[llvm] [VectorCombine][X86] Use updated getVectorInstrCost hook (PR #137823)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 11 17:11:07 PDT 2025


fmayer wrote:

> > Alive seems to approve of this transformation: https://alive2.llvm.org/ce/z/xUNKWG
> 
> FWIW this patch didn't actually change the transformation, but just changed the cost model so it might kick in more places. So I guess if the transformation was faulty it would have already existed before this patch.
> 
> Is it possible to reduce the test case with llvm-reduce somehow?

Yeah I am working on that. I just diffed the IR and hoped something would come out, but it all looks good.
```
   %28 = load i64, ptr %add.ptr87, align 1, !dbg !190701, !alias.scope !190705
-  %vecinit1.i.i.i519 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %28, i64 0, !dbg !190701
-  %cmp.i.i.i362 = icmp ult <2 x i64> %vecinit1.i.i.i519, splat (i64 2), !dbg !190710
+  %cmp.i.i.i362.scalar = icmp ult i64 %28, 2, !dbg !190710
+  %cmp.i.i.i362 = insertelement <2 x i1> <i1 poison, i1 true>, i1 %cmp.i.i.i362.scalar, i64 0, !dbg !190710
```

https://alive2.llvm.org/ce/z/CyUZmA

```
-  %14 = shl <2 x i64> %vecinit1.i.i, splat (i64 1), !dbg !190577
+  %.scalar = shl i64 %11, 1, !dbg !190577
+  %14 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %.scalar, i64 0, !dbg !190577
   %15 = call noundef <2 x double> @llvm.x86.avx.vpermilvar.pd(<2 x double> <double 4.940660e-324, double 9.881310e-324>, <2 x i64> %14), !dbg !190585
   %16 = bitcast <2 x double> %15 to <2 x i64>, !dbg !190586
   %17 = load ptr, ptr %expected, align 8, !dbg !190593
```

https://alive2.llvm.org/ce/z/SV9bKL

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


More information about the llvm-commits mailing list