<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I temporarily reverted the patch, because it depends on r363289, which breaks a green dragon<br class="">build:<br class=""> <a href="http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/18208" class="">http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/18208</a><div class=""><br class=""></div><div class="">I’ll upload a reduced reproducer at <a href="https://bugs.llvm.org/show_bug.cgi?id=42279" class="">https://bugs.llvm.org/show_bug.cgi?id=42279</a> as soon as bugpoint is done.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 13, 2019, at 19:40, Philip Reames via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Author: reames<br class="">Date: Thu Jun 13 11:40:15 2019<br class="">New Revision: 363293<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=363293&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=363293&view=rev</a><br class="">Log:<br class="">[LFTR] Rename variable to minimize confusion [NFC]<br class=""><br class="">As pointed out by Nikita in D62625, BackedgeTakenCount is generally used to refer to the backedge taken count of the loop. A conditional backedge taken count - one which only applies if a particular exit is taken - is called a ExitCount in SCEV code, so be consistent here.<br class=""><br class=""><br class="">Modified:<br class=""> llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp<br class=""><br class="">Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=363293&r1=363292&r2=363293&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=363293&r1=363292&r2=363293&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)<br class="">+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Jun 13 11:40:15 2019<br class="">@@ -151,7 +151,7 @@ class IndVarSimplify {<br class=""> bool hasHardUserWithinLoop(const Loop *L, const Instruction *I) const;<br class=""><br class=""> bool linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,<br class="">- const SCEV *BackedgeTakenCount,<br class="">+ const SCEV *ExitCount,<br class=""> PHINode *IndVar, SCEVExpander &Rewriter);<br class=""><br class=""> bool sinkUnusedInvariants(Loop *L);<br class="">@@ -2382,8 +2382,7 @@ static Value *genLoopLimit(PHINode *IndV<br class=""> /// determine a loop-invariant trip count of the loop, which is actually a much<br class=""> /// broader range than just linear tests.<br class=""> bool IndVarSimplify::<br class="">-linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,<br class="">- const SCEV *BackedgeTakenCount,<br class="">+linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB, const SCEV *ExitCount,<br class=""> PHINode *IndVar, SCEVExpander &Rewriter) {<br class=""> assert(isLoopCounter(IndVar, L, SE));<br class=""> assert(L->getLoopLatch() && "Loop no longer in simplified form?");<br class="">@@ -2392,7 +2391,7 @@ linearFunctionTestReplace(Loop *L, Basic<br class=""><br class=""> // Initialize CmpIndVar and IVCount to their preincremented values.<br class=""> Value *CmpIndVar = IndVar;<br class="">- const SCEV *IVCount = BackedgeTakenCount;<br class="">+ const SCEV *IVCount = ExitCount;<br class=""><br class=""> // If the exiting block is the same as the backedge block, we prefer to<br class=""> // compare against the post-incremented value, otherwise we must compare<br class="">@@ -2412,10 +2411,9 @@ linearFunctionTestReplace(Loop *L, Basic<br class=""> if (SafeToPostInc) {<br class=""> // Add one to the "backedge-taken" count to get the trip count.<br class=""> // This addition may overflow, which is valid as long as the comparison<br class="">- // is truncated to BackedgeTakenCount->getType().<br class="">- IVCount = SE->getAddExpr(BackedgeTakenCount,<br class="">- SE->getOne(BackedgeTakenCount->getType()));<br class="">- // The BackedgeTaken expression contains the number of times that the<br class="">+ // is truncated to ExitCount->getType().<br class="">+ IVCount = SE->getAddExpr(ExitCount, SE->getOne(ExitCount->getType()));<br class="">+ // The ExitCount expression contains the number of times that the<br class=""> // backedge branches to the loop header. This is one less than the<br class=""> // number of times the loop executes, so use the incremented indvar.<br class=""> CmpIndVar = IncVar;<br class="">@@ -2481,9 +2479,9 @@ linearFunctionTestReplace(Loop *L, Basic<br class=""> if (isa<SCEVConstant>(ARStart) && isa<SCEVConstant>(IVCount)) {<br class=""> const APInt &Start = cast<SCEVConstant>(ARStart)->getAPInt();<br class=""> APInt Count = cast<SCEVConstant>(IVCount)->getAPInt();<br class="">- // Note that the post-inc value of BackedgeTakenCount may have overflowed<br class="">+ // Note that the post-inc value of ExitCount may have overflowed<br class=""> // above such that IVCount is now zero.<br class="">- if (IVCount != BackedgeTakenCount && Count == 0) {<br class="">+ if (IVCount != ExitCount && Count == 0) {<br class=""> Count = APInt::getMaxValue(Count.getBitWidth()).zext(CmpIndVarSize);<br class=""> ++Count;<br class=""> }<br class="">@@ -2710,21 +2708,21 @@ bool IndVarSimplify::run(Loop *L) {<br class=""> if (!needsLFTR(L, ExitingBB))<br class=""> continue;<br class=""><br class="">- const SCEV *BETakenCount = SE->getExitCount(L, ExitingBB);<br class="">- if (isa<SCEVCouldNotCompute>(BETakenCount))<br class="">+ const SCEV *ExitCount = SE->getExitCount(L, ExitingBB);<br class="">+ if (isa<SCEVCouldNotCompute>(ExitCount))<br class=""> continue;<br class=""><br class=""> // Better to fold to true (TODO: do so!)<br class="">- if (BETakenCount->isZero())<br class="">+ if (ExitCount->isZero())<br class=""> continue;<br class=""><br class="">- PHINode *IndVar = FindLoopCounter(L, ExitingBB, BETakenCount, SE, DT);<br class="">+ PHINode *IndVar = FindLoopCounter(L, ExitingBB, ExitCount, SE, DT);<br class=""> if (!IndVar)<br class=""> continue;<br class=""><br class=""> // Avoid high cost expansions. Note: This heuristic is questionable in<br class=""> // that our definition of "high cost" is not exactly principled. <br class="">- if (Rewriter.isHighCostExpansion(BETakenCount, L))<br class="">+ if (Rewriter.isHighCostExpansion(ExitCount, L))<br class=""> continue;<br class=""><br class=""> // Check preconditions for proper SCEVExpander operation. SCEV does not<br class="">@@ -2736,10 +2734,9 @@ bool IndVarSimplify::run(Loop *L) {<br class=""> //<br class=""> // FIXME: SCEV expansion has no way to bail out, so the caller must<br class=""> // explicitly check any assumptions made by SCEV. Brittle.<br class="">- const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(BETakenCount);<br class="">+ const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(ExitCount);<br class=""> if (!AR || AR->getLoop()->getLoopPreheader())<br class="">- Changed |= linearFunctionTestReplace(L, ExitingBB,<br class="">- BETakenCount, IndVar,<br class="">+ Changed |= linearFunctionTestReplace(L, ExitingBB, ExitCount, IndVar,<br class=""> Rewriter);<br class=""> }<br class=""> }<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""></div></div></blockquote></div><br class=""></div></body></html>