[llvm] [RISCV] Select add(vec, splat(scalar)) to PADD_*S for P extension (PR #190303)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 22:30:52 PDT 2026


================
@@ -625,6 +625,29 @@ define <2 x i16> @test_non_const_splat_i16(i16 %elt) {
   ret <2 x i16> %splat
 }
 
+; Test add(vec, splat(scalar)) pattern
+define <4 x i8> @test_padd_bs_from_scalar_splat(<4 x i8> %a, i8 %b) {
+; CHECK-LABEL: test_padd_bs_from_scalar_splat:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    padd.bs a0, a0, a1
+; CHECK-NEXT:    ret
+  %insert = insertelement <4 x i8> poison, i8 %b, i32 0
+  %splat = shufflevector <4 x i8> %insert, <4 x i8> poison, <4 x i32> zeroinitializer
+  %res = add <4 x i8> %splat, %a
+  ret <4 x i8> %res
----------------
sihuan wrote:

I’ve added test cases with %splat as RHS to cover this.

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


More information about the llvm-commits mailing list