[llvm] [SLP]Vectorize aggregates of bit packs as a single vector (PR #228955)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 16:45:59 PDT 2026


https://github.com/alexey-bataev created https://github.com/llvm/llvm-project/pull/228955

An insertvalue aggregate built of or-packs of zero-extended fields (e.g.
the { i64, i64 } returned for std::array<int16_t, 8>) was vectorized
pack by pack, leaving the vectors half as wide as possible. Vectorize
the fields of all packs as one tree and bitcast the result to the vector
of the packs.

Fixes #48223

Assisted-by: Cursor


>From 2d25480d5fd96d2e22c2a2618bf385cc6c3989e9 Mon Sep 17 00:00:00 2001
From: Alexey Bataev <a.bataev at outlook.com>
Date: Sun, 4 Oct 2026 16:45:47 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 .../Transforms/Vectorize/SLPVectorizer.cpp    | 118 ++++++++++++++++++
 .../SLPVectorizer/SLPReductionUtils.cpp       |  28 +++++
 .../SLPVectorizer/SLPReductionUtils.h         |   9 ++
 .../Transforms/PhaseOrdering/X86/pr48223.ll   |  16 +--
 .../AArch64/bitpacked-aggregate.ll            |  32 ++---
 .../SLPVectorizer/X86/bitpacked-aggregate.ll  | 108 ++++++----------
 .../SLPVectorizer/X86/pr48879-sroa.ll         |  64 ++++------
 7 files changed, 237 insertions(+), 138 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index c105f41bc15ab..9f9445ba3d5a8 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -755,6 +755,15 @@ class slpvectorizer::BoUpSLP {
     return Cnt;
   }
 
+  /// Returns true if the tree gathers any scalars other than constants.
+  bool hasNonConstantGathers() const {
+    return any_of(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
+      return !DeletedNodes.contains(TE.get()) &&
+             (TE->isGather() || TransformedToGatherNodes.contains(TE.get())) &&
+             !allConstant(TE->Scalars);
+    });
+  }
+
   /// Returns the base graph size, before any transformations.
   unsigned getCanonicalGraphSize() const { return BaseGraphSize; }
 
@@ -35269,6 +35278,109 @@ bool SLPVectorizerPass::tryToVectorize(
   return Res;
 }
 
+/// Vectorizes the aggregate \p IVI, built of the packs of the same layout, as
+/// the single vector of all the fields, bitcasted to the vector of the packs.
+/// The packs vectorized alone would leave the vectors narrower than possible.
+static bool vectorizePackedAggregate(InsertValueInst *IVI, BoUpSLP &R,
+                                     TargetTransformInfo &TTI,
+                                     const DataLayout &DL) {
+  if (!ShouldVectorizeHor || SLPReVec || DL.isBigEndian() ||
+      !R.canMapToVector(IVI->getType()))
+    return false;
+  SmallVector<Value *, 16> Packs;
+  SmallVector<Value *, 16> Inserts;
+  if (!findBuildAggregate(IVI, &TTI, Packs, Inserts, R))
+    return false;
+  // The inserts must form the plain chain, which is moved after the vector.
+  BasicBlock *BB = IVI->getParent();
+  if (!all_of(Inserts, [&](Value *V) {
+        auto *Insert = dyn_cast<InsertValueInst>(V);
+        if (!Insert || Insert->getParent() != BB ||
+            (Insert != IVI && !(Insert->hasOneUse() &&
+                                is_contained(Inserts, Insert->user_back()))))
+          return false;
+        Value *Agg = Insert->getAggregateOperand();
+        return !isa<InsertValueInst>(Agg) || is_contained(Inserts, Agg);
+      }))
+    return false;
+
+  SmallVector<Value *> Fields;
+  SmallVector<Instruction *> Chain;
+  for (Value *Pack : Packs) {
+    auto *Root = dyn_cast<Instruction>(Pack);
+    if (!Root || Root->getParent() != BB ||
+        !matchPackedFields(Root, RecursionMaxDepth, Fields, Chain))
+      return false;
+  }
+  // The pack instructions are dropped, so they must be used by the packs only.
+  SmallDenseSet<Value *> IgnoreList;
+  IgnoreList.insert_range(Chain);
+  if (!all_of(Chain, [&](Instruction *I) {
+        return I->getParent() == BB && all_of(I->users(), [&](User *U) {
+                 return IgnoreList.contains(U) || is_contained(Inserts, U);
+               });
+      }))
+    return false;
+  // Merging the loads into the wider load is better done for each pack.
+  if (all_of(Fields, IsaPred<LoadInst>))
+    return false;
+
+  // The fields of different types are not vectorized, the tree is empty.
+  R.buildTree(Fields, IgnoreList);
+  if (R.isTreeTinyAndNotFullyVectorizable(/*ForReduction=*/true))
+    return false;
+  R.transformNodes();
+  // The fields are not demoted, the bitcast depends on their width.
+  InstructionCost TreeCost = R.calculateTreeCostAndTrimNonProfitable(Fields);
+  R.buildExternalUses();
+  // The gathered operands of the fields are unpacked better for each pack. The
+  // packs take the lanes in the order of the fields.
+  if (R.hasNonConstantGathers() ||
+      !all_of(enumerate(Fields), [&](const auto &P) {
+        return R.findRootLaneForValue(P.value()) == P.index();
+      }))
+    return false;
+
+  const TTI::TargetCostKind CostKind = R.getCostKind();
+  const unsigned NumPacks = Packs.size();
+  Type *FieldsTy = getWidenedType(Fields.front()->getType(), Fields.size());
+  Type *PacksTy = getWidenedType(Packs.front()->getType(), NumPacks);
+  InstructionCost PackCost =
+      TTI.getCastInstrCost(Instruction::BitCast, PacksTy, FieldsTy,
+                           TTI::CastContextHint::None, CostKind);
+  PackCost += TTI.getScalarizationOverhead(
+      cast<VectorType>(PacksTy), APInt::getAllOnes(NumPacks),
+      /*Insert=*/false, /*Extract=*/true, CostKind);
+  for (Instruction *I : Chain)
+    PackCost -= TTI.getInstructionCost(I, CostKind);
+  InstructionCost Cost = R.getTreeCost(TreeCost, Fields, PackCost, IVI);
+  LLVM_DEBUG(dbgs() << "SLP: Found cost = " << Cost
+                    << " for packed aggregate\n");
+  if (!Cost.isValid() || Cost >= -SLPCostThreshold)
+    return false;
+
+  Value *Vec = R.vectorizeTree({}, IVI);
+  assert(Vec->getType() == FieldsTy && "Expected the vector of the fields.");
+  IRBuilder<TargetFolder> Builder(IVI->getContext(), TargetFolder(DL));
+  Builder.SetInsertPoint(IVI);
+  Builder.SetCurrentDebugLocation(IVI->getDebugLoc());
+  Value *Packed = Builder.CreateBitCast(Vec, PacksTy);
+  for (auto [Idx, Insert] : enumerate(Inserts))
+    cast<InsertValueInst>(Insert)->setOperand(
+        1, Builder.CreateExtractElement(Packed, Idx));
+  // The inserts may precede the vector, move them after the extracts.
+  InsertValueInst *Next = IVI;
+  while (auto *Prev = dyn_cast<InsertValueInst>(Next->getAggregateOperand())) {
+    if (!is_contained(Inserts, Prev))
+      break;
+    Prev->moveBefore(Next->getIterator());
+    Next = Prev;
+  }
+
+  R.removeInstructionsAndOperands(ArrayRef(Chain), {});
+  return true;
+}
+
 bool SLPVectorizerPass::vectorizeInsertValueInst(InsertValueInst *IVI,
                                                  BasicBlock *BB, BoUpSLP &R,
                                                  bool MaxVFOnly) {
@@ -35857,6 +35969,12 @@ bool SLPVectorizerPass::vectorizeInserts(
   for (auto *I : make_filter_range(reverse(Instructions), [&](auto *I) {
          return !R.isDeleted(I) && !isa<CmpInst>(I);
        })) {
+    // The packs of the aggregate are vectorized together, not each alone.
+    if (auto *IVI = dyn_cast<InsertValueInst>(I);
+        IVI && vectorizePackedAggregate(IVI, R, *TTI, *DL)) {
+      OpsChanged = true;
+      continue;
+    }
     if (auto *LastInsertValue = dyn_cast<InsertValueInst>(I)) {
       OpsChanged |=
           vectorizeInsertValueInst(LastInsertValue, BB, R, /*MaxVFOnly=*/true);
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.cpp
index 4c6bcce49fdc1..e8626c9a00b48 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.cpp
@@ -11,6 +11,7 @@
 #include "SLPCostAnalysis.h"
 #include "SLPUtils.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/Analysis/IVDescriptors.h"
 #include "llvm/Analysis/ValueTracking.h"
@@ -96,6 +97,33 @@ BoolBitmask isBoolBitmaskRdx(
   return NeedMask ? BoolBitmask::NeedMask : BoolBitmask::NoMask;
 }
 
+bool matchPackedFields(Value *V, unsigned MaxDepth,
+                       SmallVectorImpl<Value *> &Fields,
+                       SmallVectorImpl<Instruction *> &Chain) {
+  auto *PackTy = dyn_cast<IntegerType>(V->getType());
+  if (!PackTy)
+    return false;
+  SmallVector<NarrowedLeafInfo> Leaves;
+  collectNarrowedLeaves(V, Instruction::Or, PackTy->getBitWidth(), MaxDepth,
+                        Leaves, Chain);
+  if (Leaves.size() < 2)
+    return false;
+  Type *FieldTy = Leaves.front().V->getType();
+  if (!FieldTy->isIntegerTy() ||
+      PackTy->getBitWidth() != Leaves.size() * FieldTy->getIntegerBitWidth())
+    return false;
+  llvm::sort(Leaves, [](const NarrowedLeafInfo &A, const NarrowedLeafInfo &B) {
+    return A.Shift < B.Shift;
+  });
+  for (const auto &[Pos, L] : enumerate(Leaves))
+    if (L.V->getType() != FieldTy || !L.Mask.isAllOnes() ||
+        L.Shift != Pos * FieldTy->getIntegerBitWidth())
+      return false;
+  append_range(
+      Fields, map_range(Leaves, [](const NarrowedLeafInfo &L) { return L.V; }));
+  return true;
+}
+
 Value *tryEmitBoolReduxBitcastCmp(IRBuilderBase &Builder,
                                   const TargetTransformInfo &TTI,
                                   RecurKind RdxKind, Value *Vec,
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.h b/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.h
index 8ffd6a3b2428f..6e55bfdad861c 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.h
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer/SLPReductionUtils.h
@@ -16,6 +16,7 @@
 #define LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPREDUCTIONUTILS_H
 
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 
 namespace llvm {
@@ -55,6 +56,14 @@ BoolBitmask isBoolBitmaskRdx(
     const SmallDenseMap<Value *, NarrowedLeafInfo> &NarrowedLeafShifts,
     const DataLayout &DL);
 
+/// Matches \p V as the zero-extended fields, placed one after another from the
+/// lowest bit and filling \p V completely. The instructions are looked through
+/// up to \p MaxDepth. Appends the fields in the order of their positions to
+/// \p Fields and the instructions of the pack to \p Chain.
+bool matchPackedFields(Value *V, unsigned MaxDepth,
+                       SmallVectorImpl<Value *> &Fields,
+                       SmallVectorImpl<Instruction *> &Chain);
+
 /// \returns the first operand of \p I that does not match \p Phi. If
 /// the operand is not an instruction, returns nullptr.
 Instruction *getNonPhiOperand(Instruction *I, PHINode *Phi);
diff --git a/llvm/test/Transforms/PhaseOrdering/X86/pr48223.ll b/llvm/test/Transforms/PhaseOrdering/X86/pr48223.ll
index 459c6c5b9ffb3..9cab024d5997c 100644
--- a/llvm/test/Transforms/PhaseOrdering/X86/pr48223.ll
+++ b/llvm/test/Transforms/PhaseOrdering/X86/pr48223.ll
@@ -9,17 +9,13 @@
 define { i64, i64 } @compute_min(ptr noundef nonnull align 2 dereferenceable(16) %x, ptr noundef nonnull align 2 dereferenceable(16) %y) {
 ; CHECK-LABEL: @compute_min(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[PT1_4:%.*]] = getelementptr inbounds nuw i8, ptr [[X:%.*]], i64 8
-; CHECK-NEXT:    [[PT0_4:%.*]] = getelementptr inbounds nuw i8, ptr [[Y:%.*]], i64 8
-; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; CHECK-NEXT:    [[TMP2:%.*]] = tail call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; CHECK-NEXT:    [[TMP2:%.*]] = tail call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP11:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[DOTFCA_0_INSERT:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP5]], 0
-; CHECK-NEXT:    [[TMP6:%.*]] = load <4 x i16>, ptr [[PT0_4]], align 2
-; CHECK-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[PT1_4]], align 2
-; CHECK-NEXT:    [[TMP8:%.*]] = tail call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP6]], <4 x i16> [[TMP7]])
-; CHECK-NEXT:    [[TMP11:%.*]] = bitcast <4 x i16> [[TMP8]] to i64
 ; CHECK-NEXT:    [[DOTFCA_1_INSERT:%.*]] = insertvalue { i64, i64 } [[DOTFCA_0_INSERT]], i64 [[TMP11]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[DOTFCA_1_INSERT]]
 ;
diff --git a/llvm/test/Transforms/SLPVectorizer/AArch64/bitpacked-aggregate.ll b/llvm/test/Transforms/SLPVectorizer/AArch64/bitpacked-aggregate.ll
index ceddd89057dc2..a13c7b6370d27 100644
--- a/llvm/test/Transforms/SLPVectorizer/AArch64/bitpacked-aggregate.ll
+++ b/llvm/test/Transforms/SLPVectorizer/AArch64/bitpacked-aggregate.ll
@@ -6,17 +6,13 @@
 define { i64, i64 } @pack_i16x8(ptr %x, ptr %y) {
 ; CHECK-LABEL: @pack_i16x8(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[X_4_P:%.*]] = getelementptr inbounds i16, ptr [[X:%.*]], i64 4
-; CHECK-NEXT:    [[Y_4_P:%.*]] = getelementptr inbounds i16, ptr [[Y:%.*]], i64 4
-; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP4:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP4]], 0
-; CHECK-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[X_4_P]], align 2
-; CHECK-NEXT:    [[TMP8:%.*]] = load <4 x i16>, ptr [[Y_4_P]], align 2
-; CHECK-NEXT:    [[TMP6:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP7]], <4 x i16> [[TMP8]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP6]] to i64
 ; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue { i64, i64 } [[AGG_0]], i64 [[TMP5]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
 ;
@@ -87,17 +83,13 @@ entry:
 define { i64, i64 } @pack_i8x16(ptr %x, ptr %y) {
 ; CHECK-LABEL: @pack_i8x16(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[X_8_P:%.*]] = getelementptr inbounds i8, ptr [[X:%.*]], i64 8
-; CHECK-NEXT:    [[Y_8_P:%.*]] = getelementptr inbounds i8, ptr [[Y:%.*]], i64 8
-; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i8>, ptr [[X]], align 1
-; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i8>, ptr [[Y]], align 1
-; CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i8> @llvm.smin.v8i8(<8 x i8> [[TMP0]], <8 x i8> [[TMP1]])
-; CHECK-NEXT:    [[TMP4:%.*]] = bitcast <8 x i8> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <16 x i8>, ptr [[X:%.*]], align 1
+; CHECK-NEXT:    [[TMP1:%.*]] = load <16 x i8>, ptr [[Y:%.*]], align 1
+; CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.smin.v16i8(<16 x i8> [[TMP0]], <16 x i8> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP4]], 0
-; CHECK-NEXT:    [[TMP7:%.*]] = load <8 x i8>, ptr [[X_8_P]], align 1
-; CHECK-NEXT:    [[TMP8:%.*]] = load <8 x i8>, ptr [[Y_8_P]], align 1
-; CHECK-NEXT:    [[TMP6:%.*]] = call <8 x i8> @llvm.smin.v8i8(<8 x i8> [[TMP7]], <8 x i8> [[TMP8]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <8 x i8> [[TMP6]] to i64
 ; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue { i64, i64 } [[AGG_0]], i64 [[TMP5]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
 ;
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll b/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll
index 9eb2b060e3781..fe898f71e380e 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll
@@ -6,17 +6,13 @@
 define { i64, i64 } @pack_i16x8(ptr %x, ptr %y) {
 ; CHECK-LABEL: @pack_i16x8(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[X_4_P:%.*]] = getelementptr inbounds i16, ptr [[X:%.*]], i64 4
-; CHECK-NEXT:    [[Y_4_P:%.*]] = getelementptr inbounds i16, ptr [[Y:%.*]], i64 4
-; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP4:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP4]], 0
-; CHECK-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[X_4_P]], align 2
-; CHECK-NEXT:    [[TMP8:%.*]] = load <4 x i16>, ptr [[Y_4_P]], align 2
-; CHECK-NEXT:    [[TMP6:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP7]], <4 x i16> [[TMP8]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP6]] to i64
 ; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue { i64, i64 } [[AGG_0]], i64 [[TMP5]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
 ;
@@ -87,17 +83,13 @@ entry:
 define { i64, i64 } @pack_i8x16(ptr %x, ptr %y) {
 ; CHECK-LABEL: @pack_i8x16(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[X_8_P:%.*]] = getelementptr inbounds i8, ptr [[X:%.*]], i64 8
-; CHECK-NEXT:    [[Y_8_P:%.*]] = getelementptr inbounds i8, ptr [[Y:%.*]], i64 8
-; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i8>, ptr [[X]], align 1
-; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i8>, ptr [[Y]], align 1
-; CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i8> @llvm.umin.v8i8(<8 x i8> [[TMP0]], <8 x i8> [[TMP1]])
-; CHECK-NEXT:    [[TMP4:%.*]] = bitcast <8 x i8> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <16 x i8>, ptr [[X:%.*]], align 1
+; CHECK-NEXT:    [[TMP1:%.*]] = load <16 x i8>, ptr [[Y:%.*]], align 1
+; CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i8> @llvm.umin.v16i8(<16 x i8> [[TMP0]], <16 x i8> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP4]], 0
-; CHECK-NEXT:    [[TMP7:%.*]] = load <8 x i8>, ptr [[X_8_P]], align 1
-; CHECK-NEXT:    [[TMP8:%.*]] = load <8 x i8>, ptr [[Y_8_P]], align 1
-; CHECK-NEXT:    [[TMP6:%.*]] = call <8 x i8> @llvm.umin.v8i8(<8 x i8> [[TMP7]], <8 x i8> [[TMP8]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <8 x i8> [[TMP6]] to i64
 ; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue { i64, i64 } [[AGG_0]], i64 [[TMP5]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
 ;
@@ -232,21 +224,14 @@ entry:
 define { i64, i64 } @pack_i32x4(ptr %x, ptr %y) {
 ; CHECK-LABEL: @pack_i32x4(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[VEC2STRUCT_SLOT:%.*]] = alloca { i64, i64 }, align 16
 ; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[X:%.*]], align 4
 ; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i32>, ptr [[Y:%.*]], align 4
-; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <2 x i32> <i32 0, i32 2>
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <2 x i32> <i32 0, i32 2>
-; CHECK-NEXT:    [[TMP4:%.*]] = call <2 x i32> @llvm.smin.v2i32(<2 x i32> [[TMP2]], <2 x i32> [[TMP3]])
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <2 x i32> <i32 1, i32 3>
-; CHECK-NEXT:    [[TMP6:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <2 x i32> <i32 1, i32 3>
-; CHECK-NEXT:    [[TMP7:%.*]] = call <2 x i32> @llvm.smin.v2i32(<2 x i32> [[TMP5]], <2 x i32> [[TMP6]])
-; CHECK-NEXT:    [[TMP8:%.*]] = zext <2 x i32> [[TMP4]] to <2 x i64>
-; CHECK-NEXT:    [[TMP9:%.*]] = zext <2 x i32> [[TMP7]] to <2 x i64>
-; CHECK-NEXT:    [[TMP10:%.*]] = shl nuw <2 x i64> [[TMP9]], splat (i64 32)
-; CHECK-NEXT:    [[TMP11:%.*]] = or disjoint <2 x i64> [[TMP10]], [[TMP8]]
-; CHECK-NEXT:    store <2 x i64> [[TMP11]], ptr [[VEC2STRUCT_SLOT]], align 16
-; CHECK-NEXT:    [[AGG_1:%.*]] = load { i64, i64 }, ptr [[VEC2STRUCT_SLOT]], align 16
+; CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i32> @llvm.smin.v4i32(<4 x i32> [[TMP0]], <4 x i32> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <4 x i32> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
+; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP4]], 0
+; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue { i64, i64 } [[AGG_0]], i64 [[TMP5]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
 ;
 entry:
@@ -284,17 +269,13 @@ entry:
 define [2 x i64] @pack_array(ptr %x, ptr %y) {
 ; CHECK-LABEL: @pack_array(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[X_4_P:%.*]] = getelementptr inbounds i16, ptr [[X:%.*]], i64 4
-; CHECK-NEXT:    [[Y_4_P:%.*]] = getelementptr inbounds i16, ptr [[Y:%.*]], i64 4
-; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP4:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue [2 x i64] poison, i64 [[TMP4]], 0
-; CHECK-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[X_4_P]], align 2
-; CHECK-NEXT:    [[TMP8:%.*]] = load <4 x i16>, ptr [[Y_4_P]], align 2
-; CHECK-NEXT:    [[TMP6:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP7]], <4 x i16> [[TMP8]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP6]] to i64
 ; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue [2 x i64] [[AGG_0]], i64 [[TMP5]], 1
 ; CHECK-NEXT:    ret [2 x i64] [[AGG_1]]
 ;
@@ -367,17 +348,13 @@ entry:
 define { i64, i64 } @insert_before_fields(ptr %x, ptr %y) {
 ; CHECK-LABEL: @insert_before_fields(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[X:%.*]], align 2
-; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[Y:%.*]], align 2
-; CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP4:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP4]], 0
-; CHECK-NEXT:    [[X_4_P:%.*]] = getelementptr inbounds i16, ptr [[X]], i64 4
-; CHECK-NEXT:    [[Y_4_P:%.*]] = getelementptr inbounds i16, ptr [[Y]], i64 4
-; CHECK-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[X_4_P]], align 2
-; CHECK-NEXT:    [[TMP8:%.*]] = load <4 x i16>, ptr [[Y_4_P]], align 2
-; CHECK-NEXT:    [[TMP6:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP7]], <4 x i16> [[TMP8]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP6]] to i64
 ; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue { i64, i64 } [[AGG_0]], i64 [[TMP5]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
 ;
@@ -450,19 +427,15 @@ entry:
 define { i64, i64 } @field_external_use(ptr %x, ptr %y, ptr %p) {
 ; CHECK-LABEL: @field_external_use(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[X_4_P:%.*]] = getelementptr inbounds i16, ptr [[X:%.*]], i64 4
-; CHECK-NEXT:    [[Y_4_P:%.*]] = getelementptr inbounds i16, ptr [[Y:%.*]], i64 4
-; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; CHECK-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP4:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; CHECK-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; CHECK-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; CHECK-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; CHECK-NEXT:    [[TMP4:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; CHECK-NEXT:    [[AGG_0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP4]], 0
-; CHECK-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[X_4_P]], align 2
-; CHECK-NEXT:    [[TMP8:%.*]] = load <4 x i16>, ptr [[Y_4_P]], align 2
-; CHECK-NEXT:    [[TMP9:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP7]], <4 x i16> [[TMP8]])
-; CHECK-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP9]] to i64
 ; CHECK-NEXT:    [[AGG_1:%.*]] = insertvalue { i64, i64 } [[AGG_0]], i64 [[TMP5]], 1
-; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <4 x i16> [[TMP2]], i64 1
+; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <8 x i16> [[TMP2]], i64 1
 ; CHECK-NEXT:    store i16 [[TMP6]], ptr [[P:%.*]], align 2
 ; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
 ;
@@ -535,10 +508,9 @@ entry:
 define { i64, i64 } @repack(<8 x i16> %v) {
 ; CHECK-LABEL: @repack(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[TMP0:%.*]] = shufflevector <8 x i16> [[V:%.*]], <8 x i16> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
-; CHECK-NEXT:    [[TMP1:%.*]] = bitcast <4 x i16> [[TMP0]] to i64
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <8 x i16> [[V]], <8 x i16> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
-; CHECK-NEXT:    [[TMP2:%.*]] = bitcast <4 x i16> [[TMP3]] to i64
+; CHECK-NEXT:    [[TMP0:%.*]] = bitcast <8 x i16> [[V:%.*]] to <2 x i64>
+; CHECK-NEXT:    [[TMP1:%.*]] = extractelement <2 x i64> [[TMP0]], i64 0
+; CHECK-NEXT:    [[TMP2:%.*]] = extractelement <2 x i64> [[TMP0]], i64 1
 ; CHECK-NEXT:    [[A0:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP1]], 0
 ; CHECK-NEXT:    [[A1:%.*]] = insertvalue { i64, i64 } [[A0]], i64 [[TMP2]], 1
 ; CHECK-NEXT:    ret { i64, i64 } [[A1]]
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/pr48879-sroa.ll b/llvm/test/Transforms/SLPVectorizer/X86/pr48879-sroa.ll
index 8d18fdcecefeb..302c9a42617f4 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/pr48879-sroa.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/pr48879-sroa.ll
@@ -7,65 +7,49 @@
 define { i64, i64 } @compute_min(ptr nocapture noundef nonnull readonly align 2 dereferenceable(16) %x, ptr nocapture noundef nonnull readonly align 2 dereferenceable(16) %y) {
 ; SSE-LABEL: @compute_min(
 ; SSE-NEXT:  entry:
-; SSE-NEXT:    [[ARRAYIDX_I_I_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[X:%.*]], i64 0, i64 4
-; SSE-NEXT:    [[ARRAYIDX_I_I10_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[Y:%.*]], i64 0, i64 4
-; SSE-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; SSE-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; SSE-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; SSE-NEXT:    [[RETVAL_SROA_0_0_INSERT_INSERT:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; SSE-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; SSE-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; SSE-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; SSE-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; SSE-NEXT:    [[RETVAL_SROA_0_0_INSERT_INSERT:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; SSE-NEXT:    [[RETVAL_SROA_5_8_INSERT_INSERT:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; SSE-NEXT:    [[DOTFCA_0_INSERT:%.*]] = insertvalue { i64, i64 } poison, i64 [[RETVAL_SROA_0_0_INSERT_INSERT]], 0
-; SSE-NEXT:    [[TMP6:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I10_4]], align 2
-; SSE-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I_4]], align 2
-; SSE-NEXT:    [[TMP8:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP6]], <4 x i16> [[TMP7]])
-; SSE-NEXT:    [[RETVAL_SROA_5_8_INSERT_INSERT:%.*]] = bitcast <4 x i16> [[TMP8]] to i64
 ; SSE-NEXT:    [[DOTFCA_1_INSERT:%.*]] = insertvalue { i64, i64 } [[DOTFCA_0_INSERT]], i64 [[RETVAL_SROA_5_8_INSERT_INSERT]], 1
 ; SSE-NEXT:    ret { i64, i64 } [[DOTFCA_1_INSERT]]
 ;
 ; AVX-LABEL: @compute_min(
 ; AVX-NEXT:  entry:
-; AVX-NEXT:    [[ARRAYIDX_I_I_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[X:%.*]], i64 0, i64 4
-; AVX-NEXT:    [[ARRAYIDX_I_I10_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[Y:%.*]], i64 0, i64 4
-; AVX-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; AVX-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; AVX-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; AVX-NEXT:    [[TMP24:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; AVX-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; AVX-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; AVX-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; AVX-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; AVX-NEXT:    [[TMP24:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; AVX-NEXT:    [[TMP25:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; AVX-NEXT:    [[DOTFCA_0_INSERT:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP24]], 0
-; AVX-NEXT:    [[TMP6:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I10_4]], align 2
-; AVX-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I_4]], align 2
-; AVX-NEXT:    [[TMP8:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP6]], <4 x i16> [[TMP7]])
-; AVX-NEXT:    [[TMP25:%.*]] = bitcast <4 x i16> [[TMP8]] to i64
 ; AVX-NEXT:    [[DOTFCA_1_INSERT:%.*]] = insertvalue { i64, i64 } [[DOTFCA_0_INSERT]], i64 [[TMP25]], 1
 ; AVX-NEXT:    ret { i64, i64 } [[DOTFCA_1_INSERT]]
 ;
 ; AVX2-LABEL: @compute_min(
 ; AVX2-NEXT:  entry:
-; AVX2-NEXT:    [[ARRAYIDX_I_I_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[X:%.*]], i64 0, i64 4
-; AVX2-NEXT:    [[ARRAYIDX_I_I10_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[Y:%.*]], i64 0, i64 4
-; AVX2-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; AVX2-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; AVX2-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; AVX2-NEXT:    [[TMP7:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; AVX2-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; AVX2-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; AVX2-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; AVX2-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; AVX2-NEXT:    [[TMP7:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; AVX2-NEXT:    [[TMP15:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; AVX2-NEXT:    [[DOTFCA_0_INSERT:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP7]], 0
-; AVX2-NEXT:    [[TMP8:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I10_4]], align 2
-; AVX2-NEXT:    [[TMP9:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I_4]], align 2
-; AVX2-NEXT:    [[TMP10:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP8]], <4 x i16> [[TMP9]])
-; AVX2-NEXT:    [[TMP15:%.*]] = bitcast <4 x i16> [[TMP10]] to i64
 ; AVX2-NEXT:    [[DOTFCA_1_INSERT:%.*]] = insertvalue { i64, i64 } [[DOTFCA_0_INSERT]], i64 [[TMP15]], 1
 ; AVX2-NEXT:    ret { i64, i64 } [[DOTFCA_1_INSERT]]
 ;
 ; AVX512-LABEL: @compute_min(
 ; AVX512-NEXT:  entry:
-; AVX512-NEXT:    [[ARRAYIDX_I_I_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[X:%.*]], i64 0, i64 4
-; AVX512-NEXT:    [[ARRAYIDX_I_I10_4:%.*]] = getelementptr inbounds [8 x i16], ptr [[Y:%.*]], i64 0, i64 4
-; AVX512-NEXT:    [[TMP0:%.*]] = load <4 x i16>, ptr [[Y]], align 2
-; AVX512-NEXT:    [[TMP1:%.*]] = load <4 x i16>, ptr [[X]], align 2
-; AVX512-NEXT:    [[TMP2:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP0]], <4 x i16> [[TMP1]])
-; AVX512-NEXT:    [[TMP5:%.*]] = bitcast <4 x i16> [[TMP2]] to i64
+; AVX512-NEXT:    [[TMP0:%.*]] = load <8 x i16>, ptr [[Y:%.*]], align 2
+; AVX512-NEXT:    [[TMP1:%.*]] = load <8 x i16>, ptr [[X:%.*]], align 2
+; AVX512-NEXT:    [[TMP2:%.*]] = call <8 x i16> @llvm.smin.v8i16(<8 x i16> [[TMP0]], <8 x i16> [[TMP1]])
+; AVX512-NEXT:    [[TMP3:%.*]] = bitcast <8 x i16> [[TMP2]] to <2 x i64>
+; AVX512-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP3]], i64 0
+; AVX512-NEXT:    [[TMP11:%.*]] = extractelement <2 x i64> [[TMP3]], i64 1
 ; AVX512-NEXT:    [[DOTFCA_0_INSERT:%.*]] = insertvalue { i64, i64 } poison, i64 [[TMP5]], 0
-; AVX512-NEXT:    [[TMP6:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I10_4]], align 2
-; AVX512-NEXT:    [[TMP7:%.*]] = load <4 x i16>, ptr [[ARRAYIDX_I_I_4]], align 2
-; AVX512-NEXT:    [[TMP8:%.*]] = call <4 x i16> @llvm.smin.v4i16(<4 x i16> [[TMP6]], <4 x i16> [[TMP7]])
-; AVX512-NEXT:    [[TMP11:%.*]] = bitcast <4 x i16> [[TMP8]] to i64
 ; AVX512-NEXT:    [[DOTFCA_1_INSERT:%.*]] = insertvalue { i64, i64 } [[DOTFCA_0_INSERT]], i64 [[TMP11]], 1
 ; AVX512-NEXT:    ret { i64, i64 } [[DOTFCA_1_INSERT]]
 ;



More information about the llvm-commits mailing list