[llvm] [InstCombine] Optimize nested select operators into a simpler form. Added test cases (PR #201453)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 00:19:17 PDT 2026


https://github.com/antoniofrighetto commented:

It seems like this folding already takes place when the nested select false arm matches the outer select false arm via the following recent extension (80d9df6b054cebfbe97d709195be4e61a7acc694):

https://github.com/llvm/llvm-project/blob/50f452f4b561eafccec23f649e379d9c845afa64/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L4972-L4980

The select with constant false is then simplified into an `and` via `foldSelectOfBools` (which also checks if any of the select arm implies poison). Is the existing fold performing suboptimally?

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


More information about the llvm-commits mailing list