[PATCH] D46340: AMDGPU/SI: Handle infinite loop for the structurizer to work with CFG with infinite loops.
Changpeng Fang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 3 16:45:16 PDT 2018
cfang marked an inline comment as done.
cfang added a comment.
In https://reviews.llvm.org/D46340#1086444, @nhaehnle wrote:
> So this does not cover all possible cases of "irreducible" infinite loops, e.g. consider the case with basic blocks A and B where both end with a conditional branch that can go to either A or B. I.e., there are no unconditional branches in the loop.
>
> A more robust approach would be to also transform conditional branches like this:
>
> br i1 %cc, label %A, label %B
>
>
> becomes
>
> br i1 true, label %DummyReturnBB, label %local_dummy
> local_dummy:
> br i1 %cc, label %A, label %b
>
Thank you so much for pointing out this case and providing the algorithm. Done as suggested.
================
Comment at: lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp:194
+ ConstantInt *BoolTrue = ConstantInt::getTrue(F.getContext());
+ BB->getInstList().pop_back(); // Remove the unconditional branch.
+ // Add a new conditional branch with a dummy edge to the return block.
----------------
nhaehnle wrote:
> Shouldn't this use eraseFromParent()?
Right. There are other places in the same file need to do the same thing using eraseFromParent(). Will do in a separate patch.
https://reviews.llvm.org/D46340
More information about the llvm-commits
mailing list