diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2009-07-11 06:15:39 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2009-07-11 06:15:39 +0000 |
| commit | dcfdce9067178c396f5d3e70385f407343753f4b (patch) | |
| tree | b39c07bebc1bb176967964a2e0a70854155fd0d7 /llvm/lib/Transforms | |
| parent | da03e8443ea8773e966e62a8539bd47b7abe3790 (diff) | |
| download | bcm5719-llvm-dcfdce9067178c396f5d3e70385f407343753f4b.tar.gz bcm5719-llvm-dcfdce9067178c396f5d3e70385f407343753f4b.zip | |
Move a method that creates constant ranges relative to another constant range
per icmp predicate out of predsimplify and into ConstantRange.
Add another utility method that determines whether one range is a subset of
another. Combine with the former to determine whether icmp pred range, range
is known to be true or not.
llvm-svn: 75357
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp | 59 |
1 files changed, 5 insertions, 54 deletions
diff --git a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp index 24707bd4d86..c82c4ff3bfb 100644 --- a/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -990,7 +990,7 @@ namespace { assert(!CR.isEmptySet() && "Can't deal with empty set."); if (LV == NE) - return makeConstantRange(ICmpInst::ICMP_NE, CR); + return ConstantRange::makeICmpRegion(ICmpInst::ICMP_NE, CR); unsigned LV_s = LV & (SGT_BIT|SLT_BIT); unsigned LV_u = LV & (UGT_BIT|ULT_BIT); @@ -999,73 +999,24 @@ namespace { ConstantRange Range(CR.getBitWidth()); if (LV_s == SGT_BIT) { - Range = Range.maximalIntersectWith(makeConstantRange( + Range = Range.maximalIntersectWith(ConstantRange::makeICmpRegion( hasEQ ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_SGT, CR)); } else if (LV_s == SLT_BIT) { - Range = Range.maximalIntersectWith(makeConstantRange( + Range = Range.maximalIntersectWith(ConstantRange::makeICmpRegion( hasEQ ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_SLT, CR)); } if (LV_u == UGT_BIT) { - Range = Range.maximalIntersectWith(makeConstantRange( + Range = Range.maximalIntersectWith(ConstantRange::makeICmpRegion( hasEQ ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_UGT, CR)); } else if (LV_u == ULT_BIT) { - Range = Range.maximalIntersectWith(makeConstantRange( + Range = Range.maximalIntersectWith(ConstantRange::makeICmpRegion( hasEQ ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_ULT, CR)); } return Range; } - /// makeConstantRange - Creates a ConstantRange representing the set of all - /// value that match the ICmpInst::Predicate with any of the values in CR. - ConstantRange makeConstantRange(ICmpInst::Predicate ICmpOpcode, - const ConstantRange &CR) { - uint32_t W = CR.getBitWidth(); - switch (ICmpOpcode) { - default: assert(!"Invalid ICmp opcode to makeConstantRange()"); - case ICmpInst::ICMP_EQ: - return ConstantRange(CR.getLower(), CR.getUpper()); - case ICmpInst::ICMP_NE: - if (CR.isSingleElement()) - return ConstantRange(CR.getUpper(), CR.getLower()); - return ConstantRange(W); - case ICmpInst::ICMP_ULT: - return ConstantRange(APInt::getMinValue(W), CR.getUnsignedMax()); - case ICmpInst::ICMP_SLT: - return ConstantRange(APInt::getSignedMinValue(W), CR.getSignedMax()); - case ICmpInst::ICMP_ULE: { - APInt UMax(CR.getUnsignedMax()); - if (UMax.isMaxValue()) - return ConstantRange(W); - return ConstantRange(APInt::getMinValue(W), UMax + 1); - } - case ICmpInst::ICMP_SLE: { - APInt SMax(CR.getSignedMax()); - if (SMax.isMaxSignedValue() || (SMax+1).isMaxSignedValue()) - return ConstantRange(W); - return ConstantRange(APInt::getSignedMinValue(W), SMax + 1); - } - case ICmpInst::ICMP_UGT: - return ConstantRange(CR.getUnsignedMin() + 1, APInt::getNullValue(W)); - case ICmpInst::ICMP_SGT: - return ConstantRange(CR.getSignedMin() + 1, - APInt::getSignedMinValue(W)); - case ICmpInst::ICMP_UGE: { - APInt UMin(CR.getUnsignedMin()); - if (UMin.isMinValue()) - return ConstantRange(W); - return ConstantRange(UMin, APInt::getNullValue(W)); - } - case ICmpInst::ICMP_SGE: { - APInt SMin(CR.getSignedMin()); - if (SMin.isMinSignedValue()) - return ConstantRange(W); - return ConstantRange(SMin, APInt::getSignedMinValue(W)); - } - } - } - #ifndef NDEBUG bool isCanonical(Value *V, DomTreeDFS::Node *Subtree) { return V == VN.canonicalize(V, Subtree); |

