From: Sanjay Patel Date: Mon, 28 Sep 2015 22:14:51 +0000 (+0000) Subject: tidy up comments; NFC X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=76008224f0c321f1ec35df52a70e29e578765492;p=oota-llvm.git tidy up comments; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248750 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index c69b0388471..c4c97ff0a3d 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -3849,19 +3849,19 @@ static bool isFormingBranchFromSelectProfitable(SelectInst *SI) { CmpInst *Cmp = dyn_cast(SI->getCondition()); - // If the branch is predicted right, an out of order CPU can avoid blocking on - // the compare. Emit cmovs on compares with a memory operand as branches to - // avoid stalls on the load from memory. If the compare has more than one use - // there's probably another cmov or setcc around so it's not worth emitting a - // branch. + // If a branch is predictable, an out-of-order CPU can avoid blocking on its + // comparison condition. If the compare has more than one use, there's + // probably another cmov or setcc around, so it's not worth emitting a branch. if (!Cmp || !Cmp->hasOneUse()) return false; Value *CmpOp0 = Cmp->getOperand(0); Value *CmpOp1 = Cmp->getOperand(1); - // We check that the memory operand has one use to avoid uses of the loaded - // value directly after the compare, making branches unprofitable. + // Emit "cmov on compare with a memory operand" as a branch to avoid stalls + // on a load from memory. But if the load is used more than once, do not + // change the select to a branch because the load is probably needed + // regardless of whether the branch is taken or not. return ((isa(CmpOp0) && CmpOp0->hasOneUse()) || (isa(CmpOp1) && CmpOp1->hasOneUse())); }