@@ -882,9 +882,7 @@ define i8 @sub_add_umin_use_m(i8 %x, i8 %y, i8 %z) {
882
882
define <2 x i8 > @sub_smax0_sub_nsw (<2 x i8 > %x , <2 x i8 > %y ) {
883
883
; CHECK-LABEL: define {{[^@]+}}@sub_smax0_sub_nsw
884
884
; CHECK-SAME: (<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
885
- ; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i8> [[X]], [[Y]]
886
- ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> [[SUB]], <2 x i8> <i8 0, i8 poison>)
887
- ; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[X]], [[M]]
885
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[X]], <2 x i8> [[Y]])
888
886
; CHECK-NEXT: ret <2 x i8> [[R]]
889
887
;
890
888
%sub = sub nsw <2 x i8 > %x , %y
@@ -899,7 +897,7 @@ define i8 @sub_smax0_sub_nsw_use(i8 %x, i8 %y) {
899
897
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i8 [[X]], [[Y]]
900
898
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[SUB]], i8 0)
901
899
; CHECK-NEXT: call void @use8(i8 [[M]])
902
- ; CHECK-NEXT: [[R:%.*]] = sub i8 [[X]], [[M]]
900
+ ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smin.i8(i8 [[X]], i8 [[Y]])
903
901
; CHECK-NEXT: ret i8 [[R]]
904
902
;
905
903
%sub = sub nsw i8 %x , %y
@@ -909,6 +907,8 @@ define i8 @sub_smax0_sub_nsw_use(i8 %x, i8 %y) {
909
907
ret i8 %r
910
908
}
911
909
910
+ ; negative test - must have nsw
911
+
912
912
define i8 @sub_smax0_sub (i8 %x , i8 %y ) {
913
913
; CHECK-LABEL: define {{[^@]+}}@sub_smax0_sub
914
914
; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) {
@@ -923,15 +923,17 @@ define i8 @sub_smax0_sub(i8 %x, i8 %y) {
923
923
ret i8 %r
924
924
}
925
925
926
+ ; negative test - wrong op
927
+
926
928
define i8 @sub_smax0_sub_commute (i8 %x , i8 %y ) {
927
929
; CHECK-LABEL: define {{[^@]+}}@sub_smax0_sub_commute
928
930
; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) {
929
- ; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[X]], [[Y]]
931
+ ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i8 [[X]], [[Y]]
930
932
; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smax.i8(i8 [[SUB]], i8 0)
931
933
; CHECK-NEXT: [[R:%.*]] = sub i8 [[M]], [[X]]
932
934
; CHECK-NEXT: ret i8 [[R]]
933
935
;
934
- %sub = sub i8 %x , %y
936
+ %sub = sub nsw i8 %x , %y
935
937
%m = call i8 @llvm.smax.i8 (i8 %sub , i8 0 )
936
938
%r = sub i8 %m , %x
937
939
ret i8 %r
@@ -942,8 +944,7 @@ define i8 @sub_smin0_sub_nsw_use(i8 %x, i8 %y) {
942
944
; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) {
943
945
; CHECK-NEXT: [[SUB:%.*]] = sub nsw i8 [[X]], [[Y]]
944
946
; CHECK-NEXT: call void @use8(i8 [[SUB]])
945
- ; CHECK-NEXT: [[M:%.*]] = call i8 @llvm.smin.i8(i8 [[SUB]], i8 0)
946
- ; CHECK-NEXT: [[R:%.*]] = sub i8 [[X]], [[M]]
947
+ ; CHECK-NEXT: [[R:%.*]] = call i8 @llvm.smax.i8(i8 [[X]], i8 [[Y]])
947
948
; CHECK-NEXT: ret i8 [[R]]
948
949
;
949
950
%sub = sub nsw i8 %x , %y
@@ -956,9 +957,7 @@ define i8 @sub_smin0_sub_nsw_use(i8 %x, i8 %y) {
956
957
define <2 x i8 > @sub_smin0_sub_nsw (<2 x i8 > %x , <2 x i8 > %y ) {
957
958
; CHECK-LABEL: define {{[^@]+}}@sub_smin0_sub_nsw
958
959
; CHECK-SAME: (<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
959
- ; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i8> [[X]], [[Y]]
960
- ; CHECK-NEXT: [[M:%.*]] = call <2 x i8> @llvm.smin.v2i8(<2 x i8> [[SUB]], <2 x i8> zeroinitializer)
961
- ; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[X]], [[M]]
960
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i8> @llvm.smax.v2i8(<2 x i8> [[X]], <2 x i8> [[Y]])
962
961
; CHECK-NEXT: ret <2 x i8> [[R]]
963
962
;
964
963
%sub = sub nsw <2 x i8 > %x , %y
@@ -967,6 +966,8 @@ define <2 x i8> @sub_smin0_sub_nsw(<2 x i8> %x, <2 x i8> %y) {
967
966
ret <2 x i8 > %r
968
967
}
969
968
969
+ ; negative test - must have nsw
970
+
970
971
define i8 @sub_smin0_sub (i8 %x , i8 %y ) {
971
972
; CHECK-LABEL: define {{[^@]+}}@sub_smin0_sub
972
973
; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) {
@@ -981,6 +982,8 @@ define i8 @sub_smin0_sub(i8 %x, i8 %y) {
981
982
ret i8 %r
982
983
}
983
984
985
+ ; negative test - wrong op
986
+
984
987
define i8 @sub_smin0_sub_nsw_commute (i8 %x , i8 %y ) {
985
988
; CHECK-LABEL: define {{[^@]+}}@sub_smin0_sub_nsw_commute
986
989
; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) {
0 commit comments