[llvm] [InstCombine] Fold selection between less than zero and one (PR #69961)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 23:45:48 PDT 2023


XChy wrote:

For example, `cmp1 ? cmp2 : 1` is equivalent to `(cmp1 & cmp2) | (!cmp1)`. When the constant range of cmp1 is a subset of cmp2, it could be seen as `cmp1 | !cmp1` -> `1`.

However, I found that InstCombine has handled such pattern, just missing here for `a < 0` being `a << BW - 1`.
My 2c is to transform `(A pred C) ? (A << BW - 1) : 1` into `ZExt ((A pred C) ? A < 0 : 1)`.

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


More information about the llvm-commits mailing list