[llvm] [SimplifyCFG] Forward indirect switch condition value if it can help fold the PHI (PR #95932)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 06:17:55 PDT 2024


DianQK wrote:

This patch will cause values in the PHI to become switch condition values, leading to an infinite loop. Additionally, it doesn't align well with the intent of the function. I have changed it to check if the PHI already contains the switch condition value.

Forwarding is meaningful for the test case in this PR: [https://alive2.llvm.org/ce/z/Z46qt6](https://alive2.llvm.org/ce/z/Z46qt6).
Based on the above discussions, I plan to implement the following changes in subsequent PRs:

- Forward switch condition value to constant before backend execution
- Forward only when the PHI can be folded. For instance, when there are multiple PHI nodes, checking only itself is insufficient. This should also help avoid potentially pointless transforms with IPSCCP and other passes, possibly reducing compilation time slightly.

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


More information about the llvm-commits mailing list