[InstCombine] add more insert-extract tests for D52439; NFC

The first attempt at this transform:
rL343407
...was reverted:
rL343458
...because it did not handle the case where we bitcast to FP. 
The patch was already limited to avoid the case where we
bitcast from FP, but we might want to transform that too.

llvm-svn: 343480
This commit is contained in:
Sanjay Patel 2018-10-01 14:29:09 +00:00
parent 94c5064701
commit 22ae8dabb5
1 changed files with 26 additions and 0 deletions

View File

@ -139,3 +139,29 @@ define i8 @bitcasted_inselt_wide_source_uses(i32 %x) {
ret i8 %r
}
define float @bitcasted_inselt_to_FP(i64 %x) {
; ANY-LABEL: @bitcasted_inselt_to_FP(
; ANY-NEXT: [[I:%.*]] = insertelement <2 x i64> undef, i64 [[X:%.*]], i32 0
; ANY-NEXT: [[B:%.*]] = bitcast <2 x i64> [[I]] to <4 x float>
; ANY-NEXT: [[R:%.*]] = extractelement <4 x float> [[B]], i32 1
; ANY-NEXT: ret float [[R]]
;
%i = insertelement <2 x i64> undef, i64 %x, i32 0
%b = bitcast <2 x i64> %i to <4 x float>
%r = extractelement <4 x float> %b, i32 1
ret float %r
}
define i32 @bitcasted_inselt_from_FP(double %x) {
; ANY-LABEL: @bitcasted_inselt_from_FP(
; ANY-NEXT: [[I:%.*]] = insertelement <2 x double> undef, double [[X:%.*]], i32 0
; ANY-NEXT: [[B:%.*]] = bitcast <2 x double> [[I]] to <4 x i32>
; ANY-NEXT: [[R:%.*]] = extractelement <4 x i32> [[B]], i32 1
; ANY-NEXT: ret i32 [[R]]
;
%i = insertelement <2 x double> undef, double %x, i32 0
%b = bitcast <2 x double> %i to <4 x i32>
%r = extractelement <4 x i32> %b, i32 1
ret i32 %r
}