summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorBalaram Makam <bmakam@codeaurora.org>2016-05-04 21:32:14 +0000
committerBalaram Makam <bmakam@codeaurora.org>2016-05-04 21:32:14 +0000
commit569eaec5f3af5996abff7bc9e8d82c66ef5e5484 (patch)
tree79b479250a2c673d31663b44b94763c643c4c99e /llvm/lib/IR
parent3fa5bbd91b370705de5c114ddc5f0f240e13ecd1 (diff)
downloadbcm5719-llvm-569eaec5f3af5996abff7bc9e8d82c66ef5e5484.tar.gz
bcm5719-llvm-569eaec5f3af5996abff7bc9e8d82c66ef5e5484.zip
"Reapply r268521 "[InstCombine] Canonicalize icmp instructions based on dominating conditions.""
This reapplies commit r268521, that was reverted in r268530 due to a test failure in select-implied.ll Modified the test case to reflect the new change. llvm-svn: 268557
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/ConstantRange.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 417b752d1a2..a2eb1517f57 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -127,6 +127,18 @@ ConstantRange ConstantRange::makeSatisfyingICmpRegion(CmpInst::Predicate Pred,
.inverse();
}
+ConstantRange ConstantRange::makeExactICmpRegion(CmpInst::Predicate Pred,
+ const APInt &C) {
+ // Computes the exact range that is equal to both the constant ranges returned
+ // by makeAllowedICmpRegion and makeSatisfyingICmpRegion. This is always true
+ // when RHS is a singleton such as an APInt and so the assert is valid.
+ // However for non-singleton RHS, for example ult [2,5) makeAllowedICmpRegion
+ // returns [0,4) but makeSatisfyICmpRegion returns [0,2).
+ //
+ assert(makeAllowedICmpRegion(Pred, C) == makeSatisfyingICmpRegion(Pred, C));
+ return makeAllowedICmpRegion(Pred, C);
+}
+
ConstantRange
ConstantRange::makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp,
const ConstantRange &Other,
OpenPOWER on IntegriCloud