From 0b7c6422fbd0c837142f347ab92a650706ebcedf Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Mon, 5 Mar 2018 17:33:50 +0000 Subject: [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 --- llvm/lib/Transforms/Scalar/SCCP.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp') 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 -- cgit v1.2.3