This fixes PR26682. Also add LCSSA as a preserved pass to LoopSimplify,
that looks correct to me and allows to write a test for the issue.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/Utils/LoopSimplify.cpp | ||
---|---|---|
753 ↗ | (On Diff #59981) | We should definitely add asserts verifying this. I'd suggest something like LoopSimplify::runOnFunction() { #ifndef NDEBUG DenseSet<Loop *> InLCSSA; // put loops that are in LCSSA in InLCSSA #endif .. do whatever it is that LoopSimplify does .. #ifndef NDEBUG // assert every Loop in InLCSSA is in LCSSA #endif } (i.e. we should also catch cases where simplifying a loop breaks LCSSA in another loop). |
786 ↗ | (On Diff #59981) | Can this be folded to true? (I'm not asking you to do that in this change itself.) |
lib/Transforms/Utils/LoopSimplify.cpp | ||
---|---|---|
753 ↗ | (On Diff #59981) | Good point. I'll add some verification. |
786 ↗ | (On Diff #59981) | Theoretically, there might be users that don't want LCSSA to be preserved. They don't have LCSSA prior loop-simplify, so PreserveLCSSA is false for them. But I'm not sure if such users exist in real world, and I'd be glad to replace it with plain true and always preserve LCSSA here (and eventually in all loop passes). |
lib/Transforms/Utils/LoopSimplify.cpp | ||
---|---|---|
786 ↗ | (On Diff #59981) | Yes, I'm more coming to the conclusion that this form of complexity |
Minor post-commit coments.
I do think we should just always preserve LCSSA. I can't come up with any good reason for not preserving it, and it gives us one fewer code path to test.
llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp | ||
---|---|---|
791–793 | Hoist the assert into the loop? As is, when the assert fires, you have to go step through a bunch ef iterations of stuff to find the loop in question. | |
803–805 | Same comment as above. |
Minor post-commit coments.
I do think we should just always preserve LCSSA. I can't come up with any good reason for not preserving it, and it gives us one fewer code path to test.
Hoist the assert into the loop? As is, when the assert fires, you have to go step through a bunch ef iterations of stuff to find the loop in question.