@@ -743,7 +743,7 @@ define i32 @test40d(i32 %a, i32 %b) {
743
743
744
744
define i32 @test45 (i32 %x , i32 %y , i32 %z ) {
745
745
; CHECK-LABEL: @test45(
746
- ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X :%.*]], [[Z :%.*]]
746
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[Z :%.*]], [[X :%.*]]
747
747
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP1]], [[Y:%.*]]
748
748
; CHECK-NEXT: ret i32 [[OR1]]
749
749
;
@@ -753,10 +753,40 @@ define i32 @test45(i32 %x, i32 %y, i32 %z) {
753
753
ret i32 %or1
754
754
}
755
755
756
+ define i32 @test45_uses1 (i32 %x , i32 %y , i32 %z ) {
757
+ ; CHECK-LABEL: @test45_uses1(
758
+ ; CHECK-NEXT: [[OR:%.*]] = or i32 [[Y:%.*]], [[Z:%.*]]
759
+ ; CHECK-NEXT: call void @use(i32 [[OR]])
760
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[Z]], [[X:%.*]]
761
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP1]], [[Y]]
762
+ ; CHECK-NEXT: ret i32 [[OR1]]
763
+ ;
764
+ %or = or i32 %y , %z
765
+ call void @use (i32 %or )
766
+ %and = and i32 %x , %or
767
+ %or1 = or i32 %and , %y
768
+ ret i32 %or1
769
+ }
770
+
771
+ define i32 @test45_uses2 (i32 %x , i32 %y , i32 %z ) {
772
+ ; CHECK-LABEL: @test45_uses2(
773
+ ; CHECK-NEXT: [[OR:%.*]] = or i32 [[Y:%.*]], [[Z:%.*]]
774
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[OR]], [[X:%.*]]
775
+ ; CHECK-NEXT: call void @use(i32 [[AND]])
776
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[AND]], [[Y]]
777
+ ; CHECK-NEXT: ret i32 [[OR1]]
778
+ ;
779
+ %or = or i32 %y , %z
780
+ %and = and i32 %x , %or
781
+ call void @use (i32 %and )
782
+ %or1 = or i32 %and , %y
783
+ ret i32 %or1
784
+ }
785
+
756
786
define i32 @test45_commuted1 (i32 %x , i32 %y , i32 %z ) {
757
787
; CHECK-LABEL: @test45_commuted1(
758
788
; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
759
- ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[X :%.*]], [[Z :%.*]]
789
+ ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[Z :%.*]], [[X :%.*]]
760
790
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[YY]], [[TMP1]]
761
791
; CHECK-NEXT: ret i32 [[OR1]]
762
792
;
@@ -772,7 +802,7 @@ define i32 @test45_commuted2(i32 %x, i32 %y, i32 %z) {
772
802
; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
773
803
; CHECK-NEXT: [[XX:%.*]] = mul i32 [[X:%.*]], [[X]]
774
804
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[XX]], [[Z:%.*]]
775
- ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[YY ]], [[TMP1 ]]
805
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP1 ]], [[YY ]]
776
806
; CHECK-NEXT: ret i32 [[OR1]]
777
807
;
778
808
%yy = mul i32 %y , %y ; thwart complexity-based ordering
@@ -788,7 +818,7 @@ define i32 @test45_commuted3(i32 %x, i32 %y, i32 %z) {
788
818
; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
789
819
; CHECK-NEXT: [[ZZ:%.*]] = mul i32 [[Z:%.*]], [[Z]]
790
820
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[ZZ]], [[X:%.*]]
791
- ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[YY ]], [[TMP1 ]]
821
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP1 ]], [[YY ]]
792
822
; CHECK-NEXT: ret i32 [[OR1]]
793
823
;
794
824
%yy = mul i32 %y , %y ; thwart complexity-based ordering
@@ -1918,3 +1948,85 @@ define i32 @test_or_and_and_multiuse(i32 %a, i32 %b, i32 %c) {
1918
1948
%or = or i32 %and2 , %a
1919
1949
ret i32 %or
1920
1950
}
1951
+
1952
+ define i32 @or_xor_and (i32 %x , i32 %y , i32 %z ) {
1953
+ ; CHECK-LABEL: @or_xor_and(
1954
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[X:%.*]], [[Y:%.*]]
1955
+ ; CHECK-NEXT: ret i32 [[OR1]]
1956
+ ;
1957
+ %and = and i32 %y , %z
1958
+ %xor = xor i32 %x , %and
1959
+ %or1 = or i32 %xor , %y
1960
+ ret i32 %or1
1961
+ }
1962
+
1963
+ define i32 @or_xor_and_uses1 (i32 %x , i32 %y , i32 %z ) {
1964
+ ; CHECK-LABEL: @or_xor_and_uses1(
1965
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[Y:%.*]], [[Z:%.*]]
1966
+ ; CHECK-NEXT: call void @use(i32 [[AND]])
1967
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[X:%.*]], [[Y]]
1968
+ ; CHECK-NEXT: ret i32 [[OR1]]
1969
+ ;
1970
+ %and = and i32 %y , %z
1971
+ call void @use (i32 %and )
1972
+ %xor = xor i32 %x , %and
1973
+ %or1 = or i32 %xor , %y
1974
+ ret i32 %or1
1975
+ }
1976
+
1977
+ define i32 @or_xor_and_uses2 (i32 %x , i32 %y , i32 %z ) {
1978
+ ; CHECK-LABEL: @or_xor_and_uses2(
1979
+ ; CHECK-NEXT: [[AND:%.*]] = and i32 [[Y:%.*]], [[Z:%.*]]
1980
+ ; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[AND]], [[X:%.*]]
1981
+ ; CHECK-NEXT: call void @use(i32 [[XOR]])
1982
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[X]], [[Y]]
1983
+ ; CHECK-NEXT: ret i32 [[OR1]]
1984
+ ;
1985
+ %and = and i32 %y , %z
1986
+ %xor = xor i32 %x , %and
1987
+ call void @use (i32 %xor )
1988
+ %or1 = or i32 %xor , %y
1989
+ ret i32 %or1
1990
+ }
1991
+
1992
+ define i32 @or_xor_and_commuted1 (i32 %x , i32 %y , i32 %z ) {
1993
+ ; CHECK-LABEL: @or_xor_and_commuted1(
1994
+ ; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
1995
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[YY]], [[X:%.*]]
1996
+ ; CHECK-NEXT: ret i32 [[OR1]]
1997
+ ;
1998
+ %yy = mul i32 %y , %y ; thwart complexity-based ordering
1999
+ %and = and i32 %yy , %z
2000
+ %xor = xor i32 %and , %x
2001
+ %or1 = or i32 %yy , %xor
2002
+ ret i32 %or1
2003
+ }
2004
+
2005
+ define i32 @or_xor_and_commuted2 (i32 %x , i32 %y , i32 %z ) {
2006
+ ; CHECK-LABEL: @or_xor_and_commuted2(
2007
+ ; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
2008
+ ; CHECK-NEXT: [[XX:%.*]] = mul i32 [[X:%.*]], [[X]]
2009
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[XX]], [[YY]]
2010
+ ; CHECK-NEXT: ret i32 [[OR1]]
2011
+ ;
2012
+ %yy = mul i32 %y , %y ; thwart complexity-based ordering
2013
+ %xx = mul i32 %x , %x ; thwart complexity-based ordering
2014
+ %and = and i32 %yy , %z
2015
+ %xor = xor i32 %xx , %and
2016
+ %or1 = or i32 %xor , %yy
2017
+ ret i32 %or1
2018
+ }
2019
+
2020
+ define i32 @or_xor_and_commuted3 (i32 %x , i32 %y , i32 %z ) {
2021
+ ; CHECK-LABEL: @or_xor_and_commuted3(
2022
+ ; CHECK-NEXT: [[YY:%.*]] = mul i32 [[Y:%.*]], [[Y]]
2023
+ ; CHECK-NEXT: [[OR1:%.*]] = or i32 [[YY]], [[X:%.*]]
2024
+ ; CHECK-NEXT: ret i32 [[OR1]]
2025
+ ;
2026
+ %yy = mul i32 %y , %y ; thwart complexity-based ordering
2027
+ %zz = mul i32 %z , %z ; thwart complexity-based ordering
2028
+ %and = and i32 %zz , %yy
2029
+ %xor = xor i32 %and , %x
2030
+ %or1 = or i32 %xor , %yy
2031
+ ret i32 %or1
2032
+ }
0 commit comments