Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
Show First 20 Lines • Show All 1,579 Lines • ▼ Show 20 Lines | NewGVN::performSymbolicPredicateInfoEvaluation(Instruction *I) const { | ||||
if (shouldSwapOperands(FirstOp, SecondOp)) { | if (shouldSwapOperands(FirstOp, SecondOp)) { | ||||
std::swap(FirstOp, SecondOp); | std::swap(FirstOp, SecondOp); | ||||
SwappedOps = true; | SwappedOps = true; | ||||
} | } | ||||
CmpInst::Predicate Predicate = | CmpInst::Predicate Predicate = | ||||
SwappedOps ? Cmp->getSwappedPredicate() : Cmp->getPredicate(); | SwappedOps ? Cmp->getSwappedPredicate() : Cmp->getPredicate(); | ||||
if (isa<PredicateAssume>(PI)) { | if (isa<PredicateAssume>(PI)) { | ||||
// If the comparison is true when the operands are equal, then we know the | // If we assume the operands are equal, then they are equal. | ||||
// operands are equal, because assumes must always be true. | if (Predicate == CmpInst::ICMP_EQ) { | ||||
if (CmpInst::isTrueWhenEqual(Predicate)) { | |||||
addPredicateUsers(PI, I); | addPredicateUsers(PI, I); | ||||
addAdditionalUsers(Cmp->getOperand(0), I); | addAdditionalUsers(SwappedOps ? Cmp->getOperand(1) : Cmp->getOperand(0), | ||||
I); | |||||
return createVariableOrConstant(FirstOp); | return createVariableOrConstant(FirstOp); | ||||
} | } | ||||
} | } | ||||
if (const auto *PBranch = dyn_cast<PredicateBranch>(PI)) { | if (const auto *PBranch = dyn_cast<PredicateBranch>(PI)) { | ||||
// If we are *not* a copy of the comparison, we may equal to the other | // If we are *not* a copy of the comparison, we may equal to the other | ||||
// operand when the predicate implies something about equality of | // operand when the predicate implies something about equality of | ||||
// operations. In particular, if the comparison is true/false when the | // operations. In particular, if the comparison is true/false when the | ||||
// operands are equal, and we are on the right edge, we know this operation | // operands are equal, and we are on the right edge, we know this operation | ||||
▲ Show 20 Lines • Show All 2,696 Lines • Show Last 20 Lines |