diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-10-18 22:00:57 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2017-10-18 22:00:57 +0000 |
| commit | 2f27456c826a9266f8f3e9cefafd1f7e08ab51b1 (patch) | |
| tree | 902ee13345ac35d424b945d1972b1eff339ec452 /llvm/lib/Analysis | |
| parent | 306d29977d4fb5b7e08880bf67109d656c711a12 (diff) | |
| download | bcm5719-llvm-2f27456c826a9266f8f3e9cefafd1f7e08ab51b1.tar.gz bcm5719-llvm-2f27456c826a9266f8f3e9cefafd1f7e08ab51b1.zip | |
Revert "[ScalarEvolution] Handling for ICmp occuring in the evolution chain."
This reverts commit r316054. There was some confusion over the review process:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20171016/495884.html
llvm-svn: 316129
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 45 |
1 files changed, 3 insertions, 42 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index e872e81a5e7..c69bd601aff 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -4756,26 +4756,11 @@ const SCEV *ScalarEvolution::createAddRecFromPHI(PHINode *PN) { Ops.push_back(Add->getOperand(i)); const SCEV *Accum = getAddExpr(Ops); - bool InvariantF = isLoopInvariant(Accum, L); - - if (!InvariantF && Accum->getSCEVType() == scZeroExtend) { - const SCEV *Op = dyn_cast<SCEVZeroExtendExpr>(Accum)->getOperand(); - const SCEVUnknown *Un = dyn_cast<SCEVUnknown>(Op); - if (Un && Un->getValue() && isa<Instruction>(Un->getValue()) && - dyn_cast<Instruction>(Un->getValue())->getOpcode() == - Instruction::ICmp) { - const SCEV *ICmpSC = evaluateForICmp(cast<ICmpInst>(Un->getValue())); - bool IsConstSC = ICmpSC->getSCEVType() == scConstant; - Accum = - IsConstSC ? getZeroExtendExpr(ICmpSC, Accum->getType()) : Accum; - InvariantF = IsConstSC ? true : false; - } - } - // This is not a valid addrec if the step amount is varying each // loop iteration, but is not itself an addrec in this loop. - if (InvariantF || (isa<SCEVAddRecExpr>(Accum) && - cast<SCEVAddRecExpr>(Accum)->getLoop() == L)) { + if (isLoopInvariant(Accum, L) || + (isa<SCEVAddRecExpr>(Accum) && + cast<SCEVAddRecExpr>(Accum)->getLoop() == L)) { SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap; if (auto BO = MatchBinaryOp(BEValueV, DT)) { @@ -6458,30 +6443,6 @@ void ScalarEvolution::forgetLoop(const Loop *L) { } } - -const SCEV *ScalarEvolution::evaluateForICmp(ICmpInst *IC) { - BasicBlock *Latch = nullptr; - const Loop *L = LI.getLoopFor(IC->getParent()); - - // If compare instruction is same or inverse of the compare in the - // branch of the loop latch, then return a constant evolution - // node. This shall facilitate computations of loop exit counts - // in cases where compare appears in the evolution chain of induction - // variables. - if (L && (Latch = L->getLoopLatch())) { - BranchInst *BI = dyn_cast<BranchInst>(Latch->getTerminator()); - if (BI && BI->isConditional() && BI->getCondition() == IC) { - if (BI->getSuccessor(0) != L->getHeader()) - return getZero(Type::getInt1Ty(getContext())); - else - return getOne(Type::getInt1Ty(getContext())); - } - } - - return getUnknown(IC); -} - - void ScalarEvolution::forgetValue(Value *V) { Instruction *I = dyn_cast<Instruction>(V); if (!I) return; |

