diff options
author | Florian Hahn <florian.hahn@arm.com> | 2018-03-05 17:33:50 +0000 |
---|---|---|
committer | Florian Hahn <florian.hahn@arm.com> | 2018-03-05 17:33:50 +0000 |
commit | 0b7c6422fbd0c837142f347ab92a650706ebcedf (patch) | |
tree | 19b9f1e7423b9b003581c113385e014504258351 /llvm/lib/Transforms/Scalar/SCCP.cpp | |
parent | 7363a2f270e38179b259921800e99c018d15717c (diff) | |
download | bcm5719-llvm-0b7c6422fbd0c837142f347ab92a650706ebcedf.tar.gz bcm5719-llvm-0b7c6422fbd0c837142f347ab92a650706ebcedf.zip |
[IPSCCP] Add getCompare which returns either true, false, undef or null.
getCompare returns true, false or undef constants if the comparison can
be evaluated, or nullptr if it cannot. This is in line with what
ConstantExpr::getCompare returns. It also allows us to use
ConstantExpr::getCompare for comparing constants.
Reviewers: davide, mssimpso, dberlin, anna
Reviewed By: davide
Differential Revision: https://reviews.llvm.org/D43761
llvm-svn: 326720
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 329c7570b45..da8b6cfda5f 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1644,12 +1644,7 @@ static bool tryToReplaceWithConstantRange(SCCPSolver &Solver, Value *V) { ValueLatticeElement A = getIcmpLatticeValue(Icmp->getOperand(0)); ValueLatticeElement B = getIcmpLatticeValue(Icmp->getOperand(1)); - Constant *C = nullptr; - if (A.satisfiesPredicate(Icmp->getPredicate(), B)) - C = ConstantInt::getTrue(Icmp->getType()); - else if (A.satisfiesPredicate(Icmp->getInversePredicate(), B)) - C = ConstantInt::getFalse(Icmp->getType()); - + Constant *C = A.getCompare(Icmp->getPredicate(), Icmp->getType(), B); if (C) { Icmp->replaceAllUsesWith(C); DEBUG(dbgs() << "Replacing " << *Icmp << " with " << *C |