As part of a particular optimization (InstCombine for example),
the situations may occur when we exit the loop on the true branch.
This transformation breaks a number of optimizations.
Therefore, it was decided to restore such instructions.
Details
- Reviewers
mkazantsev lebedev.ri
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
And what if the condition had other users?
And what if the condition was not relational?
Please just insert xor %cond, -1.
This is missing tests (please precommit) that now are getting optimized.
This is almost certainly not the correct way to fix whatever problem you're trying to fix. If an optimization doesn't work with commuted branch targets, then that optimization needs to be fixed.
There is always a tradeoff between having a canonical form and expecting this canonical form in transforms, and trying to support everything. I've seen enough cases where exit by false isn't [fully] supported, so saying that "fallthrough stays in loop is our canonical form" isn't a that bad idea in general.
Besides, even if it's not about the optimizations, codegen will still do something similar when it tries to lay out the blocks. So generally I like the idea of this patch (though I think the place for doing it is wrong).
llvm/lib/Transforms/Utils/LoopSimplify.cpp | ||
---|---|---|
543 | How is that even possible? | |
545 | m_match(BI, m_Br(m_ICmp (...) ) | |
548 | Changed = true somewhere? |
This review may be stuck/dead, consider abandoning if no longer relevant.
Removing myself as reviewer in attempt to clean dashboard.
How is that even possible?
UB here.