@@ -527,6 +527,23 @@ define i32 @test25_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
527
527
ret i32 %mul
528
528
}
529
529
530
+ define i32 @test29_fast_shift (i32 %x ) "target-features" ="+alu-lsl-fast" {
531
+ ; CHECK-LABEL: test29_fast_shift:
532
+ ; CHECK: // %bb.0:
533
+ ; CHECK-NEXT: sub w8, w0, w0, lsl #3
534
+ ; CHECK-NEXT: sub w0, w0, w8, lsl #2
535
+ ; CHECK-NEXT: ret
536
+ ;
537
+ ; GISEL-LABEL: test29_fast_shift:
538
+ ; GISEL: // %bb.0:
539
+ ; GISEL-NEXT: mov w8, #29 // =0x1d
540
+ ; GISEL-NEXT: mul w0, w0, w8
541
+ ; GISEL-NEXT: ret
542
+
543
+ %mul = mul nsw i32 %x , 29 ; 29 = 1 - (1-8) * 4
544
+ ret i32 %mul
545
+ }
546
+
530
547
define i32 @test45_fast_shift (i32 %x ) "target-features" ="+alu-lsl-fast" {
531
548
; CHECK-LABEL: test45_fast_shift:
532
549
; CHECK: // %bb.0:
@@ -615,6 +632,42 @@ define i32 @test97_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
615
632
ret i32 %mul
616
633
}
617
634
635
+ ; Negative test: The shift number 5 is out of bound
636
+ define i32 @test125_fast_shift (i32 %x ) "target-features" ="+alu-lsl-fast" {
637
+ ; CHECK-LABEL: test125_fast_shift:
638
+ ; CHECK: // %bb.0:
639
+ ; CHECK-NEXT: mov w8, #125 // =0x7d
640
+ ; CHECK-NEXT: mul w0, w0, w8
641
+ ; CHECK-NEXT: ret
642
+ ;
643
+ ; GISEL-LABEL: test125_fast_shift:
644
+ ; GISEL: // %bb.0:
645
+ ; GISEL-NEXT: mov w8, #125 // =0x7d
646
+ ; GISEL-NEXT: mul w0, w0, w8
647
+ ; GISEL-NEXT: ret
648
+
649
+ %mul = mul nsw i32 %x , 125 ; 125 = 1 - ((1-32) << 2)
650
+ ret i32 %mul
651
+ }
652
+
653
+ ; TODO: (1 - 2^M) * (1 - 2^N)
654
+ define i32 @test225_fast_shift (i32 %x ) "target-features" ="+alu-lsl-fast" {
655
+ ; CHECK-LABEL: test225_fast_shift:
656
+ ; CHECK: // %bb.0:
657
+ ; CHECK-NEXT: mov w8, #225 // =0xe1
658
+ ; CHECK-NEXT: mul w0, w0, w8
659
+ ; CHECK-NEXT: ret
660
+ ;
661
+ ; GISEL-LABEL: test225_fast_shift:
662
+ ; GISEL: // %bb.0:
663
+ ; GISEL-NEXT: mov w8, #225 // =0xe1
664
+ ; GISEL-NEXT: mul w0, w0, w8
665
+ ; GISEL-NEXT: ret
666
+
667
+ %mul = mul nsw i32 %x , 225 ; 225 = (1-16)*(1-16)
668
+ ret i32 %mul
669
+ }
670
+
618
671
; Negative test: The shift amount 5 larger than 4
619
672
define i32 @test297_fast_shift (i32 %x ) "target-features" ="+alu-lsl-fast" {
620
673
; CHECK-LABEL: test297_fast_shift:
@@ -633,6 +686,24 @@ define i32 @test297_fast_shift(i32 %x) "target-features"="+alu-lsl-fast" {
633
686
ret i32 %mul
634
687
}
635
688
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
+
636
707
; Convert mul x, -pow2 to shift.
637
708
; Convert mul x, -(pow2 +/- 1) to shift + add/sub.
638
709
; Lowering other negative constants are not supported yet.
@@ -910,9 +981,9 @@ define <4 x i32> @muladd_demand_commute(<4 x i32> %x, <4 x i32> %y) {
910
981
;
911
982
; GISEL-LABEL: muladd_demand_commute:
912
983
; GISEL: // %bb.0:
913
- ; GISEL-NEXT: adrp x8, .LCPI52_0
984
+ ; GISEL-NEXT: adrp x8, .LCPI56_0
914
985
; GISEL-NEXT: movi v3.4s, #1, msl #16
915
- ; GISEL-NEXT: ldr q2, [x8, :lo12:.LCPI52_0 ]
986
+ ; GISEL-NEXT: ldr q2, [x8, :lo12:.LCPI56_0 ]
916
987
; GISEL-NEXT: mla v1.4s, v0.4s, v2.4s
917
988
; GISEL-NEXT: and v0.16b, v1.16b, v3.16b
918
989
; GISEL-NEXT: ret
0 commit comments