[llvm] 4a065a7 - [InstCombine] add tests for bitcast+inselt; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 06:12:17 PDT 2020


Author: Sanjay Patel
Date: 2020-04-30T09:11:29-04:00
New Revision: 4a065a72efe1232291af679374a87d88b2a5f195

URL: https://github.com/llvm/llvm-project/commit/4a065a72efe1232291af679374a87d88b2a5f195
DIFF: https://github.com/llvm/llvm-project/commit/4a065a72efe1232291af679374a87d88b2a5f195.diff

LOG: [InstCombine] add tests for bitcast+inselt; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll b/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll
index 245f072714b4..4d39651af34d 100644
--- a/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll
+++ b/llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll
@@ -70,3 +70,77 @@ entry:
   %1 = bitcast <1 x i64> %0 to double
   ret double %1
 }
+
+define <3 x i64> @bitcast_inselt_undef(double %x, i32 %idx) {
+; CHECK-LABEL: @bitcast_inselt_undef(
+; CHECK-NEXT:    [[XB:%.*]] = bitcast double [[X:%.*]] to i64
+; CHECK-NEXT:    [[I:%.*]] = insertelement <3 x i64> undef, i64 [[XB]], i32 [[IDX:%.*]]
+; CHECK-NEXT:    ret <3 x i64> [[I]]
+;
+  %xb = bitcast double %x to i64
+  %i = insertelement <3 x i64> undef, i64 %xb, i32 %idx
+  ret <3 x i64> %i
+}
+
+define <3 x float> @bitcast_inselt_undef_fp(i32 %x, i567 %idx) {
+; CHECK-LABEL: @bitcast_inselt_undef_fp(
+; CHECK-NEXT:    [[XB:%.*]] = bitcast i32 [[X:%.*]] to float
+; CHECK-NEXT:    [[I:%.*]] = insertelement <3 x float> undef, float [[XB]], i567 [[IDX:%.*]]
+; CHECK-NEXT:    ret <3 x float> [[I]]
+;
+  %xb = bitcast i32 %x to float
+  %i = insertelement <3 x float> undef, float %xb, i567 %idx
+  ret <3 x float> %i
+}
+
+declare void @use(i64)
+
+define <3 x i64> @bitcast_inselt_undef_extra_use(double %x, i32 %idx) {
+; CHECK-LABEL: @bitcast_inselt_undef_extra_use(
+; CHECK-NEXT:    [[XB:%.*]] = bitcast double [[X:%.*]] to i64
+; CHECK-NEXT:    call void @use(i64 [[XB]])
+; CHECK-NEXT:    [[I:%.*]] = insertelement <3 x i64> undef, i64 [[XB]], i32 [[IDX:%.*]]
+; CHECK-NEXT:    ret <3 x i64> [[I]]
+;
+  %xb = bitcast double %x to i64
+  call void @use(i64 %xb)
+  %i = insertelement <3 x i64> undef, i64 %xb, i32 %idx
+  ret <3 x i64> %i
+}
+
+define <3 x i64> @bitcast_inselt_undef_vec_src(<2 x i32> %x, i32 %idx) {
+; CHECK-LABEL: @bitcast_inselt_undef_vec_src(
+; CHECK-NEXT:    [[XB:%.*]] = bitcast <2 x i32> [[X:%.*]] to i64
+; CHECK-NEXT:    [[I:%.*]] = insertelement <3 x i64> undef, i64 [[XB]], i32 [[IDX:%.*]]
+; CHECK-NEXT:    ret <3 x i64> [[I]]
+;
+  %xb = bitcast <2 x i32> %x to i64
+  %i = insertelement <3 x i64> undef, i64 %xb, i32 %idx
+  ret <3 x i64> %i
+}
+
+define <3 x i64> @bitcast_inselt_undef_from_mmx(x86_mmx %x, i32 %idx) {
+; CHECK-LABEL: @bitcast_inselt_undef_from_mmx(
+; CHECK-NEXT:    [[XB:%.*]] = bitcast x86_mmx [[X:%.*]] to i64
+; CHECK-NEXT:    [[I:%.*]] = insertelement <3 x i64> undef, i64 [[XB]], i32 [[IDX:%.*]]
+; CHECK-NEXT:    ret <3 x i64> [[I]]
+;
+  %xb = bitcast x86_mmx %x to i64
+  %i = insertelement <3 x i64> undef, i64 %xb, i32 %idx
+  ret <3 x i64> %i
+}
+
+define <2 x i64> @PR45748(double %x, double %y) {
+; CHECK-LABEL: @PR45748(
+; CHECK-NEXT:    [[XB:%.*]] = bitcast double [[X:%.*]] to i64
+; CHECK-NEXT:    [[I0:%.*]] = insertelement <2 x i64> undef, i64 [[XB]], i32 0
+; CHECK-NEXT:    [[YB:%.*]] = bitcast double [[Y:%.*]] to i64
+; CHECK-NEXT:    [[I1:%.*]] = insertelement <2 x i64> [[I0]], i64 [[YB]], i32 1
+; CHECK-NEXT:    ret <2 x i64> [[I1]]
+;
+  %xb = bitcast double %x to i64
+  %i0 = insertelement <2 x i64> undef, i64 %xb, i32 0
+  %yb = bitcast double %y to i64
+  %i1 = insertelement <2 x i64> %i0, i64 %yb, i32 1
+  ret <2 x i64> %i1
+}


        


More information about the llvm-commits mailing list