diff options
Diffstat (limited to 'llvm/test/Transforms/InstCombine/broadcast.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/broadcast.ll | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/broadcast.ll b/llvm/test/Transforms/InstCombine/broadcast.ll new file mode 100644 index 00000000000..8485cd9c53f --- /dev/null +++ b/llvm/test/Transforms/InstCombine/broadcast.ll @@ -0,0 +1,137 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -instcombine -S < %s | FileCheck %s + +; CHECK-LABEL: good1 +; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0 +; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: ret <4 x float> %[[BCAST]] +define <4 x float> @good1(float %arg) { + %tmp = insertelement <4 x float> undef, float %arg, i32 0 + %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + ret <4 x float> %tmp6 +} + +; CHECK-LABEL: good2 +; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0 +; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: ret <4 x float> %[[BCAST]] +define <4 x float> @good2(float %arg) { + %tmp = insertelement <4 x float> undef, float %arg, i32 1 + %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 2 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 0 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + ret <4 x float> %tmp6 +} + +; CHECK-LABEL: good3 +; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0 +; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[INS]], <4 x float> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: ret <4 x float> %[[BCAST]] +define <4 x float> @good3(float %arg) { + %tmp = insertelement <4 x float> zeroinitializer, float %arg, i32 0 + %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + ret <4 x float> %tmp6 +} + +; CHECK-LABEL: good4 +; CHECK: %[[INS:.*]] = insertelement <4 x float> undef, float %arg, i32 0 +; CHECK-NEXT: %[[ADD:.*]] = fadd <4 x float> %[[INS]], %[[INS]] +; CHECK-NEXT: %[[BCAST:.*]] = shufflevector <4 x float> %[[ADD]], <4 x float> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: ret <4 x float> %[[BCAST]] +define <4 x float> @good4(float %arg) { + %tmp = insertelement <4 x float> zeroinitializer, float %arg, i32 0 + %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + %tmp7 = fadd <4 x float> %tmp6, %tmp6 + ret <4 x float> %tmp7 +} + +; CHECK-LABEL: @good5( +; CHECK-NEXT: %ins1 = insertelement <4 x float> undef, float %v, i32 0 +; CHECK-NEXT: %a1 = fadd <4 x float> %ins1, %ins1 +; CHECK-NEXT: %ins4 = shufflevector <4 x float> %ins1, <4 x float> undef, <4 x i32> zeroinitializer +; CHECK-NEXT: %res = fadd <4 x float> %a1, %ins4 +; CHECK-NEXT: ret <4 x float> %res +define <4 x float> @good5(float %v) { + %ins1 = insertelement <4 x float> undef, float %v, i32 0 + %a1 = fadd <4 x float> %ins1, %ins1 + %ins2 = insertelement<4 x float> %ins1, float %v, i32 1 + %ins3 = insertelement<4 x float> %ins2, float %v, i32 2 + %ins4 = insertelement<4 x float> %ins3, float %v, i32 3 + %res = fadd <4 x float> %a1, %ins4 + ret <4 x float> %res +} + +; CHECK-LABEL: bad1 +; CHECK-NOT: shufflevector +define <4 x float> @bad1(float %arg) { + %tmp = insertelement <4 x float> undef, float %arg, i32 1 + %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + ret <4 x float> %tmp6 +} + +; CHECK-LABEL: bad2 +; CHECK-NOT: shufflevector +define <4 x float> @bad2(float %arg) { + %tmp = insertelement <4 x float> undef, float %arg, i32 0 + %tmp5 = insertelement <4 x float> %tmp, float %arg, i32 2 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + ret <4 x float> %tmp6 +} + +; CHECK-LABEL: bad3 +; CHECK-NOT: shufflevector +define <4 x float> @bad3(float %arg, float %arg2) { + %tmp = insertelement <4 x float> undef, float %arg, i32 0 + %tmp4 = insertelement <4 x float> %tmp, float %arg2, i32 1 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + ret <4 x float> %tmp6 +} + +; CHECK-LABEL: bad4 +; CHECK-NOT: shufflevector +define <1 x float> @bad4(float %arg) { + %tmp = insertelement <1 x float> undef, float %arg, i32 0 + ret <1 x float> %tmp +} + +; CHECK-LABEL: bad5 +; CHECK-NOT: shufflevector +define <4 x float> @bad5(float %arg) { + %tmp = insertelement <4 x float> undef, float %arg, i32 0 + %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 2 + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + %tmp7 = fadd <4 x float> %tmp6, %tmp4 + ret <4 x float> %tmp7 +} + +; CHECK-LABEL: bad6 +; CHECK-NOT: shufflevector +define <4 x float> @bad6(float %arg, i32 %k) { + %tmp = insertelement <4 x float> undef, float %arg, i32 0 + %tmp4 = insertelement <4 x float> %tmp, float %arg, i32 1 + %tmp5 = insertelement <4 x float> %tmp4, float %arg, i32 %k + %tmp6 = insertelement <4 x float> %tmp5, float %arg, i32 3 + ret <4 x float> %tmp6 +} + +; CHECK-LABEL: @bad7( +; CHECK-NOT: shufflevector +define <4 x float> @bad7(float %v) { + %ins1 = insertelement <4 x float> undef, float %v, i32 1 + %a1 = fadd <4 x float> %ins1, %ins1 + %ins2 = insertelement<4 x float> %ins1, float %v, i32 2 + %ins3 = insertelement<4 x float> %ins2, float %v, i32 3 + %ins4 = insertelement<4 x float> %ins3, float %v, i32 0 + %res = fadd <4 x float> %a1, %ins4 + ret <4 x float> %res +} |