[llvm] e1790c8 - Revert "[InstCombine] Remove redundant splats in InstCombineVectorOps"

Peter Waller via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 01:01:20 PDT 2022


Author: Peter Waller
Date: 2022-11-03T07:56:03Z
New Revision: e1790c8c290d773cd5b1fc79f80b7a23dceb7589

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

LOG: Revert "[InstCombine] Remove redundant splats in InstCombineVectorOps"

This reverts commit 957eed0b1af2cb88edafe1ff2643a38165c67a40.

Added: 
    llvm/test/Transforms/VectorCombine/AArch64/insert-shuffle-binop.ll

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineInternal.h
    llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
    llvm/test/Transforms/InstCombine/shuffle-binop.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 11aed7754c264..3f1bcea3727f5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -167,7 +167,6 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
   Instruction *visitInsertValueInst(InsertValueInst &IV);
   Instruction *visitInsertElementInst(InsertElementInst &IE);
   Instruction *visitExtractElementInst(ExtractElementInst &EI);
-  Instruction *simplifyBinOpSplats(ShuffleVectorInst &SVI);
   Instruction *visitShuffleVectorInst(ShuffleVectorInst &SVI);
   Instruction *visitExtractValueInst(ExtractValueInst &EV);
   Instruction *visitLandingPadInst(LandingPadInst &LI);

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index 6581fe0b9dc91..d50918629ba5c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -2598,34 +2598,6 @@ static Instruction *foldIdentityPaddedShuffles(ShuffleVectorInst &Shuf) {
   return new ShuffleVectorInst(X, Y, NewMask);
 }
 
-// Splatting the first element of the result of a BinOp, where any of the
-// BinOp's operands are the result of a first element splat can be simplified to
-// splatting the first element of the result of the BinOp
-Instruction *InstCombinerImpl::simplifyBinOpSplats(ShuffleVectorInst &SVI) {
-  if (!SVI.isZeroEltSplat())
-    return nullptr;
-
-  Value *Op0 = SVI.getOperand(0);
-  Value *X, *Y;
-  if (!match(Op0, m_BinOp(m_Shuffle(m_Value(X), m_Undef(), m_ZeroMask()),
-                          m_Value(Y))) &&
-      !match(Op0, m_BinOp(m_Value(X),
-                          m_Shuffle(m_Value(Y), m_Undef(), m_ZeroMask()))))
-    return nullptr;
-  if (X->getType() != Y->getType())
-    return nullptr;
-
-  auto *BinOp = cast<BinaryOperator>(Op0);
-  if (!isSafeToSpeculativelyExecute(BinOp))
-    return nullptr;
-
-  Value *NewBO = Builder.CreateBinOp(BinOp->getOpcode(), X, Y);
-  if (auto NewBOI = dyn_cast<Instruction>(NewBO))
-    NewBOI->copyIRFlags(BinOp);
-
-  return new ShuffleVectorInst(NewBO, SVI.getShuffleMask());
-}
-
 Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
   Value *LHS = SVI.getOperand(0);
   Value *RHS = SVI.getOperand(1);
@@ -2634,9 +2606,7 @@ Instruction *InstCombinerImpl::visitShuffleVectorInst(ShuffleVectorInst &SVI) {
                                           SVI.getType(), ShufQuery))
     return replaceInstUsesWith(SVI, V);
 
-  if (Instruction *I = simplifyBinOpSplats(SVI))
-    return I;
-
+  // Bail out for scalable vectors
   if (isa<ScalableVectorType>(LHS->getType()))
     return nullptr;
 

diff  --git a/llvm/test/Transforms/InstCombine/shuffle-binop.ll b/llvm/test/Transforms/InstCombine/shuffle-binop.ll
index c26c293c695af..fe2d1af5a04f3 100644
--- a/llvm/test/Transforms/InstCombine/shuffle-binop.ll
+++ b/llvm/test/Transforms/InstCombine/shuffle-binop.ll
@@ -50,13 +50,13 @@ define <4 x i8> @splat_binop_splat_x(<4 x i8> %x, <4 x i8> %y) {
 ; CHECK-LABEL: @splat_binop_splat_x(
 ; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer
 ; CHECK-NEXT:    call void @use(<4 x i8> [[XSPLAT]])
-; CHECK-NEXT:    [[TMP1:%.*]] = add nsw <4 x i8> [[X]], [[Y:%.*]]
-; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[TMP1]], <4 x i8> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[B:%.*]] = add <4 x i8> [[XSPLAT]], [[Y:%.*]]
+; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[B]], <4 x i8> poison, <4 x i32> zeroinitializer
 ; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]
 ;
   %xsplat = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> zeroinitializer
   call void @use(<4 x i8> %xsplat)
-  %b = add nsw <4 x i8> %xsplat, %y
+  %b = add <4 x i8> %xsplat, %y
   %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> zeroinitializer
   ret <4 x i8> %bsplat
 }
@@ -65,14 +65,14 @@ define <4 x i8> @splat_binop_splat_y(<4 x i8> %x, <4 x i8> %y) {
 ; CHECK-LABEL: @splat_binop_splat_y(
 ; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <4 x i8> [[Y:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer
 ; CHECK-NEXT:    call void @use(<4 x i8> [[YSPLAT]])
-; CHECK-NEXT:    [[TMP1:%.*]] = sub <4 x i8> [[X:%.*]], [[Y]]
-; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[TMP1]], <4 x i8> poison, <4 x i32> <i32 undef, i32 0, i32 0, i32 0>
+; CHECK-NEXT:    [[B:%.*]] = sub <4 x i8> [[X:%.*]], [[YSPLAT]]
+; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[B]], <4 x i8> poison, <4 x i32> zeroinitializer
 ; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]
 ;
   %ysplat = shufflevector <4 x i8> %y, <4 x i8> poison, <4 x i32> zeroinitializer
   call void @use(<4 x i8> %ysplat)
   %b = sub <4 x i8> %x, %ysplat
-  %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32><i32 poison, i32 0, i32 0, i32 0>
+  %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> zeroinitializer
   ret <4 x i8> %bsplat
 }
 
@@ -82,40 +82,21 @@ define <4 x i8> @splat_binop_splat_x_splat_y(<4 x i8> %x, <4 x i8> %y) {
 ; CHECK-NEXT:    call void @use(<4 x i8> [[XSPLAT]])
 ; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <4 x i8> [[Y:%.*]], <4 x i8> poison, <4 x i32> zeroinitializer
 ; CHECK-NEXT:    call void @use(<4 x i8> [[YSPLAT]])
-; CHECK-NEXT:    [[TMP1:%.*]] = mul nuw <4 x i8> [[Y]], [[X]]
-; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[TMP1]], <4 x i8> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[B:%.*]] = mul <4 x i8> [[XSPLAT]], [[YSPLAT]]
+; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x i8> [[B]], <4 x i8> poison, <4 x i32> zeroinitializer
 ; CHECK-NEXT:    ret <4 x i8> [[BSPLAT]]
 ;
   %xsplat = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> zeroinitializer
   call void @use(<4 x i8> %xsplat)
   %ysplat = shufflevector <4 x i8> %y, <4 x i8> poison, <4 x i32> zeroinitializer
   call void @use(<4 x i8> %ysplat)
-  %b = mul nuw <4 x i8> %xsplat, %ysplat
+  %b = mul <4 x i8> %xsplat, %ysplat
   %bsplat = shufflevector <4 x i8> %b, <4 x i8> poison, <4 x i32> zeroinitializer
   ret <4 x i8> %bsplat
 }
 
-define <4 x float> @splat_binop_splat_x_splat_y_fmath_flags(<4 x float> %x, <4 x float> %y) {
-; CHECK-LABEL: @splat_binop_splat_x_splat_y_fmath_flags(
-; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> poison, <4 x i32> zeroinitializer
-; CHECK-NEXT:    call void @use(<4 x float> [[XSPLAT]])
-; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <4 x float> [[Y:%.*]], <4 x float> poison, <4 x i32> zeroinitializer
-; CHECK-NEXT:    call void @use(<4 x float> [[YSPLAT]])
-; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast <4 x float> [[Y]], [[X]]
-; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> zeroinitializer
-; CHECK-NEXT:    ret <4 x float> [[BSPLAT]]
-;
-  %xsplat = shufflevector <4 x float> %x, <4 x float> poison, <4 x i32> zeroinitializer
-  call void @use(<4 x float> %xsplat)
-  %ysplat = shufflevector <4 x float> %y, <4 x float> poison, <4 x i32> zeroinitializer
-  call void @use(<4 x float> %ysplat)
-  %b = fmul fast <4 x float> %xsplat, %ysplat
-  %bsplat = shufflevector <4 x float> %b, <4 x float> poison, <4 x i32> zeroinitializer
-  ret <4 x float> %bsplat
-}
-
-define <vscale x 4 x i32> @vscale_splat_udiv_splat_x(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {
-; CHECK-LABEL: @vscale_splat_udiv_splat_x(
+define <vscale x 4 x i32> @vscale_splat_binop_splat_x(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {
+; CHECK-LABEL: @vscale_splat_binop_splat_x(
 ; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[X:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
 ; CHECK-NEXT:    [[B:%.*]] = udiv <vscale x 4 x i32> [[XSPLAT]], [[Y:%.*]]
 ; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
@@ -127,19 +108,6 @@ define <vscale x 4 x i32> @vscale_splat_udiv_splat_x(<vscale x 4 x i32> %x, <vsc
   ret <vscale x 4 x i32> %bsplat
 }
 
-define <vscale x 4 x i32> @vscale_splat_urem_splat_x(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {
-; CHECK-LABEL: @vscale_splat_urem_splat_x(
-; CHECK-NEXT:    [[XSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[X:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
-; CHECK-NEXT:    [[B:%.*]] = urem <vscale x 4 x i32> [[XSPLAT]], [[Y:%.*]]
-; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
-; CHECK-NEXT:    ret <vscale x 4 x i32> [[BSPLAT]]
-;
-  %xsplat = shufflevector <vscale x 4 x i32> %x, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
-  %b = urem <vscale x 4 x i32> %xsplat, %y
-  %bsplat = shufflevector <vscale x 4 x i32> %b, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
-  ret <vscale x 4 x i32> %bsplat
-}
-
 define <vscale x 4 x i32> @vscale_splat_binop_splat_y(<vscale x 4 x i32> %x, <vscale x 4 x i32> %y) {
 ; CHECK-LABEL: @vscale_splat_binop_splat_y(
 ; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[Y:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
@@ -172,8 +140,8 @@ define <vscale x 4 x i32> @vscale_splat_binop_splat_x_splat_y_calls(<vscale x 4
 ; CHECK-NEXT:    call void @use_v(<vscale x 4 x i32> [[XSPLAT]])
 ; CHECK-NEXT:    [[YSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[Y:%.*]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
 ; CHECK-NEXT:    call void @use_v(<vscale x 4 x i32> [[YSPLAT]])
-; CHECK-NEXT:    [[TMP1:%.*]] = lshr <vscale x 4 x i32> [[X]], [[Y]]
-; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[TMP1]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[B:%.*]] = lshr <vscale x 4 x i32> [[XSPLAT]], [[YSPLAT]]
+; CHECK-NEXT:    [[BSPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[B]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
 ; CHECK-NEXT:    ret <vscale x 4 x i32> [[BSPLAT]]
 ;
   %xsplat = shufflevector <vscale x 4 x i32> %x, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
@@ -186,4 +154,4 @@ define <vscale x 4 x i32> @vscale_splat_binop_splat_x_splat_y_calls(<vscale x 4
 }
 
 declare void @use(<4 x i8>)
-declare void @use_v(<vscale x 4 x i32>)
+declare void @use_v(<vscale x 4 x i32>)
\ No newline at end of file

diff  --git a/llvm/test/Transforms/VectorCombine/AArch64/insert-shuffle-binop.ll b/llvm/test/Transforms/VectorCombine/AArch64/insert-shuffle-binop.ll
new file mode 100644
index 0000000000000..c75f53bc68583
--- /dev/null
+++ b/llvm/test/Transforms/VectorCombine/AArch64/insert-shuffle-binop.ll
@@ -0,0 +1,216 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes='vector-combine' -S %s | FileCheck %s
+
+target triple = "aarch64-none-eabi"
+
+define <vscale x 4 x float> @fadd_vscale_insertelt_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fadd_vscale_insertelt_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fadd fast <vscale x 4 x float> [[BROADCAST_SPLATINSERT2]], [[BROADCAST_SPLAT]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <vscale x 4 x float> [[R]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <vscale x 4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <vscale x 4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <vscale x 4 x float> %broadcast.splatinsert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <vscale x 4 x float> poison, float %1, i64 0
+  %r = fadd fast <vscale x 4 x float> %broadcast.splatinsert2, %broadcast.splat
+  %3 = shufflevector <vscale x 4 x float> %r, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  ret <vscale x 4 x float> %3
+}
+
+define <4 x float> @fadd_fixed_insertelt_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fadd_fixed_insertelt_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fadd fast <4 x float> [[BROADCAST_SPLATINSERT2]], [[BROADCAST_SPLAT]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x float> [[R]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <4 x float> poison, float %1, i64 0
+  %r = fadd fast <4 x float> %broadcast.splatinsert2, %broadcast.splat
+  %3 = shufflevector <4 x float> %r, <4 x float> poison, <4 x i32> zeroinitializer
+  ret <4 x float> %3
+}
+
+define <vscale x 4 x float> @fsub_vscale_insertelt_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fsub_vscale_insertelt_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fsub fast <vscale x 4 x float> [[BROADCAST_SPLATINSERT2]], [[BROADCAST_SPLAT]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <vscale x 4 x float> [[R]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <vscale x 4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <vscale x 4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <vscale x 4 x float> %broadcast.splatinsert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <vscale x 4 x float> poison, float %1, i64 0
+  %r = fsub fast <vscale x 4 x float> %broadcast.splatinsert2, %broadcast.splat
+  %3 = shufflevector <vscale x 4 x float> %r, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  ret <vscale x 4 x float> %3
+}
+
+define <4 x float> @fsub_fixed_insertelt_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fsub_fixed_insertelt_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fsub fast <4 x float> [[BROADCAST_SPLATINSERT2]], [[BROADCAST_SPLAT]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x float> [[R]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <4 x float> poison, float %1, i64 0
+  %r = fsub fast <4 x float> %broadcast.splatinsert2, %broadcast.splat
+  %3 = shufflevector <4 x float> %r, <4 x float> poison, <4 x i32> zeroinitializer
+  ret <4 x float> %3
+}
+
+define <vscale x 4 x float> @fadd_vscale_shuffle_insert_a_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fadd_vscale_shuffle_insert_a_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fadd fast <vscale x 4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLATINSERT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <vscale x 4 x float> [[R]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <vscale x 4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <vscale x 4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <vscale x 4 x float> %broadcast.splatinsert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <vscale x 4 x float> poison, float %1, i64 0
+  %r = fadd fast <vscale x 4 x float> %broadcast.splat, %broadcast.splatinsert2
+  %3 = shufflevector <vscale x 4 x float> %r, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  ret <vscale x 4 x float> %3
+}
+
+define <4 x float> @fadd_fixed_shuffle_insert_a_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fadd_fixed_shuffle_insert_a_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fadd fast <4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLATINSERT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x float> [[R]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <4 x float> poison, float %1, i64 0
+  %r = fadd fast <4 x float> %broadcast.splat, %broadcast.splatinsert2
+  %3 = shufflevector <4 x float> %r, <4 x float> poison, <4 x i32> zeroinitializer
+  ret <4 x float> %3
+}
+
+define <vscale x 4 x float> @fsub_vscale_shuffle_insert_a_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fsub_vscale_shuffle_insert_a_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fsub fast <vscale x 4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLATINSERT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <vscale x 4 x float> [[R]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <vscale x 4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <vscale x 4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <vscale x 4 x float> %broadcast.splatinsert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <vscale x 4 x float> poison, float %1, i64 0
+  %r = fsub fast <vscale x 4 x float> %broadcast.splat, %broadcast.splatinsert2
+  %3 = shufflevector <vscale x 4 x float> %r, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  ret <vscale x 4 x float> %3
+}
+
+define <4 x float> @fsub_fixed_shuffle_insert_a_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fsub_fixed_shuffle_insert_a_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[R:%.*]] = fsub fast <4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLATINSERT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x float> [[R]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <4 x float> poison, float %1, i64 0
+  %r = fsub fast <4 x float> %broadcast.splat, %broadcast.splatinsert2
+  %3 = shufflevector <4 x float> %r, <4 x float> poison, <4 x i32> zeroinitializer
+  ret <4 x float> %3
+}
+
+define <vscale x 4 x float> @fadd_vscale_shuffle_insert_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fadd_vscale_shuffle_insert_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT2:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT2]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[R:%.*]] = fadd fast <vscale x 4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLAT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <vscale x 4 x float> [[R]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <vscale x 4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <vscale x 4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <vscale x 4 x float> %broadcast.splatinsert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <vscale x 4 x float> poison, float %1, i64 0
+  %broadcast.splat2 = shufflevector <vscale x 4 x float> %broadcast.splatinsert2, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %r = fadd fast <vscale x 4 x float> %broadcast.splat, %broadcast.splat2
+  %3 = shufflevector <vscale x 4 x float> %r, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  ret <vscale x 4 x float> %3
+}
+
+define <4 x float> @fadd_fixed_shuffle_insert_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fadd_fixed_shuffle_insert_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT2:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT2]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[R:%.*]] = fadd fast <4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLAT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x float> [[R]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <4 x float> poison, float %1, i64 0
+  %broadcast.splat2 = shufflevector <4 x float> %broadcast.splatinsert2, <4 x float> poison, <4 x i32> zeroinitializer
+  %r = fadd fast <4 x float> %broadcast.splat, %broadcast.splat2
+  %3 = shufflevector <4 x float> %r, <4 x float> poison, <4 x i32> zeroinitializer
+  ret <4 x float> %3
+}
+
+define <vscale x 4 x float> @fsub_vscale_shuffle_insert_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fsub_vscale_shuffle_insert_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <vscale x 4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT2:%.*]] = shufflevector <vscale x 4 x float> [[BROADCAST_SPLATINSERT2]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    [[R:%.*]] = fsub fast <vscale x 4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLAT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <vscale x 4 x float> [[R]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <vscale x 4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <vscale x 4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <vscale x 4 x float> %broadcast.splatinsert, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <vscale x 4 x float> poison, float %1, i64 0
+  %broadcast.splat2 = shufflevector <vscale x 4 x float> %broadcast.splatinsert2, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  %r = fsub fast <vscale x 4 x float> %broadcast.splat, %broadcast.splat2
+  %3 = shufflevector <vscale x 4 x float> %r, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+  ret <vscale x 4 x float> %3
+}
+
+define <4 x float> @fsub_fixed_shuffle_insert_a_shuffle_insert_b(float %0, float %1) {
+; CHECK-LABEL: @fsub_fixed_shuffle_insert_a_shuffle_insert_b(
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x float> poison, float [[TMP0:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[BROADCAST_SPLATINSERT2:%.*]] = insertelement <4 x float> poison, float [[TMP1:%.*]], i64 0
+; CHECK-NEXT:    [[BROADCAST_SPLAT2:%.*]] = shufflevector <4 x float> [[BROADCAST_SPLATINSERT2]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[R:%.*]] = fsub fast <4 x float> [[BROADCAST_SPLAT]], [[BROADCAST_SPLAT2]]
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x float> [[R]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    ret <4 x float> [[TMP3]]
+;
+  %broadcast.splatinsert = insertelement <4 x float> poison, float %0, i64 0
+  %broadcast.splat = shufflevector <4 x float> %broadcast.splatinsert, <4 x float> poison, <4 x i32> zeroinitializer
+  %broadcast.splatinsert2 = insertelement <4 x float> poison, float %1, i64 0
+  %broadcast.splat2 = shufflevector <4 x float> %broadcast.splatinsert2, <4 x float> poison, <4 x i32> zeroinitializer
+  %r = fsub fast <4 x float> %broadcast.splat, %broadcast.splat2
+  %3 = shufflevector <4 x float> %r, <4 x float> poison, <4 x i32> zeroinitializer
+  ret <4 x float> %3
+}


        


More information about the llvm-commits mailing list