[llvm] Reland partial vector reduce (PR #197659)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 14 04:54:51 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-vectorizers

Author: AbdallahRashed (AbdallahRashed)

<details>
<summary>Changes</summary>



---

Patch is 60.91 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/197659.diff


7 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/VectorCombine.cpp (+34-6) 
- (modified) llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smax.ll (+8-32) 
- (modified) llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smin.ll (+8-32) 
- (modified) llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-umax.ll (+8-32) 
- (modified) llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-umin.ll (+8-32) 
- (added) llvm/test/Transforms/VectorCombine/AArch64/partial-reduce-crash.ll (+25) 
- (modified) llvm/test/Transforms/VectorCombine/fold-shuffle-chains-to-reduce.ll (+50) 


``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 5ba344ea9a808..53017660351ce 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -3995,6 +3995,8 @@ bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
 
   InstWorklist.push(VecOpEE);
 
+  bool IsPartialReduction = false;
+
   while (!InstWorklist.empty()) {
     Value *CI = InstWorklist.front();
     InstWorklist.pop();
@@ -4125,12 +4127,19 @@ bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
 
       ShouldBeCallOrBinInst ^= 1;
     } else {
+      // Check if this is a partial reduction - the chain ended because
+      // the source vector is not a recognized op/shuffle.
+      if (ShouldBeCallOrBinInst && VisitedCnt >= 1 && CI == PrevVecV[0]) {
+        IsPartialReduction = true;
+        break;
+      }
       return false;
     }
   }
 
-  // Pattern should end with a shuffle op.
-  if (ShouldBeCallOrBinInst)
+  // Full reduction pattern should end with a shuffle op.
+  // Partial reduction ends when the source vector is reached.
+  if (ShouldBeCallOrBinInst && !IsPartialReduction)
     return false;
 
   assert(VecSize != -1 && "Expected Match for Vector Size");
@@ -4147,14 +4156,33 @@ bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
   if (!ReducedOp)
     return false;
 
-  IntrinsicCostAttributes ICA(ReducedOp, FinalVecVTy, {FinalVecV});
-  InstructionCost NewCost = TTI.getIntrinsicInstrCost(ICA, CostKind);
+  InstructionCost NewCost = 0;
+  FixedVectorType *ReduceVecTy = FinalVecVTy;
+  SmallVector<int> ExtractMask;
+
+  if (IsPartialReduction) {
+    unsigned SubVecSize = ShuffleMaskHalf;
+    ReduceVecTy = FixedVectorType::get(FVT->getElementType(), SubVecSize);
+    ExtractMask.resize(SubVecSize);
+    std::iota(ExtractMask.begin(), ExtractMask.end(), 0);
+    NewCost +=
+        TTI.getShuffleCost(TargetTransformInfo::SK_ExtractSubvector,
+                           ReduceVecTy, FinalVecVTy, ExtractMask, CostKind, 0,
+                           ReduceVecTy);
+  }
+
+  IntrinsicCostAttributes ICA(ReducedOp, ReduceVecTy, {ReduceVecTy});
+  NewCost += TTI.getIntrinsicInstrCost(ICA, CostKind);
 
   if (NewCost >= OrigCost)
     return false;
 
-  auto *ReducedResult =
-      Builder.CreateIntrinsic(ReducedOp, {FinalVecV->getType()}, {FinalVecV});
+  Value *ReduceInput = FinalVecV;
+  if (IsPartialReduction)
+    ReduceInput = Builder.CreateShuffleVector(FinalVecV, ExtractMask);
+
+  auto *ReducedResult = Builder.CreateIntrinsic(
+      ReducedOp, {ReduceInput->getType()}, {ReduceInput});
   replaceValue(I, *ReducedResult);
 
   return true;
diff --git a/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smax.ll b/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smax.ll
index 85186dba0891f..ec8cd82b96a37 100644
--- a/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smax.ll
+++ b/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smax.ll
@@ -314,13 +314,8 @@ define i8 @test_reduce_v64i8(<64 x i8> %a0) {
 
 define i16 @test_reduce_v16i16_v8i16(<16 x i16> %a0) {
 ; CHECK-LABEL: @test_reduce_v16i16_v8i16(
-; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <16 x i16> [[A0:%.*]], <16 x i16> poison, <16 x i32> <i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP2:%.*]] = tail call <16 x i16> @llvm.smax.v16i16(<16 x i16> [[A0]], <16 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <16 x i16> [[TMP2]], <16 x i16> poison, <16 x i32> <i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP4:%.*]] = tail call <16 x i16> @llvm.smax.v16i16(<16 x i16> [[TMP2]], <16 x i16> [[TMP3]])
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i16> [[TMP4]], <16 x i16> poison, <16 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP6:%.*]] = tail call <16 x i16> @llvm.smax.v16i16(<16 x i16> [[TMP4]], <16 x i16> [[TMP5]])
-; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <16 x i16> [[TMP6]], i64 0
+; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <16 x i16> [[A0:%.*]], <16 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT:    [[TMP10:%.*]] = tail call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[TMP1]])
 ; CHECK-NEXT:    ret i16 [[TMP10]]
 ;
   %1  = shufflevector <16 x i16> %a0, <16 x i16> undef, <16 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
@@ -338,13 +333,8 @@ define i16 @test_reduce_v16i16_v8i16(<16 x i16> %a0) {
 
 define i16 @test_reduce_v32i16_v8i16(<32 x i16> %a0) {
 ; CHECK-LABEL: @test_reduce_v32i16_v8i16(
-; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <32 x i16> [[A0:%.*]], <32 x i16> poison, <32 x i32> <i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP2:%.*]] = tail call <32 x i16> @llvm.smax.v32i16(<32 x i16> [[A0]], <32 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <32 x i16> [[TMP2]], <32 x i16> poison, <32 x i32> <i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP4:%.*]] = tail call <32 x i16> @llvm.smax.v32i16(<32 x i16> [[TMP2]], <32 x i16> [[TMP3]])
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <32 x i16> [[TMP4]], <32 x i16> poison, <32 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP6:%.*]] = tail call <32 x i16> @llvm.smax.v32i16(<32 x i16> [[TMP4]], <32 x i16> [[TMP5]])
-; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <32 x i16> [[TMP6]], i64 0
+; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <32 x i16> [[A0:%.*]], <32 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT:    [[TMP10:%.*]] = tail call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> [[TMP1]])
 ; CHECK-NEXT:    ret i16 [[TMP10]]
 ;
   %1  = shufflevector <32 x i16> %a0, <32 x i16> undef, <32 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
@@ -362,15 +352,8 @@ define i16 @test_reduce_v32i16_v8i16(<32 x i16> %a0) {
 
 define i8 @test_reduce_v32i8_v16i8(<32 x i8> %a0) {
 ; CHECK-LABEL: @test_reduce_v32i8_v16i8(
-; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <32 x i8> [[A0:%.*]], <32 x i8> poison, <32 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP2:%.*]] = tail call <32 x i8> @llvm.smax.v32i8(<32 x i8> [[A0]], <32 x i8> [[TMP1]])
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <32 x i8> [[TMP2]], <32 x i8> poison, <32 x i32> <i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP4:%.*]] = tail call <32 x i8> @llvm.smax.v32i8(<32 x i8> [[TMP2]], <32 x i8> [[TMP3]])
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <32 x i8> [[TMP4]], <32 x i8> poison, <32 x i32> <i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP6:%.*]] = tail call <32 x i8> @llvm.smax.v32i8(<32 x i8> [[TMP4]], <32 x i8> [[TMP5]])
-; CHECK-NEXT:    [[TMP7:%.*]] = shufflevector <32 x i8> [[TMP6]], <32 x i8> poison, <32 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP8:%.*]] = tail call <32 x i8> @llvm.smax.v32i8(<32 x i8> [[TMP6]], <32 x i8> [[TMP7]])
-; CHECK-NEXT:    [[TMP13:%.*]] = extractelement <32 x i8> [[TMP8]], i64 0
+; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <32 x i8> [[A0:%.*]], <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+; CHECK-NEXT:    [[TMP13:%.*]] = tail call i8 @llvm.vector.reduce.smax.v16i8(<16 x i8> [[TMP1]])
 ; CHECK-NEXT:    ret i8 [[TMP13]]
 ;
   %1  = shufflevector <32 x i8> %a0, <32 x i8> undef, <32 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
@@ -391,15 +374,8 @@ define i8 @test_reduce_v32i8_v16i8(<32 x i8> %a0) {
 
 define i8 @test_reduce_v64i8_v16i8(<64 x i8> %a0) {
 ; CHECK-LABEL: @test_reduce_v64i8_v16i8(
-; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <64 x i8> [[A0:%.*]], <64 x i8> poison, <64 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP2:%.*]] = tail call <64 x i8> @llvm.smax.v64i8(<64 x i8> [[A0]], <64 x i8> [[TMP1]])
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <64 x i8> [[TMP2]], <64 x i8> poison, <64 x i32> <i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP4:%.*]] = tail call <64 x i8> @llvm.smax.v64i8(<64 x i8> [[TMP2]], <64 x i8> [[TMP3]])
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <64 x i8> [[TMP4]], <64 x i8> poison, <64 x i32> <i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP6:%.*]] = tail call <64 x i8> @llvm.smax.v64i8(<64 x i8> [[TMP4]], <64 x i8> [[TMP5]])
-; CHECK-NEXT:    [[TMP7:%.*]] = shufflevector <64 x i8> [[TMP6]], <64 x i8> poison, <64 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP8:%.*]] = tail call <64 x i8> @llvm.smax.v64i8(<64 x i8> [[TMP6]], <64 x i8> [[TMP7]])
-; CHECK-NEXT:    [[TMP13:%.*]] = extractelement <64 x i8> [[TMP8]], i64 0
+; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <64 x i8> [[A0:%.*]], <64 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
+; CHECK-NEXT:    [[TMP13:%.*]] = tail call i8 @llvm.vector.reduce.smax.v16i8(<16 x i8> [[TMP1]])
 ; CHECK-NEXT:    ret i8 [[TMP13]]
 ;
   %1  = shufflevector <64 x i8> %a0, <64 x i8> undef, <64 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
diff --git a/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smin.ll b/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smin.ll
index 80c2929b5d5cf..650947d240ace 100644
--- a/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smin.ll
+++ b/llvm/test/Transforms/PhaseOrdering/X86/horizontal-reduce-smin.ll
@@ -314,13 +314,8 @@ define i8 @test_reduce_v64i8(<64 x i8> %a0) {
 
 define i16 @test_reduce_v16i16_v8i16(<16 x i16> %a0) {
 ; CHECK-LABEL: @test_reduce_v16i16_v8i16(
-; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <16 x i16> [[A0:%.*]], <16 x i16> poison, <16 x i32> <i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP2:%.*]] = tail call <16 x i16> @llvm.smin.v16i16(<16 x i16> [[A0]], <16 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <16 x i16> [[TMP2]], <16 x i16> poison, <16 x i32> <i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP4:%.*]] = tail call <16 x i16> @llvm.smin.v16i16(<16 x i16> [[TMP2]], <16 x i16> [[TMP3]])
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <16 x i16> [[TMP4]], <16 x i16> poison, <16 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP6:%.*]] = tail call <16 x i16> @llvm.smin.v16i16(<16 x i16> [[TMP4]], <16 x i16> [[TMP5]])
-; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <16 x i16> [[TMP6]], i64 0
+; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <16 x i16> [[A0:%.*]], <16 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT:    [[TMP10:%.*]] = tail call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> [[TMP1]])
 ; CHECK-NEXT:    ret i16 [[TMP10]]
 ;
   %1  = shufflevector <16 x i16> %a0, <16 x i16> undef, <16 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
@@ -338,13 +333,8 @@ define i16 @test_reduce_v16i16_v8i16(<16 x i16> %a0) {
 
 define i16 @test_reduce_v32i16_v8i16(<32 x i16> %a0) {
 ; CHECK-LABEL: @test_reduce_v32i16_v8i16(
-; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <32 x i16> [[A0:%.*]], <32 x i16> poison, <32 x i32> <i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP2:%.*]] = tail call <32 x i16> @llvm.smin.v32i16(<32 x i16> [[A0]], <32 x i16> [[TMP1]])
-; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <32 x i16> [[TMP2]], <32 x i16> poison, <32 x i32> <i32 2, i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP4:%.*]] = tail call <32 x i16> @llvm.smin.v32i16(<32 x i16> [[TMP2]], <32 x i16> [[TMP3]])
-; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <32 x i16> [[TMP4]], <32 x i16> poison, <32 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
-; CHECK-NEXT:    [[TMP6:%.*]] = tail call <32 x i16> @llvm.smin.v32i16(<32 x i16> [[TMP4]], <32 x i16> [[TMP5]])
-; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <32 x i16> [[TMP6]], i64 0
+; CHECK-NEXT:    [[TMP1:%....
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/197659


More information about the llvm-commits mailing list