@@ -810,11 +810,11 @@ define i1 @eq_shl_by_variable_produces_poison(i8 %x) {
810
810
ret i1 %cmp
811
811
}
812
812
813
+ ; No overflow, so mul constant must be a factor of cmp constant.
814
+
813
815
define i1 @mul_nuw_urem_cmp_constant1 (i8 %x ) {
814
816
; CHECK-LABEL: @mul_nuw_urem_cmp_constant1(
815
- ; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], 43
816
- ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[M]], 42
817
- ; CHECK-NEXT: ret i1 [[R]]
817
+ ; CHECK-NEXT: ret i1 false
818
818
;
819
819
%m = mul nuw i8 %x , 43
820
820
%r = icmp eq i8 %m , 42
@@ -825,31 +825,29 @@ define i1 @mul_nuw_urem_cmp_constant1(i8 %x) {
825
825
826
826
define <2 x i1 > @mul_nuw_urem_cmp_constant_vec_splat (<2 x i8 > %x ) {
827
827
; CHECK-LABEL: @mul_nuw_urem_cmp_constant_vec_splat(
828
- ; CHECK-NEXT: [[M:%.*]] = mul nuw <2 x i8> [[X:%.*]], <i8 45, i8 45>
829
- ; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i8> [[M]], <i8 15, i8 15>
830
- ; CHECK-NEXT: ret <2 x i1> [[R]]
828
+ ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
831
829
;
832
830
%m = mul nuw <2 x i8 > %x , <i8 45 , i8 45 >
833
831
%r = icmp ne <2 x i8 > %m , <i8 15 , i8 15 >
834
832
ret <2 x i1 > %r
835
833
}
836
834
835
+ ; Undefs in vector constants are ok.
836
+
837
837
define <2 x i1 > @mul_nuw_urem_cmp_constant_vec_splat_undef1 (<2 x i8 > %x ) {
838
838
; CHECK-LABEL: @mul_nuw_urem_cmp_constant_vec_splat_undef1(
839
- ; CHECK-NEXT: [[M:%.*]] = mul nuw <2 x i8> [[X:%.*]], <i8 45, i8 45>
840
- ; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i8> [[M]], <i8 15, i8 undef>
841
- ; CHECK-NEXT: ret <2 x i1> [[R]]
839
+ ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
842
840
;
843
841
%m = mul nuw <2 x i8 > %x , <i8 45 , i8 45 >
844
842
%r = icmp ne <2 x i8 > %m , <i8 15 , i8 undef >
845
843
ret <2 x i1 > %r
846
844
}
847
845
846
+ ; Undefs in vector constants are ok.
847
+
848
848
define <2 x i1 > @mul_nuw_urem_cmp_constant_vec_splat_undef2 (<2 x i8 > %x ) {
849
849
; CHECK-LABEL: @mul_nuw_urem_cmp_constant_vec_splat_undef2(
850
- ; CHECK-NEXT: [[M:%.*]] = mul nuw <2 x i8> [[X:%.*]], <i8 undef, i8 45>
851
- ; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i8> [[M]], <i8 15, i8 15>
852
- ; CHECK-NEXT: ret <2 x i1> [[R]]
850
+ ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true>
853
851
;
854
852
%m = mul nuw <2 x i8 > %x , <i8 undef , i8 45 >
855
853
%r = icmp ne <2 x i8 > %m , <i8 15 , i8 15 >
@@ -860,15 +858,15 @@ define <2 x i1> @mul_nuw_urem_cmp_constant_vec_splat_undef2(<2 x i8> %x) {
860
858
861
859
define i1 @mul_nuw_urem_cmp_constant2 (i8 %x ) {
862
860
; CHECK-LABEL: @mul_nuw_urem_cmp_constant2(
863
- ; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], -42
864
- ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[M]], -84
865
- ; CHECK-NEXT: ret i1 [[R]]
861
+ ; CHECK-NEXT: ret i1 false
866
862
;
867
863
%m = mul nuw i8 %x , -42
868
864
%r = icmp eq i8 %m , -84
869
865
ret i1 %r
870
866
}
871
867
868
+ ; Negative test - require nuw.
869
+
872
870
define i1 @mul_urem_cmp_constant1 (i8 %x ) {
873
871
; CHECK-LABEL: @mul_urem_cmp_constant1(
874
872
; CHECK-NEXT: [[M:%.*]] = mul i8 [[X:%.*]], 43
@@ -880,6 +878,8 @@ define i1 @mul_urem_cmp_constant1(i8 %x) {
880
878
ret i1 %r
881
879
}
882
880
881
+ ; Negative test - x could be 0.
882
+
883
883
define i1 @mul_nuw_urem_cmp_constant0 (i8 %x ) {
884
884
; CHECK-LABEL: @mul_nuw_urem_cmp_constant0(
885
885
; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], 23
@@ -891,6 +891,8 @@ define i1 @mul_nuw_urem_cmp_constant0(i8 %x) {
891
891
ret i1 %r
892
892
}
893
893
894
+ ; Negative test - cmp constant is multiple of mul constant.
895
+
894
896
define i1 @mul_nuw_urem_cmp_constant_is_0 (i8 %x ) {
895
897
; CHECK-LABEL: @mul_nuw_urem_cmp_constant_is_0(
896
898
; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], 42
@@ -902,6 +904,8 @@ define i1 @mul_nuw_urem_cmp_constant_is_0(i8 %x) {
902
904
ret i1 %r
903
905
}
904
906
907
+ ; Negative test - cmp constant is multiple (treated as unsigned).
908
+
905
909
define i1 @mul_nuw_urem_cmp_neg_constant_is_0 (i8 %x ) {
906
910
; CHECK-LABEL: @mul_nuw_urem_cmp_neg_constant_is_0(
907
911
; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], 43
0 commit comments