@@ -1869,15 +1869,17 @@ define void @cmyk_commute11(i8 %r, i8 %g, i8 %b) {
1869
1869
1870
1870
define i8 @smax_offset (i8 %x ) {
1871
1871
; CHECK-LABEL: @smax_offset(
1872
- ; CHECK-NEXT: [[A :%.*]] = add nsw i8 [[X:%.*]], 3
1873
- ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[A ]], i8 -124)
1872
+ ; CHECK-NEXT: [[TMP1 :%.*]] = call i8 @llvm.smax.i8(i8 [[X:%.*]], i8 -127)
1873
+ ; CHECK-NEXT: [[M:%.*]] = add nsw i8 [[TMP1 ]], 3
1874
1874
; CHECK-NEXT: ret i8 [[M]]
1875
1875
;
1876
1876
%a = add nsw i8 %x , 3
1877
1877
%m = call i8 @llvm.smax.i8 (i8 %a , i8 -124 )
1878
1878
ret i8 %m
1879
1879
}
1880
1880
1881
+ ; This is handled by InstSimplify; testing here to confirm assert.
1882
+
1881
1883
define i8 @smax_offset_limit (i8 %x ) {
1882
1884
; CHECK-LABEL: @smax_offset_limit(
1883
1885
; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[X:%.*]], 3
@@ -1888,6 +1890,8 @@ define i8 @smax_offset_limit(i8 %x) {
1888
1890
ret i8 %m
1889
1891
}
1890
1892
1893
+ ; This is handled by InstSimplify; testing here to confirm assert.
1894
+
1891
1895
define i8 @smax_offset_overflow (i8 %x ) {
1892
1896
; CHECK-LABEL: @smax_offset_overflow(
1893
1897
; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[X:%.*]], 3
@@ -1898,6 +1902,8 @@ define i8 @smax_offset_overflow(i8 %x) {
1898
1902
ret i8 %m
1899
1903
}
1900
1904
1905
+ ; negative test - require nsw
1906
+
1901
1907
define i8 @smax_offset_may_wrap (i8 %x ) {
1902
1908
; CHECK-LABEL: @smax_offset_may_wrap(
1903
1909
; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], 3
@@ -1909,6 +1915,8 @@ define i8 @smax_offset_may_wrap(i8 %x) {
1909
1915
ret i8 %m
1910
1916
}
1911
1917
1918
+ ; negative test
1919
+
1912
1920
define i8 @smax_offset_uses (i8 %x ) {
1913
1921
; CHECK-LABEL: @smax_offset_uses(
1914
1922
; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[X:%.*]], 3
@@ -1924,15 +1932,17 @@ define i8 @smax_offset_uses(i8 %x) {
1924
1932
1925
1933
define <3 x i8 > @smin_offset (<3 x i8 > %x ) {
1926
1934
; CHECK-LABEL: @smin_offset(
1927
- ; CHECK-NEXT: [[A :%.*]] = add nuw nsw <3 x i8> [[X:%.*]], <i8 124 , i8 124 , i8 124>
1928
- ; CHECK-NEXT: [[M:%.*]] = call <3 x i8> @llvm.smin.v3i8(<3 x i8> [[A ]], <3 x i8> <i8 -3 , i8 -3 , i8 -3>)
1935
+ ; CHECK-NEXT: [[TMP1 :%.*]] = call <3 x i8> @llvm.smin.v3i8( <3 x i8> [[X:%.*]], <3 x i8> <i8 -127 , i8 -127 , i8 -127>)
1936
+ ; CHECK-NEXT: [[M:%.*]] = or <3 x i8> [[TMP1 ]], <i8 124 , i8 124 , i8 124>
1929
1937
; CHECK-NEXT: ret <3 x i8> [[M]]
1930
1938
;
1931
1939
%a = add nsw nuw <3 x i8 > %x , <i8 124 , i8 124 , i8 124 >
1932
1940
%m = call <3 x i8 > @llvm.smin.v3i8 (<3 x i8 > %a , <3 x i8 > <i8 -3 , i8 -3 , i8 -3 >)
1933
1941
ret <3 x i8 > %m
1934
1942
}
1935
1943
1944
+ ; This is handled by InstSimplify; testing here to confirm assert.
1945
+
1936
1946
define i8 @smin_offset_limit (i8 %x ) {
1937
1947
; CHECK-LABEL: @smin_offset_limit(
1938
1948
; CHECK-NEXT: ret i8 -3
@@ -1942,6 +1952,8 @@ define i8 @smin_offset_limit(i8 %x) {
1942
1952
ret i8 %m
1943
1953
}
1944
1954
1955
+ ; This is handled by InstSimplify; testing here to confirm assert.
1956
+
1945
1957
define i8 @smin_offset_overflow (i8 %x ) {
1946
1958
; CHECK-LABEL: @smin_offset_overflow(
1947
1959
; CHECK-NEXT: ret i8 -3
@@ -1951,6 +1963,8 @@ define i8 @smin_offset_overflow(i8 %x) {
1951
1963
ret i8 %m
1952
1964
}
1953
1965
1966
+ ; negative test - require nsw
1967
+
1954
1968
define i8 @smin_offset_may_wrap (i8 %x ) {
1955
1969
; CHECK-LABEL: @smin_offset_may_wrap(
1956
1970
; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[X:%.*]], 124
@@ -1962,6 +1976,8 @@ define i8 @smin_offset_may_wrap(i8 %x) {
1962
1976
ret i8 %m
1963
1977
}
1964
1978
1979
+ ; negative test
1980
+
1965
1981
define i8 @smin_offset_uses (i8 %x ) {
1966
1982
; CHECK-LABEL: @smin_offset_uses(
1967
1983
; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[X:%.*]], 124
@@ -1975,17 +1991,21 @@ define i8 @smin_offset_uses(i8 %x) {
1975
1991
ret i8 %m
1976
1992
}
1977
1993
1994
+ ; Note: 'nsw' must not propagate here.
1995
+
1978
1996
define <3 x i8 > @umax_offset (<3 x i8 > %x ) {
1979
1997
; CHECK-LABEL: @umax_offset(
1980
- ; CHECK-NEXT: [[A :%.*]] = add nuw nsw <3 x i8> [[X:%.*]], <i8 127 , i8 127 , i8 127>
1981
- ; CHECK-NEXT: [[M:%.*]] = call <3 x i8> @llvm.umax.v3i8( <3 x i8> [[A ]], <3 x i8> <i8 -126 , i8 -126 , i8 -126>)
1998
+ ; CHECK-NEXT: [[TMP1 :%.*]] = call <3 x i8> @llvm.umax.v3i8( <3 x i8> [[X:%.*]], <3 x i8> <i8 3 , i8 3 , i8 3>)
1999
+ ; CHECK-NEXT: [[M:%.*]] = add nuw <3 x i8> [[TMP1 ]], <i8 127 , i8 127 , i8 127>
1982
2000
; CHECK-NEXT: ret <3 x i8> [[M]]
1983
2001
;
1984
2002
%a = add nsw nuw <3 x i8 > %x , <i8 127 , i8 127 , i8 127 >
1985
2003
%m = call <3 x i8 > @llvm.umax.v3i8 (<3 x i8 > %a , <3 x i8 > <i8 130 , i8 130 , i8 130 >)
1986
2004
ret <3 x i8 > %m
1987
2005
}
1988
2006
2007
+ ; This is handled by InstSimplify; testing here to confirm assert.
2008
+
1989
2009
define i8 @umax_offset_limit (i8 %x ) {
1990
2010
; CHECK-LABEL: @umax_offset_limit(
1991
2011
; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[X:%.*]], 3
@@ -1996,6 +2016,8 @@ define i8 @umax_offset_limit(i8 %x) {
1996
2016
ret i8 %m
1997
2017
}
1998
2018
2019
+ ; This is handled by InstSimplify; testing here to confirm assert.
2020
+
1999
2021
define i8 @umax_offset_overflow (i8 %x ) {
2000
2022
; CHECK-LABEL: @umax_offset_overflow(
2001
2023
; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[X:%.*]], 3
@@ -2006,6 +2028,8 @@ define i8 @umax_offset_overflow(i8 %x) {
2006
2028
ret i8 %m
2007
2029
}
2008
2030
2031
+ ; negative test - require nuw
2032
+
2009
2033
define i8 @umax_offset_may_wrap (i8 %x ) {
2010
2034
; CHECK-LABEL: @umax_offset_may_wrap(
2011
2035
; CHECK-NEXT: [[A:%.*]] = add i8 [[X:%.*]], 3
@@ -2017,6 +2041,8 @@ define i8 @umax_offset_may_wrap(i8 %x) {
2017
2041
ret i8 %m
2018
2042
}
2019
2043
2044
+ ; negative test
2045
+
2020
2046
define i8 @umax_offset_uses (i8 %x ) {
2021
2047
; CHECK-LABEL: @umax_offset_uses(
2022
2048
; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[X:%.*]], 3
@@ -2032,15 +2058,17 @@ define i8 @umax_offset_uses(i8 %x) {
2032
2058
2033
2059
define i8 @umin_offset (i8 %x ) {
2034
2060
; CHECK-LABEL: @umin_offset(
2035
- ; CHECK-NEXT: [[A :%.*]] = add nuw i8 [[X:%.*]], -5
2036
- ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.umin.i8(i8 [[A ]], i8 -4)
2061
+ ; CHECK-NEXT: [[DOTNOT :%.*]] = icmp eq i8 [[X:%.*]], 0
2062
+ ; CHECK-NEXT: [[M:%.*]] = select i1 [[DOTNOT ]], i8 -5, i8 -4
2037
2063
; CHECK-NEXT: ret i8 [[M]]
2038
2064
;
2039
2065
%a = add nuw i8 %x , 251
2040
2066
%m = call i8 @llvm.umin.i8 (i8 %a , i8 252 )
2041
2067
ret i8 %m
2042
2068
}
2043
2069
2070
+ ; This is handled by InstSimplify; testing here to confirm assert.
2071
+
2044
2072
define i8 @umin_offset_limit (i8 %x ) {
2045
2073
; CHECK-LABEL: @umin_offset_limit(
2046
2074
; CHECK-NEXT: ret i8 -4
@@ -2050,6 +2078,8 @@ define i8 @umin_offset_limit(i8 %x) {
2050
2078
ret i8 %m
2051
2079
}
2052
2080
2081
+ ; This is handled by InstSimplify; testing here to confirm assert.
2082
+
2053
2083
define i8 @umin_offset_overflow (i8 %x ) {
2054
2084
; CHECK-LABEL: @umin_offset_overflow(
2055
2085
; CHECK-NEXT: ret i8 -4
@@ -2059,6 +2089,8 @@ define i8 @umin_offset_overflow(i8 %x) {
2059
2089
ret i8 %m
2060
2090
}
2061
2091
2092
+ ; negative test - require nuw
2093
+
2062
2094
define i8 @umin_offset_may_wrap (i8 %x ) {
2063
2095
; CHECK-LABEL: @umin_offset_may_wrap(
2064
2096
; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[X:%.*]], -5
@@ -2070,6 +2102,8 @@ define i8 @umin_offset_may_wrap(i8 %x) {
2070
2102
ret i8 %m
2071
2103
}
2072
2104
2105
+ ; negative test
2106
+
2073
2107
define i8 @umin_offset_uses (i8 %x ) {
2074
2108
; CHECK-LABEL: @umin_offset_uses(
2075
2109
; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[X:%.*]], -5
@@ -2083,6 +2117,8 @@ define i8 @umin_offset_uses(i8 %x) {
2083
2117
ret i8 %m
2084
2118
}
2085
2119
2120
+ ; TODO: This could transform, but undef element must not propagate to the new add.
2121
+
2086
2122
define <3 x i8 > @umax_vector_splat_undef (<3 x i8 > %x ) {
2087
2123
; CHECK-LABEL: @umax_vector_splat_undef(
2088
2124
; CHECK-NEXT: [[A:%.*]] = add nuw <3 x i8> [[X:%.*]], <i8 undef, i8 64, i8 64>
0 commit comments