[llvm] [RISCV] Fold vector shift of sext/zext to widening multiply (PR #121563)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 3 03:49:23 PST 2025


================
@@ -238,12 +238,20 @@ define <vscale x 2 x i64> @vwsll_vx_i8_nxv2i64_zext(<vscale x 2 x i32> %a, i8 %b
 }
 
 define <vscale x 2 x i64> @vwsll_vi_nxv2i64(<vscale x 2 x i32> %a, <vscale x 2 x i1> %m, i32 zeroext %vl) {
-; CHECK-LABEL: vwsll_vi_nxv2i64:
-; CHECK:       # %bb.0:
-; CHECK-NEXT:    vsetvli zero, a0, e64, m2, ta, ma
-; CHECK-NEXT:    vzext.vf2 v10, v8
-; CHECK-NEXT:    vsll.vi v8, v10, 2, v0.t
-; CHECK-NEXT:    ret
+; CHECK-RV32-LABEL: vwsll_vi_nxv2i64:
+; CHECK-RV32:       # %bb.0:
+; CHECK-RV32-NEXT:    vsetvli zero, a0, e64, m2, ta, ma
+; CHECK-RV32-NEXT:    vzext.vf2 v10, v8
+; CHECK-RV32-NEXT:    vsll.vi v8, v10, 2, v0.t
----------------
pfusik wrote:

The transform did not apply on RV32 here:

    17373     if (!ISD::isConstantSplatVector(RHS.getNode(), ShAmt))
    (gdb)
    17374       return SDValue();
    (gdb) call RHS->dump()
    t20: nxv2i64 = splat_vector_parts Constant:i32<2>, Constant:i32<0>

I'm guessing it's an effect of type legalization. Please advise on how to fix.

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


More information about the llvm-commits mailing list