[Diffusion] rL277877: [LoopSimplify] Fix updating LCSSA after separating nested loops.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 11:32:55 PDT 2016
> On Aug 8, 2016, at 9:55 AM, Hans Wennborg <hans at chromium.org> wrote:
>
> Can a regular user run into this? The PR talks about the new pass
> manager. I haven't followed along very well, is that (partially)
> enabled by default these days?
It can also be exposed with the old PM (I mentioned a way in the comments to that bug). It was just discovered with the new PM.
>
> From the PR it also sounds like the original test case still fails?
I’ll look into it, probably there is more than one issue there. It still might be a good idea to merge this in, as the test from the commit would fail without the fix anyway.
Thanks,
Michael
> Thanks,
> Hans
>
> On Fri, Aug 5, 2016 at 3:12 PM, Michael Zolotukhin
> <mzolotukhin at apple.com> wrote:
>> Hi Hans,
>>
>> I think this fix is worth merging to the branch.
>>
>> Thanks,
>> Michael
>>
>>> On Aug 5, 2016, at 3:00 PM, Michael Zolotukhin <mzolotukhin at apple.com> wrote:
>>>
>>> mzolotukhin committed rL277877: [LoopSimplify] Fix updating LCSSA after separating nested loops..
>>>
>>> [LoopSimplify] Fix updating LCSSA after separating nested loops.
>>>
>>> This fixes PR28825. The problem was that we only checked if a value from
>>> a created inner loop is used in the outer loop, and fixed LCSSA for
>>> them. But we missed to fixup LCSSA for values used in exits of the outer
>>> loop.
>>>
>>>
>>> Files:
>>> /llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
>>> /llvm/trunk/test/Transforms/LoopSimplify/pr28272.ll
>>>
>>> PATCH
>>>
>>> Index: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
>>> ===================================================================
>>> --- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (revision 277876)
>>> +++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (revision 277877)
>>> @@ -376,6 +376,21 @@
>>> }
>>> }
>>> }
>>> + // We also need to check exit blocks of the outer loop - it might be using
>>> + // values from what now became an inner loop.
>>> + SmallVector<BasicBlock*, 8> ExitBlocks;
>>> + NewOuter->getExitBlocks(ExitBlocks);
>>> + for (BasicBlock *ExitBB: ExitBlocks) {
>>> + for (Instruction &I : *ExitBB) {
>>> + for (Value *Op : I.operands()) {
>>> + Instruction *OpI = dyn_cast<Instruction>(Op);
>>> + if (!OpI || !L->contains(OpI))
>>> + continue;
>>> + WorklistSet.insert(OpI);
>>> + }
>>> + }
>>> + }
>>> +
>>> SmallVector<Instruction *, 8> Worklist(WorklistSet.begin(),
>>> WorklistSet.end());
>>> formLCSSAForInstructions(Worklist, *DT, *LI);
>>> Index: llvm/trunk/test/Transforms/LoopSimplify/pr28272.ll
>>> ===================================================================
>>> --- llvm/trunk/test/Transforms/LoopSimplify/pr28272.ll (revision 277876)
>>> +++ llvm/trunk/test/Transforms/LoopSimplify/pr28272.ll (revision 277877)
>>> @@ -1,7 +1,7 @@
>>> ; RUN: opt < %s -lcssa -loop-unroll -S | FileCheck %s
>>> target triple = "x86_64-unknown-linux-gnu"
>>>
>>> -; PR28272
>>> +; PR28272, PR28825
>>> ; When LoopSimplify separates nested loops, it might break LCSSA form: values
>>> ; from the original loop might be used in the outer loop. This test invokes
>>> ; loop-unroll, which calls loop-simplify before itself. If LCSSA is broken
>>> @@ -74,3 +74,35 @@
>>> bb:
>>> br label %loop2
>>> }
>>> +
>>> +; When LoopSimplify separates nested loops, it might break LCSSA form: values
>>> +; from the original loop might be used in exit blocks of the outer loop.
>>> +; CHECK-LABEL: @foo3
>>> +define void @foo3() {
>>> +entry:
>>> + br label %bb1
>>> +
>>> +bb1:
>>> + br i1 undef, label %bb2, label %bb1
>>> +
>>> +bb2:
>>> + %a = phi i32 [ undef, %bb1 ], [ %a, %bb3 ], [ undef, %bb5 ]
>>> + br i1 undef, label %bb3, label %bb1
>>> +
>>> +bb3:
>>> + %b = load i32*, i32** undef
>>> + br i1 undef, label %bb2, label %bb4
>>> +
>>> +bb4:
>>> + br i1 undef, label %bb5, label %bb6
>>> +
>>> +bb5:
>>> + br i1 undef, label %bb2, label %bb4
>>> +
>>> +bb6:
>>> + br i1 undef, label %bb_end, label %bb1
>>> +
>>> +bb_end:
>>> + %x = getelementptr i32, i32* %b
>>> + br label %bb_end
>>> +}
>>>
>>> Users:
>>> mzolotukhin (Author)
>>>
>>> https://reviews.llvm.org/rL277877
>>>
>>>
>>>
>>
More information about the llvm-commits
mailing list