[llvm] [X86] Generate `kmov` for masking integers (PR #120593)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 23 00:27:14 PST 2024


RKSimon wrote:

This is what you're matching:
```
Type-legalized selection DAG: %bb.0 'pr120593_16_ne:'
SelectionDAG has 31 nodes:
  t0: ch,glue = EntryToken
  t2: i32,ch = CopyFromReg t0, Register:i32 %0
          t34: v16i32 = BUILD_VECTOR t2, t2, t2, t2, t2, t2, t2, t2, t2, t2, t2, t2, t2, t2, t2, t2
          t23: v16i32 = BUILD_VECTOR Constant:i32<1>, Constant:i32<2>, Constant:i32<4>, Constant:i32<8>, Constant:i32<16>, Constant:i32<32>, Constant:i32<64>, Constant:i32<128>, Constant:i32<256>, Constant:i32<512>, Constant:i32<1024>, Constant:i32<2048>, Constant:i32<4096>, Constant:i32<8192>, Constant:i32<16384>, Constant:i32<32768>
        t24: v16i32 = and t34, t23
        t26: v16i32 = BUILD_VECTOR Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>, Constant:i32<0>
      t28: v16i1 = setcc t24, t26, setne:ch
    t29: v16i8 = any_extend t28
  t32: ch,glue = CopyToReg t0, Register:v16i8 $xmm0, t29
  t33: ch = X86ISD::RET_GLUE t32, TargetConstant:i32<0>, Register:v16i8 $xmm0, t32:1
```
You'd probably be better off trying to fold this inside combineSETCC - there's already a number of similar patterns that get folded in there.

What you're after is folding this to something like: `(sext v16i8 (v16i1 bitcast(i16 trunc (i32 t2))))`

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


More information about the llvm-commits mailing list