@@ -694,7 +694,7 @@ if.end: ; preds = %if.then, %lor.lhs.f
694
694
ret i32 undef
695
695
}
696
696
697
- ; ((X << C) - Y) + Z --> (Z - Y) + (X << C)
697
+ ; ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
698
698
define i32 @commute_subop0 (i32 %x , i32 %y , i32 %z ) {
699
699
; CHECK-LABEL: commute_subop0:
700
700
; CHECK: // %bb.0:
@@ -707,7 +707,7 @@ define i32 @commute_subop0(i32 %x, i32 %y, i32 %z) {
707
707
ret i32 %add
708
708
}
709
709
710
- ; ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
710
+ ; ((X << C) - Y) + Z --> (Z - Y) + (X << C)
711
711
define i32 @commute_subop0_lshr (i32 %x , i32 %y , i32 %z ) {
712
712
; CHECK-LABEL: commute_subop0_lshr:
713
713
; CHECK: // %bb.0:
@@ -721,7 +721,7 @@ define i32 @commute_subop0_lshr(i32 %x, i32 %y, i32 %z) {
721
721
ret i32 %add
722
722
}
723
723
724
- ; ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
724
+ ; ((X << C) - Y) + Z --> (Z - Y) + (X << C)
725
725
define i32 @commute_subop0_ashr (i32 %x , i32 %y , i32 %z ) {
726
726
; CHECK-LABEL: commute_subop0_ashr:
727
727
; CHECK: // %bb.0:
@@ -735,89 +735,7 @@ define i32 @commute_subop0_ashr(i32 %x, i32 %y, i32 %z) {
735
735
ret i32 %add
736
736
}
737
737
738
- ; ((sext X) - Y) + Z --> (Z - Y) + (sext X)
739
- define i64 @commute_subop0_sext (i32 %x , i64 %y , i64 %z ) {
740
- ; CHECK-LABEL: commute_subop0_sext:
741
- ; CHECK: // %bb.0:
742
- ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
743
- ; CHECK-NEXT: sxtw x8, w0
744
- ; CHECK-NEXT: sub x8, x8, x1
745
- ; CHECK-NEXT: add x0, x8, x2
746
- ; CHECK-NEXT: ret
747
- %sext = sext i32 %x to i64
748
- %sub = sub i64 %sext , %y
749
- %add = add i64 %sub , %z
750
- ret i64 %add
751
- }
752
-
753
- ; ((sext_inreg X) - Y) + Z --> (Z - Y) + (sext_inreg X)
754
- define i64 @commute_subop0_sext_inreg (i64 %x , i64 %y , i64 %z ) {
755
- ; CHECK-LABEL: commute_subop0_sext_inreg:
756
- ; CHECK: // %bb.0:
757
- ; CHECK-NEXT: sxth x8, w0
758
- ; CHECK-NEXT: sub x8, x8, x1
759
- ; CHECK-NEXT: add x0, x8, x2
760
- ; CHECK-NEXT: ret
761
- %shl = shl i64 %x , 48
762
- %ashr = ashr i64 %shl , 48
763
- %sub = sub i64 %ashr , %y
764
- %add = add i64 %sub , %z
765
- ret i64 %add
766
- }
767
-
768
- ; ((zext X) - Y) + Z --> (Z - Y) + (zext X)
769
- define i32 @commute_subop0_zext (i16 %x , i32 %y , i32 %z ) {
770
- ; CHECK-LABEL: commute_subop0_zext:
771
- ; CHECK: // %bb.0:
772
- ; CHECK-NEXT: and w8, w0, #0xffff
773
- ; CHECK-NEXT: sub w8, w8, w1
774
- ; CHECK-NEXT: add w0, w8, w2
775
- ; CHECK-NEXT: ret
776
- %zext = zext i16 %x to i32
777
- %sub = sub i32 %zext , %y
778
- %add = add i32 %sub , %z
779
- ret i32 %add
780
- }
781
-
782
-
783
- ; ((anyext X) - Y) + Z --> (Z - Y) + (anyext X)
784
- define i8 @commute_subop0_anyext (i16 %a , i16 %b , i32 %c ) {
785
- ; CHECK-LABEL: commute_subop0_anyext:
786
- ; CHECK: // %bb.0:
787
- ; CHECK-NEXT: mov w8, #222
788
- ; CHECK-NEXT: mov w9, #111
789
- ; CHECK-NEXT: mul w8, w1, w8
790
- ; CHECK-NEXT: neg w8, w8
791
- ; CHECK-NEXT: madd w8, w0, w9, w8
792
- ; CHECK-NEXT: add w8, w8, w2
793
- ; CHECK-NEXT: add w0, w8, w8, lsl #5
794
- ; CHECK-NEXT: ret
795
- %aa = mul i16 %a , 111
796
- %bb = mul i16 %b , 222
797
- %a_32 = zext i16 %aa to i32
798
- %b_32 = zext i16 %bb to i32
799
- %sub = sub i32 %a_32 , %b_32
800
- %add = add i32 %sub , %c
801
- %trunc = trunc i32 %add to i8
802
- %r = mul i8 %trunc , 33
803
- ret i8 %r
804
- }
805
-
806
- ; ((X and C) - Y) + Z --> (Z - Y) + (X and C)
807
- define i32 @commute_subop0_and (i32 %x , i32 %y , i32 %z ) {
808
- ; CHECK-LABEL: commute_subop0_and:
809
- ; CHECK: // %bb.0:
810
- ; CHECK-NEXT: and w8, w0, #0xff
811
- ; CHECK-NEXT: sub w8, w8, w1
812
- ; CHECK-NEXT: add w0, w8, w2
813
- ; CHECK-NEXT: ret
814
- %and = and i32 %x , 255
815
- %sub = sub i32 %and , %y
816
- %add = add i32 %sub , %z
817
- ret i32 %add
818
- }
819
-
820
- ; Z + ((X << C) - Y) --> (Z - Y) + (X << C)
738
+ ; Z + ((X >> C) - Y) --> (Z - Y) + (X >> C)
821
739
define i32 @commute_subop0_cadd (i32 %x , i32 %y , i32 %z ) {
822
740
; CHECK-LABEL: commute_subop0_cadd:
823
741
; CHECK: // %bb.0:
@@ -830,7 +748,7 @@ define i32 @commute_subop0_cadd(i32 %x, i32 %y, i32 %z) {
830
748
ret i32 %add
831
749
}
832
750
833
- ; Y + ((X << C) - X) --> (Y - X) + (X << C)
751
+ ; Y + ((X >> C) - X) --> (Y - X) + (X >> C)
834
752
define i32 @commute_subop0_mul (i32 %x , i32 %y ) {
835
753
; CHECK-LABEL: commute_subop0_mul:
836
754
; CHECK: // %bb.0:
@@ -842,7 +760,7 @@ define i32 @commute_subop0_mul(i32 %x, i32 %y) {
842
760
ret i32 %add
843
761
}
844
762
845
- ; negative case for ((X << C) - Y) + Z --> (Z - Y) + (X << C)
763
+ ; negative case for ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
846
764
; Y can't be constant to avoid dead loop
847
765
define i32 @commute_subop0_zconst (i32 %x , i32 %y ) {
848
766
; CHECK-LABEL: commute_subop0_zconst:
@@ -857,7 +775,7 @@ define i32 @commute_subop0_zconst(i32 %x, i32 %y) {
857
775
ret i32 %add
858
776
}
859
777
860
- ; negative case for ((X << C) - Y) + Z --> (Z - Y) + (X << C)
778
+ ; negative case for ((X >> C) - Y) + Z --> (Z - Y) + (X >> C)
861
779
; Y can't be shift C also to avoid dead loop
862
780
define i32 @commute_subop0_zshiftc_oneuse (i32 %x , i32 %y , i32 %z ) {
863
781
; CHECK-LABEL: commute_subop0_zshiftc_oneuse:
0 commit comments