[llvm] [SelectionDAG] Scalarize binary ops of splats before legal types (PR #100749)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 02:56:30 PDT 2024
================
@@ -864,21 +864,19 @@ define <vscale x 8 x i64> @vmul_vi_nxv8i64_2(<vscale x 8 x i64> %va) {
}
define <vscale x 8 x i64> @vmul_xx_nxv8i64(i64 %a, i64 %b) nounwind {
-; RV32-LABEL: vmul_xx_nxv8i64:
-; RV32: # %bb.0:
-; RV32-NEXT: addi sp, sp, -16
-; RV32-NEXT: sw a1, 12(sp)
-; RV32-NEXT: sw a0, 8(sp)
-; RV32-NEXT: addi a0, sp, 8
-; RV32-NEXT: vsetvli a1, zero, e64, m8, ta, ma
-; RV32-NEXT: vlse64.v v8, (a0), zero
-; RV32-NEXT: sw a3, 4(sp)
-; RV32-NEXT: sw a2, 0(sp)
-; RV32-NEXT: mv a0, sp
-; RV32-NEXT: vlse64.v v16, (a0), zero
-; RV32-NEXT: vmul.vv v8, v8, v16
-; RV32-NEXT: addi sp, sp, 16
-; RV32-NEXT: ret
+; RV32NOM-LABEL: vmul_xx_nxv8i64:
+; RV32NOM: # %bb.0:
+; RV32NOM-NEXT: addi sp, sp, -16
+; RV32NOM-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
+; RV32NOM-NEXT: call __muldi3
----------------
Fros1er wrote:
It seems that Initial selection DAG has the pattern of mul(splat, splat).
```
Initial selection DAG: %bb.0 'vmul_xx_nxv8i64:'
SelectionDAG has 22 nodes:
t0: ch,glue = EntryToken
t2: i32,ch = CopyFromReg t0, Register:i32 %0
t4: i32,ch = CopyFromReg t0, Register:i32 %1
t9: i64 = build_pair t2, t4
t6: i32,ch = CopyFromReg t0, Register:i32 %2
t8: i32,ch = CopyFromReg t0, Register:i32 %3
t10: i64 = build_pair t6, t8
t13: nxv8i64 = insert_vector_elt undef:nxv8i64, t9, Constant:i32<0>
t15: nxv8i64 = insert_vector_elt undef:nxv8i64, t10, Constant:i32<0>
t17: i64 = mul t9, t10
t14: nxv8i64 = splat_vector t9
t16: nxv8i64 = splat_vector t10
t18: nxv8i64 = mul t14, t16
t20: ch,glue = CopyToReg t0, Register:nxv8i64 $v8m8, t18
t21: ch = RISCVISD::RET_GLUE t20, Register:nxv8i64 $v8m8, t20:1
Combining: t21: ch = RISCVISD::RET_GLUE t20, Register:nxv8i64 $v8m8, t20:1
Combining: t20: ch,glue = CopyToReg t0, Register:nxv8i64 $v8m8, t18
Combining: t19: nxv8i64 = Register $v8m8
Combining: t18: nxv8i64 = mul t14, t16
Creating new node: t22: i64 = mul t9, t10
Creating constant: t23: i32 = Constant<0>
Creating new node: t24: nxv8i64 = splat_vector t22
... into: t24: nxv8i64 = splat_vector t22
Combining: t24: nxv8i64 = splat_vector t22
Combining: t22: i64 = mul t9, t10
Combining: t20: ch,glue = CopyToReg t0, Register:nxv8i64 $v8m8, t24
Combining: t10: i64 = build_pair t6, t8
Combining: t9: i64 = build_pair t2, t4
Combining: t8: i32,ch = CopyFromReg t0, Register:i32 %3
Combining: t7: i32 = Register %3
Combining: t6: i32,ch = CopyFromReg t0, Register:i32 %2
Combining: t5: i32 = Register %2
Combining: t4: i32,ch = CopyFromReg t0, Register:i32 %1
Combining: t3: i32 = Register %1
Combining: t2: i32,ch = CopyFromReg t0, Register:i32 %0
Combining: t1: i32 = Register %0
Combining: t0: ch,glue = EntryToken
Optimized lowered selection DAG: %bb.0 'vmul_xx_nxv8i64:'
SelectionDAG has 16 nodes:
t0: ch,glue = EntryToken
t2: i32,ch = CopyFromReg t0, Register:i32 %0
t4: i32,ch = CopyFromReg t0, Register:i32 %1
t9: i64 = build_pair t2, t4
t6: i32,ch = CopyFromReg t0, Register:i32 %2
t8: i32,ch = CopyFromReg t0, Register:i32 %3
t10: i64 = build_pair t6, t8
t22: i64 = mul t9, t10
t24: nxv8i64 = splat_vector t22
t20: ch,glue = CopyToReg t0, Register:nxv8i64 $v8m8, t24
t21: ch = RISCVISD::RET_GLUE t20, Register:nxv8i64 $v8m8, t20:1
Legalizing node: t19: nxv8i64 = Register $v8m8
Ignoring node results
Legally typed node: t19: nxv8i64 = Register $v8m8
Legalizing node: t7: i32 = Register %3
Ignoring node results
Legally typed node: t7: i32 = Register %3
Legalizing node: t5: i32 = Register %2
Ignoring node results
Legally typed node: t5: i32 = Register %2
Legalizing node: t3: i32 = Register %1
Ignoring node results
Legally typed node: t3: i32 = Register %1
Legalizing node: t1: i32 = Register %0
Ignoring node results
Legally typed node: t1: i32 = Register %0
Legalizing node: t0: ch,glue = EntryToken
Analyzing result type: ch
Legal result type
Analyzing result type: glue
Legal result type
Legally typed node: t0: ch,glue = EntryToken
Legalizing node: t2: i32,ch = CopyFromReg t0, Register:i32 %0
Analyzing result type: i32
Legal result type
Analyzing result type: ch
Legal result type
Analyzing operand: t0: ch,glue = EntryToken
Legal operand
Legally typed node: t2: i32,ch = CopyFromReg t0, Register:i32 %0
Legalizing node: t4: i32,ch = CopyFromReg t0, Register:i32 %1
Analyzing result type: i32
Legal result type
Analyzing result type: ch
Legal result type
Analyzing operand: t0: ch,glue = EntryToken
Legal operand
Legally typed node: t4: i32,ch = CopyFromReg t0, Register:i32 %1
Legalizing node: t9: i64 = build_pair t2, t4
Analyzing result type: i64
Expand integer result: t9: i64 = build_pair t2, t4
Legalizing node: t6: i32,ch = CopyFromReg t0, Register:i32 %2
Analyzing result type: i32
Legal result type
Analyzing result type: ch
Legal result type
Analyzing operand: t0: ch,glue = EntryToken
Legal operand
Legally typed node: t6: i32,ch = CopyFromReg t0, Register:i32 %2
Legalizing node: t8: i32,ch = CopyFromReg t0, Register:i32 %3
Analyzing result type: i32
Legal result type
Analyzing result type: ch
Legal result type
Analyzing operand: t0: ch,glue = EntryToken
Legal operand
Legally typed node: t8: i32,ch = CopyFromReg t0, Register:i32 %3
Legalizing node: t10: i64 = build_pair t6, t8
Analyzing result type: i64
Expand integer result: t10: i64 = build_pair t6, t8
Legalizing node: t22: i64 = mul t9, t10
Analyzing result type: i64
Expand integer result: t22: i64 = mul t9, t10
Creating constant: t26: i32 = Constant<1>
Creating constant: t27: i32 = Constant<0>
Creating constant: t28: i32 = TargetConstant<0>
Creating new node: t29: ch,glue = callseq_start t0, TargetConstant:i32<0>, TargetConstant:i32<0>
Creating new node: t31: ch,glue = CopyToReg t29, Register:i32 $x10, t2
Creating new node: t33: ch,glue = CopyToReg t31, Register:i32 $x11, t4, t31:1
Creating new node: t35: ch,glue = CopyToReg t33, Register:i32 $x12, t6, t33:1
Creating new node: t37: ch,glue = CopyToReg t35, Register:i32 $x13, t8, t35:1
Creating new node: t40: ch,glue = RISCVISD::CALL t37, TargetExternalSymbol:i32'__muldi3' [TF=1], Register:i32 $x10, Register:i32 $x11, Register:i32 $x12, Register:i32 $x13, RegisterMask:Untyped, t37:1
Creating new node: t41: ch,glue = callseq_end t40, TargetConstant:i32<0>, TargetConstant:i32<0>, t40:1
Creating new node: t42: i32,ch,glue = CopyFromReg t41, Register:i32 $x10, t41:1
Creating new node: t43: i32,ch,glue = CopyFromReg t42:1, Register:i32 $x11, t42:2
Creating new node: t44: i64 = build_pair t42, t43
Creating new node: t45: i32 = truncate t44
Creating constant: t46: i32 = Constant<32>
Creating new node: t47: i64 = srl t44, Constant:i32<32>
Creating new node: t48: i32 = truncate t47
```
https://github.com/llvm/llvm-project/pull/100749
More information about the llvm-commits
mailing list