@@ -567,3 +567,33 @@ define i16 @cond_value_may_not_well_defined(i16 %x) {
567
567
%sel = select i1 %cmp , i16 %and , i16 24
568
568
ret i16 %sel
569
569
}
570
+
571
+ define i16 @and_elide_poison_flags (i16 noundef %a ) {
572
+ ; CHECK-LABEL: @and_elide_poison_flags(
573
+ ; CHECK-NEXT: [[X:%.*]] = add nuw i16 [[A:%.*]], 1
574
+ ; CHECK-NEXT: [[AND:%.*]] = and i16 [[X]], 7
575
+ ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X]], 8
576
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i16 [[AND]], i16 24
577
+ ; CHECK-NEXT: ret i16 [[SEL]]
578
+ ;
579
+ %x = add nuw i16 %a , 1
580
+ %and = and i16 %x , 7
581
+ %cmp = icmp ult i16 %x , 8
582
+ %sel = select i1 %cmp , i16 %and , i16 24
583
+ ret i16 %sel
584
+ }
585
+
586
+ define i16 @and_elide_poison_flags_missing_noundef (i16 %a ) {
587
+ ; CHECK-LABEL: @and_elide_poison_flags_missing_noundef(
588
+ ; CHECK-NEXT: [[X:%.*]] = add nuw i16 [[A:%.*]], 1
589
+ ; CHECK-NEXT: [[AND:%.*]] = and i16 [[X]], 7
590
+ ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X]], 8
591
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i16 [[AND]], i16 24
592
+ ; CHECK-NEXT: ret i16 [[SEL]]
593
+ ;
594
+ %x = add nuw i16 %a , 1
595
+ %and = and i16 %x , 7
596
+ %cmp = icmp ult i16 %x , 8
597
+ %sel = select i1 %cmp , i16 %and , i16 24
598
+ ret i16 %sel
599
+ }
0 commit comments