<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 28, 2016, at 3:30 AM, Mikael Holmén <<a href="mailto:mikael.holmen@ericsson.com" class="">mikael.holmen@ericsson.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Hi Michael,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">(I've been on vacation for a few days, hence my delayed answer)</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On 06/23/2016 03:38 PM, Michael Zolotukhin wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""><blockquote type="cite" class="">On Jun 23, 2016, at 2:09 AM, Mikael Holmén <<a href="mailto:mikael.holmen@ericsson.com" class="">mikael.holmen@ericsson.com</a>> wrote:<br class=""><br class="">Hi,<br class=""><br class="">On 06/23/2016 01:54 AM, Michael Zolotukhin wrote:<br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class="">On Jun 22, 2016, at 1:25 AM, Mikael Holmén <<a href="mailto:mikael.holmen@ericsson.com" class="">mikael.holmen@ericsson.com</a>> wrote:<br class=""><br class="">Hi Michael,<br class=""><br class="">The checks introduced in this commit fail on:<br class=""><br class="">opt -S -lcssa -loop-unroll red.ll<br class=""><br class="">I don't know if it's the checks or the optimization that is actually wrong.<br class=""></blockquote>Hi Mikael,<br class=""><br class="">The checks are correct, they just exposed a bug that has been there for a long time. It seems that a routine separateNestedLoop in LoopSimplify breaks LCSSA - the test you provided shows exactly that. I’ll look into how we can fix it.<br class=""></blockquote><br class="">Great!<br class=""><br class=""><blockquote type="cite" class="">Does it block you in any way?<br class=""></blockquote><br class="">Well we see the checks failing quite alot in our testing now, so I simply turned off the preservation of LCSSA in LoopSimplify as a workaround that I hope is ok until the bug is fixed for real.<br class=""><br class=""> // Temporarily turn off preservation of LCSSA to prevent #10729 from<br class=""> // triggering all the time.<br class="">#if 0<br class=""> AU.addPreservedID(LCSSAID);<br class="">#endif<br class=""><br class="">I suppose this should be ok?<br class=""></blockquote>I would suggest a different fix:<br class=""><br class="">diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp<br class="">index 2509b0a..90dd621 100644<br class="">--- a/lib/Transforms/Utils/LoopSimplify.cpp<br class="">+++ b/lib/Transforms/Utils/LoopSimplify.cpp<br class="">@@ -338,6 +338,7 @@ static Loop *separateNestedLoop(Loop *L, BasicBlock *Preheader,<br class="">       --i;<br class="">     }<br class="">   }<br class="">+   llvm::formLCSSARecursively(*L, *DT, LI, SE);<br class=""><br class="">   return NewOuter;<br class=""> }<br class=""><br class="">Could you please try that<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Sure!</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">The specific code that I attached earlier in this thread seems to work with this fix instead of my workaround.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I've run a bunch of our own normal tests and I haven't seen any problems so far with your change so that seems good as well.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">However, the basic test</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">test/Transforms/LoopSimplify/phi-node-simplify.ll</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">seems to fail with it?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">No idea if this is important but I get:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Expected 6 lines, got 10</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">with your change.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">So, if you just do something about phi-node-simplify.ll I suppose all is well.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote>Hi Mikael,</div><div><br class=""></div><div>Yes, you’re right, it’ll break phi-node-simplify.ll. To unbreak it, you could guard the call to llvm::formLCSSARecursively with  “if (PreserveLCSSA)”. However, for now I consider this just as a workaround, I hope I’ll come up with a smarter fix soon.</div><div><br class=""></div><div>Thanks,</div><div>Michael</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Thanks,</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Mikael</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">As far as I understand, it should cover all cases where LCSSA is broken and restore it (and if not it’ll give us a valuable info about other cases :-) ).<br class=""><br class="">In your version of the fix there are a couple of drawbacks, which actually can hurt you:<br class="">1) When a pass says that it doesn’t preserve LCSSA, LoopPassManager can’t schedule it along with other loop passes if they do preserve LCSSA. In result, you get two separate pass managers, which means your run all passes from the first PM for all loops first, then all pass managers from the second PM on all loops. The problem is that some passes from the first PM might rely on LoopSimplify, which is now scheduled in the second PM.<br class="">2) Most of the loop passes assume that loops are in LCSSA form. But if a pass breaks it for one loop, no one would recompute it before proceeding to another loop: it only can be recomputed when all loops are processed by this pass manager. In this case I think it won’t lead to a bug because AFAIR LoopSimplify doesn’t rely on LCSSA and it’ll be scheduled in its one PM without other passes, but still, it’s a slippery road.<br class=""><br class="">Thanks,<br class="">Michael<br class=""><br class=""><blockquote type="cite" class=""><br class="">Thanks,<br class="">Mikael<br class=""><br class=""><blockquote type="cite" class=""><br class="">Michael<br class=""><blockquote type="cite" class=""><br class="">Regards,<br class="">Mikael<br class=""><br class="">On 06/09/2016 01:13 AM, Michael Zolotukhin via llvm-commits wrote:<br class=""><blockquote type="cite" class="">Author: mzolotukhin<br class="">Date: Wed Jun  8 18:13:21 2016<br class="">New Revision: 272224<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=272224&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=272224&view=rev</a><br class="">Log:<br class="">[LoopSimplify] Preserve LCSSA when merging exit blocks.<br class=""><br class="">Summary:<br class="">This fixes PR26682. Also add LCSSA as a preserved pass to LoopSimplify,<br class="">that looks correct to me and allows to write a test for the issue.<br class=""><br class="">Reviewers: chandlerc, bogner, sanjoy<br class=""><br class="">Subscribers: llvm-commits<br class=""><br class="">Differential Revision: <a href="http://reviews.llvm.org/D21112" class="">http://reviews.llvm.org/D21112</a><br class=""><br class="">Added:<br class="">    llvm/trunk/test/Transforms/LoopSimplify/pr26682.ll<br class="">Modified:<br class="">    llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp<br class=""><br class="">Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=272224&r1=272223&r2=272224&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=272224&r1=272223&r2=272224&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original)<br class="">+++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Wed Jun  8 18:13:21 2016<br class="">@@ -686,8 +686,10 @@ ReprocessLoop:<br class="">       }<br class="">       DT->eraseNode(ExitingBlock);<br class=""><br class="">-      BI->getSuccessor(0)->removePredecessor(ExitingBlock);<br class="">-      BI->getSuccessor(1)->removePredecessor(ExitingBlock);<br class="">+      BI->getSuccessor(0)->removePredecessor(<br class="">+          ExitingBlock, /* DontDeleteUselessPHIs */ PreserveLCSSA);<br class="">+      BI->getSuccessor(1)->removePredecessor(<br class="">+          ExitingBlock, /* DontDeleteUselessPHIs */ PreserveLCSSA);<br class="">       ExitingBlock->eraseFromParent();<br class="">     }<br class="">   }<br class="">@@ -748,6 +750,7 @@ namespace {<br class="">       AU.addPreserved<GlobalsAAWrapperPass>();<br class="">       AU.addPreserved<ScalarEvolutionWrapperPass>();<br class="">       AU.addPreserved<SCEVAAWrapperPass>();<br class="">+      AU.addPreservedID(LCSSAID);<br class="">       AU.addPreserved<DependenceAnalysisWrapperPass>();<br class="">       AU.addPreservedID(BreakCriticalEdgesID);  // No critical edges added.<br class="">     }<br class="">@@ -781,11 +784,27 @@ bool LoopSimplify::runOnFunction(Functio<br class="">   SE = SEWP ? &SEWP->getSE() : nullptr;<br class="">   AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);<br class="">   bool PreserveLCSSA = mustPreserveAnalysisID(LCSSAID);<br class="">+#ifndef NDEBUG<br class="">+  if (PreserveLCSSA) {<br class="">+    assert(DT && "DT not available.");<br class="">+    assert(LI && "LI not available.");<br class="">+    bool InLCSSA =<br class="">+        all_of(*LI, [&](Loop *L) { return L->isRecursivelyLCSSAForm(*DT); });<br class="">+    assert(InLCSSA && "Requested to preserve LCSSA, but it's already broken.");<br class="">+  }<br class="">+#endif<br class=""><br class="">   // Simplify each loop nest in the function.<br class="">   for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)<br class="">     Changed |= simplifyLoop(*I, DT, LI, SE, AC, PreserveLCSSA);<br class=""><br class="">+#ifndef NDEBUG<br class="">+  if (PreserveLCSSA) {<br class="">+    bool InLCSSA =<br class="">+        all_of(*LI, [&](Loop *L) { return L->isRecursivelyLCSSAForm(*DT); });<br class="">+    assert(InLCSSA && "LCSSA is broken after loop-simplify.");<br class="">+  }<br class="">+#endif<br class="">   return Changed;<br class=""> }<br class=""><br class=""><br class="">Added: llvm/trunk/test/Transforms/LoopSimplify/pr26682.ll<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplify/pr26682.ll?rev=272224&view=auto" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplify/pr26682.ll?rev=272224&view=auto</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/Transforms/LoopSimplify/pr26682.ll (added)<br class="">+++ llvm/trunk/test/Transforms/LoopSimplify/pr26682.ll Wed Jun  8 18:13:21 2016<br class="">@@ -0,0 +1,32 @@<br class="">+; RUN: opt < %s -lcssa -loop-simplify -indvars -S | FileCheck %s<br class="">+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"<br class="">+target triple = "x86_64-unknown-unknown"<br class="">+<br class="">+@a = external global i32, align 4<br class="">+<br class="">+; Check that loop-simplify merges two loop exits, but preserves LCSSA form.<br class="">+; CHECK-LABEL: @foo<br class="">+; CHECK: for:<br class="">+; CHECK: %or.cond = and i1 %cmp1, %cmp2<br class="">+; CHECK-NOT: for.cond:<br class="">+; CHECK: for.end:<br class="">+; CHECK: %a.lcssa = phi i32 [ %a, %for ]<br class="">+define i32 @foo(i32 %x) {<br class="">+entry:<br class="">+  br label %for<br class="">+<br class="">+for:<br class="">+  %iv = phi i32 [ 0, %entry ], [ %iv.next, %for.cond ]<br class="">+  %cmp1 = icmp eq i32 %x, 0<br class="">+  %iv.next = add nuw nsw i32 %iv, 1<br class="">+  %a = load i32, i32* @a<br class="">+  br i1 %cmp1, label %for.cond, label %for.end<br class="">+<br class="">+for.cond:<br class="">+  %cmp2 = icmp slt i32 %iv.next, 4<br class="">+  br i1 %cmp2, label %for, label %for.end<br class="">+<br class="">+for.end:<br class="">+  %a.lcssa = phi i32 [ %a, %for ], [ %a, %for.cond ]<br class="">+  ret i32 %a.lcssa<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="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""><br class=""></blockquote><red.ll></blockquote></blockquote></blockquote></blockquote></div></blockquote></div><br class=""></body></html>