[llvm] [GlobaISel] Allow expanding of sdiv -> mul by constant (PR #146504)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 5 12:02:44 PDT 2025
================
@@ -229,12 +229,15 @@ define <4 x i32> @test_bit_sink_operand(<4 x i32> %src, <4 x i32> %dst, <4 x i32
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: sub sp, sp, #32
; CHECK-GI-NEXT: .cfi_def_cfa_offset 32
-; CHECK-GI-NEXT: asr w9, w0, #31
+; CHECK-GI-NEXT: // kill: def $w0 killed $w0 def $x0
+; CHECK-GI-NEXT: sxtw x9, w0
; CHECK-GI-NEXT: mov w8, wzr
; CHECK-GI-NEXT: add x10, sp, #16
; CHECK-GI-NEXT: mov x11, sp
-; CHECK-GI-NEXT: add w9, w0, w9, lsr #31
-; CHECK-GI-NEXT: asr w9, w9, #1
+; CHECK-GI-NEXT: sub x9, x9, x9, lsl #31
+; CHECK-GI-NEXT: asr x9, x9, #32
+; CHECK-GI-NEXT: add w9, w9, w0
+; CHECK-GI-NEXT: add w9, w9, w9, lsr #31
----------------
davemgreen wrote:
Do you know why sdiv by power-2 is no longer as efficient as it was? It can be performed more efficiently by a cmp+add+sel+asr.
https://github.com/llvm/llvm-project/pull/146504
More information about the llvm-commits
mailing list