[llvm] [SimplifyCFG] Don't limit the number of simultaneous forwards from switch condition (PR #95932)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 01:28:45 PDT 2024


DianQK wrote:

> It's a tricky question. I'd generally say that having constants instead of variables is "more canonical" -- and in fact, we have quite a lot of passes that will undo what SimplifyCFG does here. At least IPSCCP, CVP and GVN do this. This is bad in itself, because it means that IR toggles back and forth between two forms. Conversely, it also means that many passes have a chance to optimize IR in both forms. The backend generally prefers phi operands not to be constants (though this is a pretty generic problem and SimplifyCFG isn't really the place to address it I think).

I have seen some similar things. These transforms are just back and forth, and it doesn't seem like they are being utilized.
I think a possible solution could be to treat this as a result of some analysis pass, and apply it when it's beneficial to use this result for certain transformations. Then transform it to phi operands before the backend.

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


More information about the llvm-commits mailing list