[llvm] [AArch64] Improve operand sinking for mul instructions (PR #116604)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 03:58:21 PST 2024


================
@@ -10,14 +10,18 @@ target triple = "aarch64-unknown-linux-gnu"
 define dso_local i32 @dupext_crashtest(i32 %e) local_unnamed_addr {
 ; CHECK-LABEL: dupext_crashtest:
 ; CHECK:       // %bb.0: // %for.body.lr.ph
-; CHECK-NEXT:    mov w8, w0
-; CHECK-NEXT:    dup v0.2s, w8
 ; CHECK-NEXT:  .LBB0_1: // %vector.body
 ; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
-; CHECK-NEXT:    ldr d1, [x8]
-; CHECK-NEXT:    smull v1.2d, v0.2s, v1.2s
-; CHECK-NEXT:    xtn v1.2s, v1.2d
-; CHECK-NEXT:    str d1, [x8]
+; CHECK-NEXT:    ldr d0, [x8]
+; CHECK-NEXT:    ushll v0.2d, v0.2s, #0
+; CHECK-NEXT:    fmov x9, d0
+; CHECK-NEXT:    mov x8, v0.d[1]
+; CHECK-NEXT:    mul w9, w0, w9
+; CHECK-NEXT:    mul w8, w0, w8
+; CHECK-NEXT:    fmov d0, x9
+; CHECK-NEXT:    mov v0.d[1], x8
+; CHECK-NEXT:    xtn v0.2s, v0.2d
+; CHECK-NEXT:    str d0, [x8]
----------------
hazzlim wrote:

This is a regression, but I have a patch that fixes it by teaching

https://github.com/llvm/llvm-project/blob/c25c6c32494c8d1038438b6208d42ba40f25270e/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp#L18599

to handle `ANY_EXTEND`s, which seem to get generated via KnownBits queries when we visit the truncate nodes.

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


More information about the llvm-commits mailing list