[InstCombine] add more insert-extract tests for D52439; NFC
authorSanjay Patel <spatel@rotateright.com>
Mon, 1 Oct 2018 14:29:09 +0000 (14:29 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 1 Oct 2018 14:29:09 +0000 (14:29 +0000)
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

llvm/test/Transforms/InstCombine/extractelement.ll

index 332aae2..f29c020 100644 (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
+}
+