summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-10-02 00:09:49 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-10-02 00:09:49 +0000
commit6ef69d97f54cbeb7c1d6764feb125191ad03c413 (patch)
treec8226380a0199de3b18b43b21712b86989188745 /llvm/lib
parent54e6a21dca76029753f4ad2dbade9d7595cae128 (diff)
downloadbcm5719-llvm-6ef69d97f54cbeb7c1d6764feb125191ad03c413.tar.gz
bcm5719-llvm-6ef69d97f54cbeb7c1d6764feb125191ad03c413.zip
[ConstantRange] Make getEquivalentICmp smarter
This change teaches getEquivalentICmp to be smarter about generating ICMP_NE and ICMP_EQ predicates. llvm-svn: 283057
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/ConstantRange.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 0f5c7128f3d..0dbefc7b0c2 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -147,6 +147,14 @@ bool ConstantRange::getEquivalentICmp(CmpInst::Predicate &Pred,
Pred = isEmptySet() ? CmpInst::ICMP_ULT : CmpInst::ICMP_UGE;
RHS = APInt(getBitWidth(), 0);
Success = true;
+ } else if (auto *OnlyElt = getSingleElement()) {
+ Pred = CmpInst::ICMP_EQ;
+ RHS = *OnlyElt;
+ Success = true;
+ } else if (auto *OnlyMissingElt = inverse().getSingleElement()) {
+ Pred = CmpInst::ICMP_NE;
+ RHS = *OnlyMissingElt;
+ Success = true;
} else if (getLower().isMinSignedValue() || getLower().isMinValue()) {
Pred =
getLower().isMinSignedValue() ? CmpInst::ICMP_SLT : CmpInst::ICMP_ULT;
OpenPOWER on IntegriCloud