[llvm] r312162 - NewGVN: Make sure we add the correct user if we swapped the comparison operands

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 12:53:24 PDT 2017


Author: dannyb
Date: Wed Aug 30 12:53:23 2017
New Revision: 312162

URL: http://llvm.org/viewvc/llvm-project?rev=312162&view=rev
Log:
NewGVN: Make sure we add the correct user if we swapped the comparison operands

Modified:
    llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=312162&r1=312161&r2=312162&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Wed Aug 30 12:53:23 2017
@@ -1476,7 +1476,8 @@ NewGVN::performSymbolicPredicateInfoEval
     if ((PBranch->TrueEdge && Predicate == CmpInst::ICMP_EQ) ||
         (!PBranch->TrueEdge && Predicate == CmpInst::ICMP_NE)) {
       addPredicateUsers(PI, I);
-      addAdditionalUsers(Cmp->getOperand(0), I);
+      addAdditionalUsers(SwappedOps ? Cmp->getOperand(1) : Cmp->getOperand(0),
+                         I);
       return createVariableOrConstant(FirstOp);
     }
     // Handle the special case of floating point.
@@ -1484,7 +1485,8 @@ NewGVN::performSymbolicPredicateInfoEval
          (!PBranch->TrueEdge && Predicate == CmpInst::FCMP_UNE)) &&
         isa<ConstantFP>(FirstOp) && !cast<ConstantFP>(FirstOp)->isZero()) {
       addPredicateUsers(PI, I);
-      addAdditionalUsers(Cmp->getOperand(0), I);
+      addAdditionalUsers(SwappedOps ? Cmp->getOperand(1) : Cmp->getOperand(0),
+                         I);
       return createConstantExpression(cast<Constant>(FirstOp));
     }
   }




More information about the llvm-commits mailing list