@@ -2797,6 +2797,19 @@ define <2 x i8> @select_replacement_add_eq_vec_poison(<2 x i8> %x, <2 x i8> %y)
2797
2797
ret <2 x i8 > %sel
2798
2798
}
2799
2799
2800
+ define <2 x i8 > @select_replacement_add_eq_vec_undef (<2 x i8 > %x , <2 x i8 > %y ) {
2801
+ ; CHECK-LABEL: @select_replacement_add_eq_vec_undef(
2802
+ ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 1, i8 undef>
2803
+ ; CHECK-NEXT: [[ADD:%.*]] = add <2 x i8> [[X]], <i8 1, i8 1>
2804
+ ; CHECK-NEXT: [[SEL:%.*]] = select <2 x i1> [[CMP]], <2 x i8> [[ADD]], <2 x i8> [[Y:%.*]]
2805
+ ; CHECK-NEXT: ret <2 x i8> [[SEL]]
2806
+ ;
2807
+ %cmp = icmp eq <2 x i8 > %x , <i8 1 , i8 undef >
2808
+ %add = add <2 x i8 > %x , <i8 1 , i8 1 >
2809
+ %sel = select <2 x i1 > %cmp , <2 x i8 > %add , <2 x i8 > %y
2810
+ ret <2 x i8 > %sel
2811
+ }
2812
+
2800
2813
define i8 @select_replacement_add_ne (i8 %x , i8 %y ) {
2801
2814
; CHECK-LABEL: @select_replacement_add_ne(
2802
2815
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 [[X:%.*]], 1
@@ -2835,6 +2848,21 @@ define i8 @select_replacement_sub_noundef(i8 %x, i8 noundef %y, i8 %z) {
2835
2848
ret i8 %sel
2836
2849
}
2837
2850
2851
+ define i8 @select_replacement_sub_noundef_but_may_be_poison (i8 %x , i8 noundef %yy , i8 %z ) {
2852
+ ; CHECK-LABEL: @select_replacement_sub_noundef_but_may_be_poison(
2853
+ ; CHECK-NEXT: [[Y:%.*]] = shl nuw i8 [[YY:%.*]], 1
2854
+ ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[Y]], [[X:%.*]]
2855
+ ; CHECK-NEXT: [[SUB:%.*]] = sub i8 [[X]], [[Y]]
2856
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i8 [[SUB]], i8 [[Z:%.*]]
2857
+ ; CHECK-NEXT: ret i8 [[SEL]]
2858
+ ;
2859
+ %y = shl nuw i8 %yy , 1
2860
+ %cmp = icmp eq i8 %x , %y
2861
+ %sub = sub i8 %x , %y
2862
+ %sel = select i1 %cmp , i8 %sub , i8 %z
2863
+ ret i8 %sel
2864
+ }
2865
+
2838
2866
; TODO: The transform is also safe without noundef.
2839
2867
define i8 @select_replacement_sub (i8 %x , i8 %y , i8 %z ) {
2840
2868
; CHECK-LABEL: @select_replacement_sub(
0 commit comments