This is a part of https://reviews.llvm.org/D108910
We replace all loop PHIs with values coming from the loop preheader if we proved that backedge is never taken.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Reverted patch due to issue caught in post commit review. See inline.
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
1317 | As written, this code does not preserve LCSSA. Consider the case where we have two sibling loops and the header of the second is directly an exit block of the first. This is not loop simplify form (i.e. no preheader), but it is a possible case. |
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
1317 | Philip, there is an assert on line 1741 that the loop is in simplify form. I don't think the situation you are referring to is even possible. |
Just to close the loop here, I agree with Max that the case I was concerned about was not possible due to an earlier bail out. The reapply of the reverted patch and the added assert resolve my concern entirely. Thanks.
(Sorry for delayed response, took a vacation last week and thus only seeing this now.)
As written, this code does not preserve LCSSA. Consider the case where we have two sibling loops and the header of the second is directly an exit block of the first. This is not loop simplify form (i.e. no preheader), but it is a possible case.