@@ -682,15 +682,15 @@ define <4 x i32> @computesignbits_through_two_input_shuffle(<4 x i32> %x, <4 x i
682
682
ret <4 x i32 > %sel
683
683
}
684
684
685
+ ; Bitcast of condition from narrow source element type can be converted to select.
686
+
685
687
define <2 x i64 > @bitcast_vec_cond (<16 x i1 > %cond , <2 x i64 > %c , <2 x i64 > %d ) {
686
688
; CHECK-LABEL: @bitcast_vec_cond(
687
- ; CHECK-NEXT: [[S:%.*]] = sext <16 x i1> [[COND:%.*]] to <16 x i8>
688
- ; CHECK-NEXT: [[T9:%.*]] = bitcast <16 x i8> [[S]] to <2 x i64>
689
- ; CHECK-NEXT: [[NOTT9:%.*]] = xor <2 x i64> [[T9]], <i64 -1, i64 -1>
690
- ; CHECK-NEXT: [[T11:%.*]] = and <2 x i64> [[NOTT9]], [[C:%.*]]
691
- ; CHECK-NEXT: [[T12:%.*]] = and <2 x i64> [[T9]], [[D:%.*]]
692
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i64> [[T11]], [[T12]]
693
- ; CHECK-NEXT: ret <2 x i64> [[R]]
689
+ ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> [[D:%.*]] to <16 x i8>
690
+ ; CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x i64> [[C:%.*]] to <16 x i8>
691
+ ; CHECK-NEXT: [[TMP3:%.*]] = select <16 x i1> [[COND:%.*]], <16 x i8> [[TMP1]], <16 x i8> [[TMP2]]
692
+ ; CHECK-NEXT: [[TMP4:%.*]] = bitcast <16 x i8> [[TMP3]] to <2 x i64>
693
+ ; CHECK-NEXT: ret <2 x i64> [[TMP4]]
694
694
;
695
695
%s = sext <16 x i1 > %cond to <16 x i8 >
696
696
%t9 = bitcast <16 x i8 > %s to <2 x i64 >
@@ -701,6 +701,8 @@ define <2 x i64> @bitcast_vec_cond(<16 x i1> %cond, <2 x i64> %c, <2 x i64> %d)
701
701
ret <2 x i64 > %r
702
702
}
703
703
704
+ ; Negative test - bitcast of condition from wide source element type cannot be converted to select.
705
+
704
706
define <8 x i3 > @bitcast_vec_cond_commute1 (<3 x i1 > %cond , <8 x i3 > %pc , <8 x i3 > %d ) {
705
707
; CHECK-LABEL: @bitcast_vec_cond_commute1(
706
708
; CHECK-NEXT: [[C:%.*]] = mul <8 x i3> [[PC:%.*]], [[PC]]
@@ -726,13 +728,11 @@ define <2 x i16> @bitcast_vec_cond_commute2(<4 x i1> %cond, <2 x i16> %pc, <2 x
726
728
; CHECK-LABEL: @bitcast_vec_cond_commute2(
727
729
; CHECK-NEXT: [[C:%.*]] = mul <2 x i16> [[PC:%.*]], [[PC]]
728
730
; CHECK-NEXT: [[D:%.*]] = mul <2 x i16> [[PD:%.*]], [[PD]]
729
- ; CHECK-NEXT: [[S:%.*]] = sext <4 x i1> [[COND:%.*]] to <4 x i8>
730
- ; CHECK-NEXT: [[T9:%.*]] = bitcast <4 x i8> [[S]] to <2 x i16>
731
- ; CHECK-NEXT: [[NOTT9:%.*]] = xor <2 x i16> [[T9]], <i16 -1, i16 -1>
732
- ; CHECK-NEXT: [[T11:%.*]] = and <2 x i16> [[C]], [[NOTT9]]
733
- ; CHECK-NEXT: [[T12:%.*]] = and <2 x i16> [[D]], [[T9]]
734
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i16> [[T11]], [[T12]]
735
- ; CHECK-NEXT: ret <2 x i16> [[R]]
731
+ ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x i16> [[D]] to <4 x i8>
732
+ ; CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x i16> [[C]] to <4 x i8>
733
+ ; CHECK-NEXT: [[TMP3:%.*]] = select <4 x i1> [[COND:%.*]], <4 x i8> [[TMP1]], <4 x i8> [[TMP2]]
734
+ ; CHECK-NEXT: [[TMP4:%.*]] = bitcast <4 x i8> [[TMP3]] to <2 x i16>
735
+ ; CHECK-NEXT: ret <2 x i16> [[TMP4]]
736
736
;
737
737
%c = mul <2 x i16 > %pc , %pc ; thwart complexity-based canonicalization
738
738
%d = mul <2 x i16 > %pd , %pd ; thwart complexity-based canonicalization
@@ -745,17 +745,18 @@ define <2 x i16> @bitcast_vec_cond_commute2(<4 x i1> %cond, <2 x i16> %pc, <2 x
745
745
ret <2 x i16 > %r
746
746
}
747
747
748
+ ; Condition doesn't have to be a bool vec - just all signbits.
749
+
748
750
define <2 x i16 > @bitcast_vec_cond_commute3 (<4 x i8 > %cond , <2 x i16 > %pc , <2 x i16 > %pd ) {
749
751
; CHECK-LABEL: @bitcast_vec_cond_commute3(
750
752
; CHECK-NEXT: [[C:%.*]] = mul <2 x i16> [[PC:%.*]], [[PC]]
751
753
; CHECK-NEXT: [[D:%.*]] = mul <2 x i16> [[PD:%.*]], [[PD]]
752
- ; CHECK-NEXT: [[S:%.*]] = ashr <4 x i8> [[COND:%.*]], <i8 7, i8 7, i8 7, i8 7>
753
- ; CHECK-NEXT: [[T9:%.*]] = bitcast <4 x i8> [[S]] to <2 x i16>
754
- ; CHECK-NEXT: [[NOTT9:%.*]] = xor <2 x i16> [[T9]], <i16 -1, i16 -1>
755
- ; CHECK-NEXT: [[T11:%.*]] = and <2 x i16> [[C]], [[NOTT9]]
756
- ; CHECK-NEXT: [[T12:%.*]] = and <2 x i16> [[D]], [[T9]]
757
- ; CHECK-NEXT: [[R:%.*]] = or <2 x i16> [[T11]], [[T12]]
758
- ; CHECK-NEXT: ret <2 x i16> [[R]]
754
+ ; CHECK-NEXT: [[DOTNOT:%.*]] = icmp sgt <4 x i8> [[COND:%.*]], <i8 -1, i8 -1, i8 -1, i8 -1>
755
+ ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x i16> [[D]] to <4 x i8>
756
+ ; CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x i16> [[C]] to <4 x i8>
757
+ ; CHECK-NEXT: [[TMP3:%.*]] = select <4 x i1> [[DOTNOT]], <4 x i8> [[TMP2]], <4 x i8> [[TMP1]]
758
+ ; CHECK-NEXT: [[TMP4:%.*]] = bitcast <4 x i8> [[TMP3]] to <2 x i16>
759
+ ; CHECK-NEXT: ret <2 x i16> [[TMP4]]
759
760
;
760
761
%c = mul <2 x i16 > %pc , %pc ; thwart complexity-based canonicalization
761
762
%d = mul <2 x i16 > %pd , %pd ; thwart complexity-based canonicalization
0 commit comments