[InstCombine] add tests for bitcasted selects; NFC
llvm-svn: 286978
This commit is contained in:
parent
56fa12c5a3
commit
bb238bb4e5
@ -113,6 +113,90 @@ define <4 x i32> @bitcast_xor_bitcast(<4 x i32> %a, i128 %b) {
|
||||
ret <4 x i32> %bc2
|
||||
}
|
||||
|
||||
; FIXME: Change the type of the vector select to eliminate 2 bitcasts.
|
||||
; https://llvm.org/bugs/show_bug.cgi?id=6137#c6
|
||||
|
||||
define <4 x float> @bitcast_vector_select(<4 x float> %x, <2 x i64> %y, <4 x i1> %cmp) {
|
||||
; CHECK-LABEL: @bitcast_vector_select(
|
||||
; CHECK-NEXT: [[T4:%.*]] = bitcast <4 x float> %x to <4 x i32>
|
||||
; CHECK-NEXT: [[T5:%.*]] = bitcast <2 x i64> %y to <4 x i32>
|
||||
; CHECK-NEXT: [[T6:%.*]] = select <4 x i1> %cmp, <4 x i32> [[T4]], <4 x i32> [[T5]]
|
||||
; CHECK-NEXT: [[T7:%.*]] = bitcast <4 x i32> [[T6]] to <4 x float>
|
||||
; CHECK-NEXT: ret <4 x float> [[T7]]
|
||||
;
|
||||
%t4 = bitcast <4 x float> %x to <4 x i32>
|
||||
%t5 = bitcast <2 x i64> %y to <4 x i32>
|
||||
%t6 = select <4 x i1> %cmp, <4 x i32> %t4, <4 x i32> %t5
|
||||
%t7 = bitcast <4 x i32> %t6 to <4 x float>
|
||||
ret <4 x float> %t7
|
||||
}
|
||||
|
||||
; FIXME: Change the type of the scalar select to eliminate a bitcast.
|
||||
|
||||
define float @bitcast_scalar_select(float %x, <4 x i8> %y, i1 %cmp) {
|
||||
; CHECK-LABEL: @bitcast_scalar_select(
|
||||
; CHECK-NEXT: [[T4:%.*]] = bitcast float %x to <4 x i8>
|
||||
; CHECK-NEXT: [[T6:%.*]] = select i1 %cmp, <4 x i8> [[T4]], <4 x i8> %y
|
||||
; CHECK-NEXT: [[T7:%.*]] = bitcast <4 x i8> [[T6]] to float
|
||||
; CHECK-NEXT: ret float [[T7]]
|
||||
;
|
||||
%t4 = bitcast float %x to <4 x i8>
|
||||
%t6 = select i1 %cmp, <4 x i8> %t4, <4 x i8> %y
|
||||
%t7 = bitcast <4 x i8> %t6 to float
|
||||
ret float %t7
|
||||
}
|
||||
|
||||
; FIXME: Change the type of the scalar select of vectors to eliminate 2 bitcasts.
|
||||
|
||||
define <4 x float> @bitcast_scalar_select_of_vectors(<4 x float> %x, <2 x i64> %y, i1 %cmp) {
|
||||
; CHECK-LABEL: @bitcast_scalar_select_of_vectors(
|
||||
; CHECK-NEXT: [[T4:%.*]] = bitcast <4 x float> %x to <4 x i32>
|
||||
; CHECK-NEXT: [[T5:%.*]] = bitcast <2 x i64> %y to <4 x i32>
|
||||
; CHECK-NEXT: [[T6:%.*]] = select i1 %cmp, <4 x i32> [[T4]], <4 x i32> [[T5]]
|
||||
; CHECK-NEXT: [[T7:%.*]] = bitcast <4 x i32> [[T6]] to <4 x float>
|
||||
; CHECK-NEXT: ret <4 x float> [[T7]]
|
||||
;
|
||||
%t4 = bitcast <4 x float> %x to <4 x i32>
|
||||
%t5 = bitcast <2 x i64> %y to <4 x i32>
|
||||
%t6 = select i1 %cmp, <4 x i32> %t4, <4 x i32> %t5
|
||||
%t7 = bitcast <4 x i32> %t6 to <4 x float>
|
||||
ret <4 x float> %t7
|
||||
}
|
||||
|
||||
; Can't change the type of the vector select if the dest type is scalar.
|
||||
|
||||
define float @bitcast_vector_select_no_fold1(float %x, <2 x i16> %y, <4 x i1> %cmp) {
|
||||
; CHECK-LABEL: @bitcast_vector_select_no_fold1(
|
||||
; CHECK-NEXT: [[T4:%.*]] = bitcast float %x to <4 x i8>
|
||||
; CHECK-NEXT: [[T5:%.*]] = bitcast <2 x i16> %y to <4 x i8>
|
||||
; CHECK-NEXT: [[T6:%.*]] = select <4 x i1> %cmp, <4 x i8> [[T4]], <4 x i8> [[T5]]
|
||||
; CHECK-NEXT: [[T7:%.*]] = bitcast <4 x i8> [[T6]] to float
|
||||
; CHECK-NEXT: ret float [[T7]]
|
||||
;
|
||||
%t4 = bitcast float %x to <4 x i8>
|
||||
%t5 = bitcast <2 x i16> %y to <4 x i8>
|
||||
%t6 = select <4 x i1> %cmp, <4 x i8> %t4, <4 x i8> %t5
|
||||
%t7 = bitcast <4 x i8> %t6 to float
|
||||
ret float %t7
|
||||
}
|
||||
|
||||
; Can't change the type of the vector select if the number of elements in the dest type is not the same.
|
||||
|
||||
define <2 x float> @bitcast_vector_select_no_fold2(<2 x float> %x, <4 x i16> %y, <8 x i1> %cmp) {
|
||||
; CHECK-LABEL: @bitcast_vector_select_no_fold2(
|
||||
; CHECK-NEXT: [[T4:%.*]] = bitcast <2 x float> %x to <8 x i8>
|
||||
; CHECK-NEXT: [[T5:%.*]] = bitcast <4 x i16> %y to <8 x i8>
|
||||
; CHECK-NEXT: [[T6:%.*]] = select <8 x i1> %cmp, <8 x i8> [[T4]], <8 x i8> [[T5]]
|
||||
; CHECK-NEXT: [[T7:%.*]] = bitcast <8 x i8> [[T6]] to <2 x float>
|
||||
; CHECK-NEXT: ret <2 x float> [[T7]]
|
||||
;
|
||||
%t4 = bitcast <2 x float> %x to <8 x i8>
|
||||
%t5 = bitcast <4 x i16> %y to <8 x i8>
|
||||
%t6 = select <8 x i1> %cmp, <8 x i8> %t4, <8 x i8> %t5
|
||||
%t7 = bitcast <8 x i8> %t6 to <2 x float>
|
||||
ret <2 x float> %t7
|
||||
}
|
||||
|
||||
; Optimize bitcasts that are extracting low element of vector. This happens because of SRoA.
|
||||
; rdar://7892780
|
||||
define float @test2(<2 x float> %A, <2 x i32> %B) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user