@@ -680,9 +680,26 @@ define i3 @or_xorn_and_commute1(i3 %a, i3 %b) {
680
680
681
681
define <2 x i32 > @or_xorn_and_commute2 (<2 x i32 > %a , <2 x i32 > %b ) {
682
682
; CHECK-LABEL: @or_xorn_and_commute2(
683
- ; CHECK-NEXT: [[NEGA:%.*]] = xor <2 x i32> [[A:%.*]], <i32 undef , i32 -1>
683
+ ; CHECK-NEXT: [[NEGA:%.*]] = xor <2 x i32> [[A:%.*]], <i32 -1 , i32 -1>
684
684
; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i32> [[B:%.*]], [[NEGA]]
685
685
; CHECK-NEXT: ret <2 x i32> [[XOR]]
686
+ ;
687
+ %nega = xor <2 x i32 > %a , <i32 -1 , i32 -1 >
688
+ %and = and <2 x i32 > %b , %a
689
+ %xor = xor <2 x i32 > %b , %nega
690
+ %or = or <2 x i32 > %xor , %and
691
+ ret <2 x i32 > %or
692
+ }
693
+
694
+ ; This is not safe to fold because the extra logic ops limit the undef-ness of the result.
695
+
696
+ define <2 x i32 > @or_xorn_and_commute2_undef (<2 x i32 > %a , <2 x i32 > %b ) {
697
+ ; CHECK-LABEL: @or_xorn_and_commute2_undef(
698
+ ; CHECK-NEXT: [[NEGA:%.*]] = xor <2 x i32> [[A:%.*]], <i32 undef, i32 -1>
699
+ ; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[B:%.*]], [[A]]
700
+ ; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i32> [[B]], [[NEGA]]
701
+ ; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[XOR]], [[AND]]
702
+ ; CHECK-NEXT: ret <2 x i32> [[OR]]
686
703
;
687
704
%nega = xor <2 x i32 > %a , <i32 undef , i32 -1 >
688
705
%and = and <2 x i32 > %b , %a
@@ -691,6 +708,23 @@ define <2 x i32> @or_xorn_and_commute2(<2 x i32> %a, <2 x i32> %b) {
691
708
ret <2 x i32 > %or
692
709
}
693
710
711
+ ; TODO: Unlike the above test, this is safe to fold.
712
+
713
+ define <2 x i32 > @or_xorn_and_commute2_poison (<2 x i32 > %a , <2 x i32 > %b ) {
714
+ ; CHECK-LABEL: @or_xorn_and_commute2_poison(
715
+ ; CHECK-NEXT: [[NEGA:%.*]] = xor <2 x i32> [[A:%.*]], <i32 poison, i32 -1>
716
+ ; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[B:%.*]], [[A]]
717
+ ; CHECK-NEXT: [[XOR:%.*]] = xor <2 x i32> [[B]], [[NEGA]]
718
+ ; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[XOR]], [[AND]]
719
+ ; CHECK-NEXT: ret <2 x i32> [[OR]]
720
+ ;
721
+ %nega = xor <2 x i32 > %a , <i32 poison, i32 -1 >
722
+ %and = and <2 x i32 > %b , %a
723
+ %xor = xor <2 x i32 > %b , %nega
724
+ %or = or <2 x i32 > %xor , %and
725
+ ret <2 x i32 > %or
726
+ }
727
+
694
728
define i32 @or_xorn_and_commute3 (i32 %a , i32 %b ) {
695
729
; CHECK-LABEL: @or_xorn_and_commute3(
696
730
; CHECK-NEXT: [[NEGA:%.*]] = xor i32 [[A:%.*]], -1
0 commit comments