@@ -858,3 +858,73 @@ define <2 x i32> @false_undef_true_constextpr_vec(i1 %cond) {
858
858
%s = select i1 %cond , <2 x i32 > <i32 undef , i32 ptrtoint (i32* @g to i32 )>, <2 x i32 > <i32 ptrtoint (i32* @g to i32 ), i32 undef >
859
859
ret <2 x i32 > %s
860
860
}
861
+
862
+ define i32 @all_constant_true_undef () {
863
+ ; CHECK-LABEL: @all_constant_true_undef(
864
+ ; CHECK-NEXT: ret i32 1
865
+ ;
866
+ %s = select i1 ptrtoint (i32 ()* @all_constant_true_undef to i1 ), i32 undef , i32 1
867
+ ret i32 %s
868
+ }
869
+
870
+ define float @all_constant_false_undef () {
871
+ ; CHECK-LABEL: @all_constant_false_undef(
872
+ ; CHECK-NEXT: ret float 1.000000e+00
873
+ ;
874
+ %s = select i1 ptrtoint (float ()* @all_constant_false_undef to i1 ), float undef , float 1 .0
875
+ ret float %s
876
+ }
877
+
878
+ define <2 x i32 > @all_constant_true_undef_vec () {
879
+ ; CHECK-LABEL: @all_constant_true_undef_vec(
880
+ ; CHECK-NEXT: ret <2 x i32> <i32 1, i32 -1>
881
+ ;
882
+ %s = select i1 ptrtoint (<2 x i32 > ()* @all_constant_true_undef_vec to i1 ), <2 x i32 > undef , <2 x i32 > <i32 1 , i32 -1 >
883
+ ret <2 x i32 > %s
884
+ }
885
+
886
+ define <2 x float > @all_constant_false_undef_vec () {
887
+ ; CHECK-LABEL: @all_constant_false_undef_vec(
888
+ ; CHECK-NEXT: ret <2 x float> <float 1.000000e+00, float -1.000000e+00>
889
+ ;
890
+ %s = select i1 ptrtoint (<2 x float > ()* @all_constant_false_undef_vec to i1 ), <2 x float > undef , <2 x float > <float 1 .0 , float -1 .0 >
891
+ ret <2 x float > %s
892
+ }
893
+
894
+ ; Negative tests. Don't fold if the non-undef operand is a constexpr.
895
+ define i32 @all_constant_false_undef_true_constexpr () {
896
+ ; CHECK-LABEL: @all_constant_false_undef_true_constexpr(
897
+ ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i1), i32 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i32), i32 undef
898
+ ; CHECK-NEXT: ret i32 [[S]]
899
+ ;
900
+ %s = select i1 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i1 ), i32 ptrtoint (i32 ()* @all_constant_false_undef_true_constexpr to i32 ), i32 undef
901
+ ret i32 %s
902
+ }
903
+
904
+ define i32 @all_constant_true_undef_false_constexpr () {
905
+ ; CHECK-LABEL: @all_constant_true_undef_false_constexpr(
906
+ ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i1), i32 undef, i32 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i32)
907
+ ; CHECK-NEXT: ret i32 [[S]]
908
+ ;
909
+ %s = select i1 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i1 ), i32 undef , i32 ptrtoint (i32 ()* @all_constant_true_undef_false_constexpr to i32 )
910
+ ret i32 %s
911
+ }
912
+
913
+ ; Negative tests. Don't fold if the non-undef operand is a vector containing a constexpr.
914
+ define <2 x i32 > @all_constant_false_undef_true_constexpr_vec () {
915
+ ; CHECK-LABEL: @all_constant_false_undef_true_constexpr_vec(
916
+ ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (<2 x i32> ()* @all_constant_false_undef_true_constexpr_vec to i1), <2 x i32> <i32 ptrtoint (<2 x i32> ()* @all_constant_false_undef_true_constexpr_vec to i32), i32 -1>, <2 x i32> undef
917
+ ; CHECK-NEXT: ret <2 x i32> [[S]]
918
+ ;
919
+ %s = select i1 ptrtoint (<2 x i32 > ()* @all_constant_false_undef_true_constexpr_vec to i1 ), <2 x i32 > <i32 ptrtoint (<2 x i32 > ()* @all_constant_false_undef_true_constexpr_vec to i32 ), i32 -1 >, <2 x i32 > undef
920
+ ret <2 x i32 > %s
921
+ }
922
+
923
+ define <2 x i32 > @all_constant_true_undef_false_constexpr_vec () {
924
+ ; CHECK-LABEL: @all_constant_true_undef_false_constexpr_vec(
925
+ ; CHECK-NEXT: [[S:%.*]] = select i1 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i1), <2 x i32> undef, <2 x i32> <i32 -1, i32 ptrtoint (<2 x i32> ()* @all_constant_true_undef_false_constexpr_vec to i32)>
926
+ ; CHECK-NEXT: ret <2 x i32> [[S]]
927
+ ;
928
+ %s = select i1 ptrtoint (<2 x i32 > ()* @all_constant_true_undef_false_constexpr_vec to i1 ), <2 x i32 > undef , <2 x i32 ><i32 -1 , i32 ptrtoint (<2 x i32 > ()* @all_constant_true_undef_false_constexpr_vec to i32 )>
929
+ ret <2 x i32 > %s
930
+ }
0 commit comments