diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-05-24 17:19:56 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-05-24 17:19:56 +0000 |
commit | 5fd7ac452e66db45baeedfd7f059152c29a13b7c (patch) | |
tree | c2054ed7e3ddbc16c72e386560aa73328e1d583d /llvm | |
parent | e78ace55df428142a7fd4ed7bd86cf61cbba8682 (diff) | |
download | bcm5719-llvm-5fd7ac452e66db45baeedfd7f059152c29a13b7c.tar.gz bcm5719-llvm-5fd7ac452e66db45baeedfd7f059152c29a13b7c.zip |
[IRCE] Return a Value*, not SCEV* from parseRangeCheck; NFC
This is better layering, since the caller needs to check if the index
was an add-rec anyway.
llvm-svn: 270582
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp index 2b9f3f59c8e..1b5cf89b4d9 100644 --- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -127,7 +127,7 @@ class InductiveRangeCheck { static InductiveRangeCheck::RangeCheckKind parseRangeCheck(Loop *L, ScalarEvolution &SE, Value *Condition, - const SCEV *&Index, Value *&UpperLimit); + Value *&Index, Value *&UpperLimit); InductiveRangeCheck() : Offset(nullptr), Scale(nullptr), Length(nullptr), @@ -317,7 +317,7 @@ InductiveRangeCheck::parseRangeCheckICmp(Loop *L, ICmpInst *ICI, /// the range check is recognized to be `RANGE_CHECK_UPPER` or stronger. InductiveRangeCheck::RangeCheckKind InductiveRangeCheck::parseRangeCheck(Loop *L, ScalarEvolution &SE, - Value *Condition, const SCEV *&Index, + Value *Condition, Value *&Index, Value *&Length) { using namespace llvm::PatternMatch; @@ -345,29 +345,14 @@ InductiveRangeCheck::parseRangeCheck(Loop *L, ScalarEvolution &SE, if (LengthA != nullptr && LengthB != nullptr && LengthA != LengthB) return InductiveRangeCheck::RANGE_CHECK_UNKNOWN; - Index = SE.getSCEV(IndexA); - if (isa<SCEVCouldNotCompute>(Index)) - return InductiveRangeCheck::RANGE_CHECK_UNKNOWN; - + Index = IndexA; Length = LengthA == nullptr ? LengthB : LengthA; return (InductiveRangeCheck::RangeCheckKind)(RCKindA | RCKindB); } - if (ICmpInst *ICI = dyn_cast<ICmpInst>(Condition)) { - Value *IndexVal = nullptr; - - auto RCKind = parseRangeCheckICmp(L, ICI, SE, IndexVal, Length); - - if (RCKind == InductiveRangeCheck::RANGE_CHECK_UNKNOWN) - return InductiveRangeCheck::RANGE_CHECK_UNKNOWN; - - Index = SE.getSCEV(IndexVal); - if (isa<SCEVCouldNotCompute>(Index)) - return InductiveRangeCheck::RANGE_CHECK_UNKNOWN; - - return RCKind; - } + if (ICmpInst *ICI = dyn_cast<ICmpInst>(Condition)) + return parseRangeCheckICmp(L, ICI, SE, Index, Length); return InductiveRangeCheck::RANGE_CHECK_UNKNOWN; } @@ -384,20 +369,19 @@ InductiveRangeCheck::create(BranchInst *BI, Loop *L, ScalarEvolution &SE, if (BPI.getEdgeProbability(BI->getParent(), (unsigned) 0) < LikelyTaken) return None; - Value *Length = nullptr; - const SCEV *IndexSCEV = nullptr; + Value *Length = nullptr, *Index = nullptr; auto RCKind = InductiveRangeCheck::parseRangeCheck(L, SE, BI->getCondition(), - IndexSCEV, Length); + Index, Length); if (RCKind == InductiveRangeCheck::RANGE_CHECK_UNKNOWN) return None; - assert(IndexSCEV && "contract with SplitRangeCheckCondition!"); + assert(Index && "contract with parseRangeCheck!"); assert((!(RCKind & InductiveRangeCheck::RANGE_CHECK_UPPER) || Length) && - "contract with SplitRangeCheckCondition!"); + "contract with parseRangeCheck!"); - const SCEVAddRecExpr *IndexAddRec = dyn_cast<SCEVAddRecExpr>(IndexSCEV); + const auto *IndexAddRec = dyn_cast<SCEVAddRecExpr>(SE.getSCEV(Index)); bool IsAffineIndex = IndexAddRec && (IndexAddRec->getLoop() == L) && IndexAddRec->isAffine(); |