NewGVN: Make sure we add the correct user if we swapped the comparison operands

llvm-svn: 312162
This commit is contained in:
Daniel Berlin 2017-08-30 19:53:23 +00:00
parent 7ef26daba8
commit 23fec57e6f
1 changed files with 4 additions and 2 deletions

View File

@ -1476,7 +1476,8 @@ NewGVN::performSymbolicPredicateInfoEvaluation(Instruction *I) const {
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::performSymbolicPredicateInfoEvaluation(Instruction *I) const {
(!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));
}
}