[llvm] [AArch64][SelectionDAG] Lower multiplication by a constant to shl+sub+shl+sub (PR #90199)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 12:58:58 PDT 2024
================
@@ -615,6 +632,42 @@ define i32 @test97_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
ret i32 %mul
}
+; Negative test: The shift number 5 is out of bound
+define i32 @test125_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
+; CHECK-LABEL: test125_fast_shift:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov w8, #125 // =0x7d
+; CHECK-NEXT: mul w0, w0, w8
+; CHECK-NEXT: ret
+;
+; GISEL-LABEL: test125_fast_shift:
+; GISEL: // %bb.0:
+; GISEL-NEXT: mov w8, #125 // =0x7d
+; GISEL-NEXT: mul w0, w0, w8
+; GISEL-NEXT: ret
+
+ %mul = mul nsw i32 %x, 125 ; 63 = 1 - ((1-32) << 2)
+ ret i32 %mul
+}
+
+; Negative test: The shift number 5 is out of bound
+define i32 @test225_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
+; CHECK-LABEL: test225_fast_shift:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov w8, #225 // =0xe1
----------------
efriedma-quic wrote:
You can write `x*225` as `x*-15*-15`.
https://github.com/llvm/llvm-project/pull/90199
More information about the llvm-commits
mailing list