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
Event Timeline
lib/Transforms/Utils/LoopSimplify.cpp | ||
---|---|---|
753 | 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 | Can this be folded to true? (I'm not asking you to do that in this change itself.) |
lib/Transforms/Utils/LoopSimplify.cpp | ||
---|---|---|
753 | Good point. I'll add some verification. | |
786 | 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 | 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 ↗ | (On Diff #60114) | 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 ↗ | (On Diff #60114) | 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.
We should definitely add asserts verifying this. I'd suggest something like
(i.e. we should also catch cases where simplifying a loop breaks LCSSA in another loop).