Check that a s_cbranch_execz is not a loop exit before removing it.
As the pass is generating infinite loops.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
You are right, the s_cbranch_execz shouldn't be removed from this loop exit BB.
But depending on the MachineLoopInfo to fix it is not good in general. There are irreducible control flows and the check may fail.
There is already a special check in function mustRetainExeczBranch, looking for loop code if the opcode is S_CBRANCH_VCCNZ & S_CBRANCH_VCCZ.
We should include S_CBRANCH_SCC0 & S_CBRANCH_SCC1 here. I hope this guarantees to be working for such cases.
If everyone agrees, I can create a patch and fix it.
That would work for my test case (essentially a slightly more complex version of lit test).
I am happy with your proposed change, if others agree then I will abandon this one.
llvm/lib/Target/AMDGPU/SIRemoveShortExecBranches.cpp | ||
---|---|---|
94 | Special casing execnz just doesn't make sense to me. execz/execnz are morally equivalent |
Remove C_BRANCH_EXECNZ special case.
This revives a c_branch_execz in one lit test.
Alternatively we special case both exec_nz/exec_z.
However this ceases to feel much better than simply stating all the accepted branch types.
Special casing execnz just doesn't make sense to me. execz/execnz are morally equivalent