[llvm] [Scalarizer] Support selecting which opcodes to scalarize (PR #230715)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 17:05:21 PDT 2026


https://github.com/Chengjunp created https://github.com/llvm/llvm-project/pull/230715

Allow users to select which opcodes Scalarizer attempts to scalarize.
Preserve `extractvalue` instructions when their producer calls have not been scalarized to avoid compiler crashes.

>From abce6690399e719b832f095acc0e2ad8cdfeb883 Mon Sep 17 00:00:00 2001
From: chengjunp <chengjunp at nvidia.com>
Date: Sat, 10 Oct 2026 00:02:11 +0000
Subject: [PATCH] [Scalarizer] Support selecting which opcodes to scalarize

Allow users to select which opcodes Scalarizer attempts to scalarize.
Preserve `extractvalue` instructions when their producer calls have not
been scalarized to avoid compiler crashes.
---
 .../llvm/Transforms/Scalar/Scalarizer.h       |   4 +
 llvm/lib/Passes/PassBuilder.cpp               |  13 ++
 llvm/lib/Passes/PassRegistry.def              |   2 +-
 llvm/lib/Transforms/Scalar/Scalarizer.cpp     |  15 +-
 .../Scalarizer/opcode-selective-struct.ll     |  54 +++++++
 .../Transforms/Scalarizer/opcode-selective.ll | 132 ++++++++++++++++++
 .../Scalarizer/pass-param-parse-errors.ll     |   4 +
 7 files changed, 220 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/Transforms/Scalarizer/opcode-selective-struct.ll
 create mode 100644 llvm/test/Transforms/Scalarizer/opcode-selective.ll

diff --git a/llvm/include/llvm/Transforms/Scalar/Scalarizer.h b/llvm/include/llvm/Transforms/Scalar/Scalarizer.h
index 68c350d875ed05..f8794a56885e02 100644
--- a/llvm/include/llvm/Transforms/Scalar/Scalarizer.h
+++ b/llvm/include/llvm/Transforms/Scalar/Scalarizer.h
@@ -18,6 +18,7 @@
 #ifndef LLVM_TRANSFORMS_SCALAR_SCALARIZER_H
 #define LLVM_TRANSFORMS_SCALAR_SCALARIZER_H
 
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/Compiler.h"
 
@@ -46,6 +47,9 @@ struct ScalarizerPassOptions {
   /// This is disabled by default because having separate loads and stores makes
   /// it more likely that the -combiner-alias-analysis limits will be reached.
   bool ScalarizeLoadStore = false;
+
+  /// Only attempt to scalarize these opcodes; an empty list allows all opcodes.
+  SmallVector<unsigned, 4> ScalarizeOpcodes;
 };
 
 class ScalarizerPass : public OptionalPassInfoMixin<ScalarizerPass> {
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 30a6f75a1b86d5..ef438dbf502c51 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -1485,6 +1485,19 @@ Expected<ScalarizerPassOptions> parseScalarizerOptions(StringRef Params) {
       continue;
     }
 
+    if (ParamName.consume_front("opcode=")) {
+      unsigned Opcode = Instruction::TermOpsBegin;
+      for (; Opcode != Instruction::OtherOpsEnd; ++Opcode)
+        if (ParamName == Instruction::getOpcodeName(Opcode))
+          break;
+      if (Opcode == Instruction::OtherOpsEnd)
+        return make_error<StringError>(
+            formatv("invalid Scalarizer opcode '{}'", ParamName).str(),
+            inconvertibleErrorCode());
+      Result.ScalarizeOpcodes.push_back(Opcode);
+      continue;
+    }
+
     bool Enable = !ParamName.consume_front("no-");
     if (ParamName == "load-store")
       Result.ScalarizeLoadStore = Enable;
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index af4ce5029551db..bccd014348d8d0 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -702,7 +702,7 @@ FUNCTION_PASS_WITH_PARAMS(
     [](ScalarizerPassOptions Opts) { return ScalarizerPass(Opts); },
     parseScalarizerOptions,
     "load-store;no-load-store;variable-insert-extract;"
-    "no-variable-insert-extract;min-bits=N;")
+    "no-variable-insert-extract;min-bits=N;opcode=OPCODE;")
 FUNCTION_PASS_WITH_PARAMS(
     "separate-const-offset-from-gep", "SeparateConstOffsetFromGEPPass",
     [](bool LowerGEP) { return SeparateConstOffsetFromGEPPass(LowerGEP); },
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 0e5f2e73c53265..330b2bb8b597c9 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -16,6 +16,7 @@
 
 #include "llvm/Transforms/Scalar/Scalarizer.h"
 #include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
@@ -283,7 +284,8 @@ class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
       : DT(DT), TTI(TTI),
         ScalarizeVariableInsertExtract(Options.ScalarizeVariableInsertExtract),
         ScalarizeLoadStore(Options.ScalarizeLoadStore),
-        ScalarizeMinBits(Options.ScalarizeMinBits) {}
+        ScalarizeMinBits(Options.ScalarizeMinBits),
+        ScalarizeOpcodes(std::move(Options.ScalarizeOpcodes)) {}
 
   bool visit(Function &F);
 
@@ -336,6 +338,7 @@ class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
   const bool ScalarizeVariableInsertExtract;
   const bool ScalarizeLoadStore;
   const unsigned ScalarizeMinBits;
+  const SmallVector<unsigned, 4> ScalarizeOpcodes;
 };
 
 class ScalarizerLegacyPass : public FunctionPass {
@@ -465,7 +468,9 @@ bool ScalarizerVisitor::visit(Function &F) {
   for (BasicBlock *BB : RPOT) {
     for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE;) {
       Instruction *I = &*II;
-      bool Done = InstVisitor::visit(I);
+      bool Done = (ScalarizeOpcodes.empty() ||
+                   is_contained(ScalarizeOpcodes, I->getOpcode())) &&
+                  InstVisitor::visit(I);
       ++II;
       if (Done && I->getType()->isVoidTy()) {
         I->eraseFromParent();
@@ -1144,8 +1149,12 @@ bool ScalarizerVisitor::visitExtractValueInst(ExtractValueInst &EVI) {
     if (!CurrVS || CurrVS->NumPacked != VS->NumPacked)
       return false;
   }
+  // Only reuse fragments from a call that was actually scalarized.
+  auto It = Scattered.find({Op, VS->SplitTy});
+  if (It == Scattered.end())
+    return false;
+  const ValueVector &Op0 = It->second;
   IRBuilder<> Builder(&EVI);
-  Scatterer Op0 = scatter(&EVI, Op, *VS);
   assert(!EVI.getIndices().empty() && "Make sure an index exists");
   // Note for our use case we only care about the top level index.
   unsigned Index = EVI.getIndices()[0];
diff --git a/llvm/test/Transforms/Scalarizer/opcode-selective-struct.ll b/llvm/test/Transforms/Scalarizer/opcode-selective-struct.ll
new file mode 100644
index 00000000000000..07d33150c5cffe
--- /dev/null
+++ b/llvm/test/Transforms/Scalarizer/opcode-selective-struct.ll
@@ -0,0 +1,54 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt %s -passes='scalarizer<opcode=extractvalue>' -S | FileCheck %s --check-prefix=RETAIN
+; RUN: opt %s -passes='scalarizer<opcode=call>' -S | FileCheck %s --check-prefix=CALL
+; RUN: opt %s -passes='scalarizer<opcode=call;opcode=extractvalue>' -S | FileCheck %s --check-prefix=BOTH
+
+; extractvalue needs actual call fragments.
+define <2 x i1> @overflow(<2 x i32> %a, <2 x i32> %b) {
+; RETAIN-LABEL: define <2 x i1> @overflow(
+; RETAIN-SAME: <2 x i32> [[A:%.*]], <2 x i32> [[B:%.*]]) {
+; RETAIN-NEXT:    [[R:%.*]] = call { <2 x i32>, <2 x i1> } @llvm.uadd.with.overflow.v2i32(<2 x i32> [[A]], <2 x i32> [[B]])
+; RETAIN-NEXT:    [[CARRY:%.*]] = extractvalue { <2 x i32>, <2 x i1> } [[R]], 1
+; RETAIN-NEXT:    ret <2 x i1> [[CARRY]]
+;
+; CALL-LABEL: define <2 x i1> @overflow(
+; CALL-SAME: <2 x i32> [[A:%.*]], <2 x i32> [[B:%.*]]) {
+; CALL-NEXT:    [[A_I0:%.*]] = extractelement <2 x i32> [[A]], i64 0
+; CALL-NEXT:    [[B_I0:%.*]] = extractelement <2 x i32> [[B]], i64 0
+; CALL-NEXT:    [[R_I0:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[A_I0]], i32 [[B_I0]])
+; CALL-NEXT:    [[A_I1:%.*]] = extractelement <2 x i32> [[A]], i64 1
+; CALL-NEXT:    [[B_I1:%.*]] = extractelement <2 x i32> [[B]], i64 1
+; CALL-NEXT:    [[R_I1:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[A_I1]], i32 [[B_I1]])
+; CALL-NEXT:    [[R_ELEM0:%.*]] = extractvalue { i32, i1 } [[R_I0]], 0
+; CALL-NEXT:    [[R_ELEM01:%.*]] = extractvalue { i32, i1 } [[R_I1]], 0
+; CALL-NEXT:    [[R_ELEM1:%.*]] = extractvalue { i32, i1 } [[R_I0]], 1
+; CALL-NEXT:    [[R_ELEM12:%.*]] = extractvalue { i32, i1 } [[R_I1]], 1
+; CALL-NEXT:    [[R_UPTO0:%.*]] = insertelement <2 x i32> poison, i32 [[R_ELEM0]], i64 0
+; CALL-NEXT:    [[R_UPTO1:%.*]] = insertelement <2 x i32> [[R_UPTO0]], i32 [[R_ELEM01]], i64 1
+; CALL-NEXT:    [[R_INSERT:%.*]] = insertvalue { <2 x i32>, <2 x i1> } poison, <2 x i32> [[R_UPTO1]], 0
+; CALL-NEXT:    [[R_UPTO03:%.*]] = insertelement <2 x i1> poison, i1 [[R_ELEM1]], i64 0
+; CALL-NEXT:    [[R_UPTO14:%.*]] = insertelement <2 x i1> [[R_UPTO03]], i1 [[R_ELEM12]], i64 1
+; CALL-NEXT:    [[R_INSERT5:%.*]] = insertvalue { <2 x i32>, <2 x i1> } [[R_INSERT]], <2 x i1> [[R_UPTO14]], 1
+; CALL-NEXT:    [[CARRY:%.*]] = extractvalue { <2 x i32>, <2 x i1> } [[R_INSERT5]], 1
+; CALL-NEXT:    ret <2 x i1> [[CARRY]]
+;
+; BOTH-LABEL: define <2 x i1> @overflow(
+; BOTH-SAME: <2 x i32> [[A:%.*]], <2 x i32> [[B:%.*]]) {
+; BOTH-NEXT:    [[A_I0:%.*]] = extractelement <2 x i32> [[A]], i64 0
+; BOTH-NEXT:    [[B_I0:%.*]] = extractelement <2 x i32> [[B]], i64 0
+; BOTH-NEXT:    [[R_I0:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[A_I0]], i32 [[B_I0]])
+; BOTH-NEXT:    [[A_I1:%.*]] = extractelement <2 x i32> [[A]], i64 1
+; BOTH-NEXT:    [[B_I1:%.*]] = extractelement <2 x i32> [[B]], i64 1
+; BOTH-NEXT:    [[R_I1:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[A_I1]], i32 [[B_I1]])
+; BOTH-NEXT:    [[CARRY_ELEM1:%.*]] = extractvalue { i32, i1 } [[R_I0]], 1
+; BOTH-NEXT:    [[CARRY_ELEM11:%.*]] = extractvalue { i32, i1 } [[R_I1]], 1
+; BOTH-NEXT:    [[CARRY_UPTO0:%.*]] = insertelement <2 x i1> poison, i1 [[CARRY_ELEM1]], i64 0
+; BOTH-NEXT:    [[CARRY:%.*]] = insertelement <2 x i1> [[CARRY_UPTO0]], i1 [[CARRY_ELEM11]], i64 1
+; BOTH-NEXT:    ret <2 x i1> [[CARRY]]
+;
+  %r = call { <2 x i32>, <2 x i1> } @llvm.uadd.with.overflow.v2i32(<2 x i32> %a, <2 x i32> %b)
+  %carry = extractvalue { <2 x i32>, <2 x i1> } %r, 1
+  ret <2 x i1> %carry
+}
+
+declare { <2 x i32>, <2 x i1> } @llvm.uadd.with.overflow.v2i32(<2 x i32>, <2 x i32>)
diff --git a/llvm/test/Transforms/Scalarizer/opcode-selective.ll b/llvm/test/Transforms/Scalarizer/opcode-selective.ll
new file mode 100644
index 00000000000000..99ef21039a5133
--- /dev/null
+++ b/llvm/test/Transforms/Scalarizer/opcode-selective.ll
@@ -0,0 +1,132 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt %s -passes='scalarizer<opcode=fdiv;load-store>' -S | FileCheck %s --check-prefix=DIV
+; RUN: opt %s -passes='scalarizer<opcode=fptosi>' -S | FileCheck %s --check-prefix=CAST
+; RUN: opt %s -passes='scalarizer<opcode=fdiv;opcode=fptosi>' -S | FileCheck %s --check-prefix=BOTH
+; RUN: opt %s -passes='scalarizer<opcode=phi;opcode=store;load-store>' -S | FileCheck %s --check-prefix=BOUNDARY
+; RUN: opt %s -passes=scalarizer -S | FileCheck %s --check-prefix=BOTH
+
+; Selected operations can consume and produce retained vectors.
+define void @producer_consumer(ptr %src, ptr %dst, <2 x float> %denom) {
+; DIV-LABEL: define void @producer_consumer(
+; DIV-SAME: ptr [[SRC:%.*]], ptr [[DST:%.*]], <2 x float> [[DENOM:%.*]]) {
+; DIV-NEXT:    [[DENOM_I0:%.*]] = extractelement <2 x float> [[DENOM]], i64 0
+; DIV-NEXT:    [[DENOM_I1:%.*]] = extractelement <2 x float> [[DENOM]], i64 1
+; DIV-NEXT:    [[V:%.*]] = load <2 x float>, ptr [[SRC]], align 8
+; DIV-NEXT:    [[V_I0:%.*]] = extractelement <2 x float> [[V]], i64 0
+; DIV-NEXT:    [[Q_I0:%.*]] = fdiv float [[V_I0]], [[DENOM_I0]]
+; DIV-NEXT:    [[V_I1:%.*]] = extractelement <2 x float> [[V]], i64 1
+; DIV-NEXT:    [[Q_I1:%.*]] = fdiv float [[V_I1]], [[DENOM_I1]]
+; DIV-NEXT:    [[Q_UPTO0:%.*]] = insertelement <2 x float> poison, float [[Q_I0]], i64 0
+; DIV-NEXT:    [[Q:%.*]] = insertelement <2 x float> [[Q_UPTO0]], float [[Q_I1]], i64 1
+; DIV-NEXT:    [[I:%.*]] = fptosi <2 x float> [[Q]] to <2 x i32>
+; DIV-NEXT:    store <2 x i32> [[I]], ptr [[DST]], align 8
+; DIV-NEXT:    ret void
+;
+; CAST-LABEL: define void @producer_consumer(
+; CAST-SAME: ptr [[SRC:%.*]], ptr [[DST:%.*]], <2 x float> [[DENOM:%.*]]) {
+; CAST-NEXT:    [[V1:%.*]] = load <2 x float>, ptr [[SRC]], align 8
+; CAST-NEXT:    [[Q:%.*]] = fdiv <2 x float> [[V1]], [[DENOM]]
+; CAST-NEXT:    [[Q0:%.*]] = extractelement <2 x float> [[Q]], i64 0
+; CAST-NEXT:    [[I0:%.*]] = fptosi float [[Q0]] to i32
+; CAST-NEXT:    [[Q1:%.*]] = extractelement <2 x float> [[Q]], i64 1
+; CAST-NEXT:    [[I1:%.*]] = fptosi float [[Q1]] to i32
+; CAST-NEXT:    [[PART:%.*]] = insertelement <2 x i32> poison, i32 [[I0]], i64 0
+; CAST-NEXT:    [[V:%.*]] = insertelement <2 x i32> [[PART]], i32 [[I1]], i64 1
+; CAST-NEXT:    store <2 x i32> [[V]], ptr [[DST]], align 8
+; CAST-NEXT:    ret void
+;
+; BOTH-LABEL: define void @producer_consumer(
+; BOTH-SAME: ptr [[SRC:%.*]], ptr [[DST:%.*]], <2 x float> [[DENOM:%.*]]) {
+; BOTH-NEXT:    [[DENOM_I0:%.*]] = extractelement <2 x float> [[DENOM]], i64 0
+; BOTH-NEXT:    [[DENOM_I1:%.*]] = extractelement <2 x float> [[DENOM]], i64 1
+; BOTH-NEXT:    [[V:%.*]] = load <2 x float>, ptr [[SRC]], align 8
+; BOTH-NEXT:    [[V_I0:%.*]] = extractelement <2 x float> [[V]], i64 0
+; BOTH-NEXT:    [[Q_I0:%.*]] = fdiv float [[V_I0]], [[DENOM_I0]]
+; BOTH-NEXT:    [[V_I1:%.*]] = extractelement <2 x float> [[V]], i64 1
+; BOTH-NEXT:    [[Q_I1:%.*]] = fdiv float [[V_I1]], [[DENOM_I1]]
+; BOTH-NEXT:    [[I_I0:%.*]] = fptosi float [[Q_I0]] to i32
+; BOTH-NEXT:    [[I_I1:%.*]] = fptosi float [[Q_I1]] to i32
+; BOTH-NEXT:    [[I_UPTO0:%.*]] = insertelement <2 x i32> poison, i32 [[I_I0]], i64 0
+; BOTH-NEXT:    [[I:%.*]] = insertelement <2 x i32> [[I_UPTO0]], i32 [[I_I1]], i64 1
+; BOTH-NEXT:    store <2 x i32> [[I]], ptr [[DST]], align 8
+; BOTH-NEXT:    ret void
+;
+; BOUNDARY-LABEL: define void @producer_consumer(
+; BOUNDARY-SAME: ptr [[SRC:%.*]], ptr [[DST:%.*]], <2 x float> [[DENOM:%.*]]) {
+; BOUNDARY-NEXT:    [[DST_I1:%.*]] = getelementptr i32, ptr [[DST]], i32 1
+; BOUNDARY-NEXT:    [[V:%.*]] = load <2 x float>, ptr [[SRC]], align 8
+; BOUNDARY-NEXT:    [[Q:%.*]] = fdiv <2 x float> [[V]], [[DENOM]]
+; BOUNDARY-NEXT:    [[I:%.*]] = fptosi <2 x float> [[Q]] to <2 x i32>
+; BOUNDARY-NEXT:    [[I_I0:%.*]] = extractelement <2 x i32> [[I]], i64 0
+; BOUNDARY-NEXT:    store i32 [[I_I0]], ptr [[DST]], align 8
+; BOUNDARY-NEXT:    [[I_I1:%.*]] = extractelement <2 x i32> [[I]], i64 1
+; BOUNDARY-NEXT:    store i32 [[I_I1]], ptr [[DST_I1]], align 4
+; BOUNDARY-NEXT:    ret void
+;
+  %v = load <2 x float>, ptr %src, align 8
+  %q = fdiv <2 x float> %v, %denom
+  %i = fptosi <2 x float> %q to <2 x i32>
+  store <2 x i32> %i, ptr %dst, align 8
+  ret void
+}
+
+; PHIs obey the filter, including loop-carried dependencies.
+define <2 x float> @loop_phi(<2 x float> %init, <2 x float> %denom, i1 %again) {
+; DIV-LABEL: define <2 x float> @loop_phi(
+; DIV-SAME: <2 x float> [[INIT:%.*]], <2 x float> [[DENOM:%.*]], i1 [[AGAIN:%.*]]) {
+; DIV-NEXT:  [[ENTRY:.*]]:
+; DIV-NEXT:    [[DENOM_I0:%.*]] = extractelement <2 x float> [[DENOM]], i64 0
+; DIV-NEXT:    [[DENOM_I1:%.*]] = extractelement <2 x float> [[DENOM]], i64 1
+; DIV-NEXT:    br label %[[LOOP:.*]]
+; DIV:       [[LOOP]]:
+; DIV-NEXT:    [[ACC:%.*]] = phi <2 x float> [ [[INIT]], %[[ENTRY]] ], [ [[NEXT:%.*]], %[[LOOP]] ]
+; DIV-NEXT:    [[ACC_I0:%.*]] = extractelement <2 x float> [[ACC]], i64 0
+; DIV-NEXT:    [[NEXT_I0:%.*]] = fdiv float [[ACC_I0]], [[DENOM_I0]]
+; DIV-NEXT:    [[ACC_I1:%.*]] = extractelement <2 x float> [[ACC]], i64 1
+; DIV-NEXT:    [[NEXT_I1:%.*]] = fdiv float [[ACC_I1]], [[DENOM_I1]]
+; DIV-NEXT:    [[NEXT_UPTO0:%.*]] = insertelement <2 x float> poison, float [[NEXT_I0]], i64 0
+; DIV-NEXT:    [[NEXT]] = insertelement <2 x float> [[NEXT_UPTO0]], float [[NEXT_I1]], i64 1
+; DIV-NEXT:    br i1 [[AGAIN]], label %[[LOOP]], label %[[EXIT:.*]]
+; DIV:       [[EXIT]]:
+; DIV-NEXT:    ret <2 x float> [[NEXT]]
+;
+; CAST-LABEL: define <2 x float> @loop_phi(
+; CAST-SAME: <2 x float> [[INIT:%.*]], <2 x float> [[DENOM:%.*]], i1 [[AGAIN:%.*]]) {
+; CAST-NEXT:  [[ENTRY:.*]]:
+; CAST-NEXT:    br label %[[LOOP:.*]]
+; CAST:       [[LOOP]]:
+; CAST-NEXT:    [[ACC:%.*]] = phi <2 x float> [ [[INIT]], %[[ENTRY]] ], [ [[NEXT:%.*]], %[[LOOP]] ]
+; CAST-NEXT:    [[NEXT]] = fdiv <2 x float> [[ACC]], [[DENOM]]
+; CAST-NEXT:    br i1 [[AGAIN]], label %[[LOOP]], label %[[EXIT:.*]]
+; CAST:       [[EXIT]]:
+; CAST-NEXT:    ret <2 x float> [[NEXT]]
+;
+; BOUNDARY-LABEL: define <2 x float> @loop_phi(
+; BOUNDARY-SAME: <2 x float> [[INIT:%.*]], <2 x float> [[DENOM:%.*]], i1 [[AGAIN:%.*]]) {
+; BOUNDARY-NEXT:  [[ENTRY:.*]]:
+; BOUNDARY-NEXT:    [[INIT_I0:%.*]] = extractelement <2 x float> [[INIT]], i64 0
+; BOUNDARY-NEXT:    [[INIT_I1:%.*]] = extractelement <2 x float> [[INIT]], i64 1
+; BOUNDARY-NEXT:    br label %[[LOOP:.*]]
+; BOUNDARY:       [[LOOP]]:
+; BOUNDARY-NEXT:    [[ACC0:%.*]] = phi float [ [[INIT_I0]], %[[ENTRY]] ], [ [[NEXT0:%.*]], %[[LOOP]] ]
+; BOUNDARY-NEXT:    [[ACC1:%.*]] = phi float [ [[INIT_I1]], %[[ENTRY]] ], [ [[NEXT1:%.*]], %[[LOOP]] ]
+; BOUNDARY-NEXT:    [[PART:%.*]] = insertelement <2 x float> poison, float [[ACC0]], i64 0
+; BOUNDARY-NEXT:    [[ACC:%.*]] = insertelement <2 x float> [[PART]], float [[ACC1]], i64 1
+; BOUNDARY-NEXT:    [[NEXT:%.*]] = fdiv <2 x float> [[ACC]], [[DENOM]]
+; BOUNDARY-NEXT:    [[NEXT0]] = extractelement <2 x float> [[NEXT]], i64 0
+; BOUNDARY-NEXT:    [[NEXT1]] = extractelement <2 x float> [[NEXT]], i64 1
+; BOUNDARY-NEXT:    br i1 [[AGAIN]], label %[[LOOP]], label %[[EXIT:.*]]
+; BOUNDARY:       [[EXIT]]:
+; BOUNDARY-NEXT:    ret <2 x float> [[NEXT]]
+;
+entry:
+  br label %loop
+
+loop:
+  %acc = phi <2 x float> [ %init, %entry ], [ %next, %loop ]
+  %next = fdiv <2 x float> %acc, %denom
+  br i1 %again, label %loop, label %exit
+
+exit:
+  ret <2 x float> %next
+}
diff --git a/llvm/test/Transforms/Scalarizer/pass-param-parse-errors.ll b/llvm/test/Transforms/Scalarizer/pass-param-parse-errors.ll
index 7a241dac6ada13..2d3593c7468cab 100644
--- a/llvm/test/Transforms/Scalarizer/pass-param-parse-errors.ll
+++ b/llvm/test/Transforms/Scalarizer/pass-param-parse-errors.ll
@@ -3,7 +3,11 @@
 ; RUN: not opt -passes='scalarizer<min-bits=>' -disable-output %s 2>&1 | FileCheck -check-prefix=MINBITS-EMPTY-ERR %s
 ; RUN: not opt -passes='scalarizer<min-bits=x>' -disable-output %s 2>&1 | FileCheck -check-prefix=MINBITS-NOTINT-ERR %s
 ; RUN: not opt -passes='scalarizer<no-min-bits=10>' -disable-output %s 2>&1 | FileCheck -check-prefix=UNKNOWNERR %s
+; RUN: not opt -passes='scalarizer<opcode=add;opcode=unknown>' -disable-output %s 2>&1 | FileCheck -check-prefix=OPCODE-ERR %s
+; RUN: not opt -passes='scalarizer<opcode=add;opcode=>' -disable-output %s 2>&1 | FileCheck -check-prefix=OPCODE-EMPTY-ERR %s
 
 ; UNKNOWNERR: invalid Scalarizer pass parameter '{{.*}}'
 ; MINBITS-EMPTY-ERR: invalid argument to Scalarizer pass min-bits parameter: ''
 ; MINBITS-NOTINT-ERR: invalid argument to Scalarizer pass min-bits parameter: 'x'
+; OPCODE-ERR: invalid Scalarizer opcode 'unknown'
+; OPCODE-EMPTY-ERR: invalid Scalarizer opcode ''



More information about the llvm-commits mailing list