[llvm] [SimplifyCFG] Simplify conditional branches on const icmp eq's (PR #73334)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 24 07:52:36 PST 2023


nikic wrote:

> > What is the broader motivation for this? That is, why is it important to handle this within a single SimplifyCFG invocation? We'd probably want to have a PhaseOrdering test for that.
> 
> Pay close attention to the test. To fully simplify the test case with existing code you'd need to run SimplifyCFG first, then a pass that folds constants, then SimplifyCFG again. That, to me, seemed unreasonable - hence the PR.

It *is* generally necessary to run SimplifyCFG, InstCombine and SimplifyCFG again to get most optimization opportunities. It can make sense to short-cut this in specific cases for phase ordering reasons, but we should have specific motivation for that. That's why I'm asking what your original motivation here is.

Another possibility is to make InstCombine slightly stronger so it can fold the phi away without a prior SimplifyCFG run -- in fact, it already does so for blocks that are dynamically unreachable, but fails to do that for blocks that are statically unreachable. That difference in not intended and just an implementation artifact.

https://github.com/llvm/llvm-project/pull/73334


More information about the llvm-commits mailing list