[llvm] [InstCombine] Fold `select (a == V1 | a == V2), a, V2` to `select (a == V1), V1, V2` (PR #76203)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 22 08:36:49 PST 2023


XChy wrote:

> This transform looks unnecessarily specific to me. I think what you actually want to do is this: https://alive2.llvm.org/ce/z/sN48Rm
> 
> We only need the one icmp in the condition, the other one is irrelevant. If the other icmp allows an operand replacement in the select, we already have a separate fold that will do that (select value equivalence fold).

Sounds great to me! It also applies to `and(cmp, icmp ne)`, with [proof](https://alive2.llvm.org/ce/z/k6uRw-). I wonder how you generalize these patterns, just replace the component with argument randomly?

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


More information about the llvm-commits mailing list