Skip to content

Commit 77d11b2

Browse files
committed
[SelectionDAG] Fix comment
1 parent 16feacf commit 77d11b2

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17629,7 +17629,7 @@ static SDValue performMulCombine(SDNode *N, SelectionDAG &DAG,
1762917629
// (mul x, (2^M + 1) * 2^N + 1))
1763017630
// => MV = add (shl x, M), x); add (shl MV, N), x)
1763117631
// (mul x, 1 - (1 - 2^M) * 2^N))
17632-
// => MV = sub (x - (shl x, M)); add (x - (shl x, M))
17632+
// => MV = sub (x - (shl x, M)); sub (x - (shl MV, N))
1763317633
APInt SCVMinus1 = ShiftedConstValue - 1;
1763417634
APInt SCVPlus1 = ShiftedConstValue + 1;
1763517635
APInt CVPlus1 = ConstValue + 1;

llvm/test/CodeGen/AArch64/mul_pow2.ll

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,11 @@ define i32 @test125_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
646646
; GISEL-NEXT: mul w0, w0, w8
647647
; GISEL-NEXT: ret
648648

649-
%mul = mul nsw i32 %x, 125 ; 63 = 1 - ((1-32) << 2)
649+
%mul = mul nsw i32 %x, 125 ; 125 = 1 - ((1-32) << 2)
650650
ret i32 %mul
651651
}
652652

653-
; Negative test: The shift number 5 is out of bound
653+
; TODO: (1 - 2^M) * (1 - 2^N)
654654
define i32 @test225_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
655655
; CHECK-LABEL: test225_fast_shift:
656656
; CHECK: // %bb.0:
@@ -664,7 +664,7 @@ define i32 @test225_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
664664
; GISEL-NEXT: mul w0, w0, w8
665665
; GISEL-NEXT: ret
666666

667-
%mul = mul nsw i32 %x, 225 ; 225 = 1 - ((1-8) << 5)
667+
%mul = mul nsw i32 %x, 225 ; 225 = (1-16)*(1-16)
668668
ret i32 %mul
669669
}
670670

@@ -686,6 +686,24 @@ define i32 @test297_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
686686
ret i32 %mul
687687
}
688688

689+
; Negative test: The shift number 5 is out of bound
690+
define i32 @test481_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
691+
; CHECK-LABEL: test481_fast_shift:
692+
; CHECK: // %bb.0:
693+
; CHECK-NEXT: mov w8, #481 // =0x1e1
694+
; CHECK-NEXT: mul w0, w0, w8
695+
; CHECK-NEXT: ret
696+
;
697+
; GISEL-LABEL: test481_fast_shift:
698+
; GISEL: // %bb.0:
699+
; GISEL-NEXT: mov w8, #481 // =0x1e1
700+
; GISEL-NEXT: mul w0, w0, w8
701+
; GISEL-NEXT: ret
702+
703+
%mul = mul nsw i32 %x, 481 ; 481 = 1 - ((1-16) << 5)
704+
ret i32 %mul
705+
}
706+
689707
; Convert mul x, -pow2 to shift.
690708
; Convert mul x, -(pow2 +/- 1) to shift + add/sub.
691709
; Lowering other negative constants are not supported yet.
@@ -963,9 +981,9 @@ define <4 x i32> @muladd_demand_commute(<4 x i32> %x, <4 x i32> %y) {
963981
;
964982
; GISEL-LABEL: muladd_demand_commute:
965983
; GISEL: // %bb.0:
966-
; GISEL-NEXT: adrp x8, .LCPI55_0
984+
; GISEL-NEXT: adrp x8, .LCPI56_0
967985
; GISEL-NEXT: movi v3.4s, #1, msl #16
968-
; GISEL-NEXT: ldr q2, [x8, :lo12:.LCPI55_0]
986+
; GISEL-NEXT: ldr q2, [x8, :lo12:.LCPI56_0]
969987
; GISEL-NEXT: mla v1.4s, v0.4s, v2.4s
970988
; GISEL-NEXT: and v0.16b, v1.16b, v3.16b
971989
; GISEL-NEXT: ret

0 commit comments

Comments
 (0)