[llvm] [InstCombine] Simplify zext(sub(0, trunc(x))) -> and(sub(0, x), mask) (Fixes #165306) (PR #167101)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 8 05:06:56 PST 2025


RKSimon wrote:

@dtcxzyw  This is the original test case, I may have oversimplified the missing transform:
```ll
define <2 x i64> @src(<2 x i64> %0, <2 x i64> %1) {
Entry:
  %2 = trunc <2 x i64> %1 to <2 x i6>
  %3 = sub <2 x i6> zeroinitializer, %2
  %4 = zext <2 x i6> %3 to <2 x i64>
  %5 = shl <2 x i64> %0, %4
  %6 = and <2 x i64> %1, splat (i64 63)
  %7 = lshr <2 x i64> %0, %6
  %8 = or <2 x i64> %5, %7
  ret <2 x i64> %8
}
```

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


More information about the llvm-commits mailing list