[llvm] [SLP] NFC. Set NumOperands directly if IntrinsicInst is VL[0]. (PR #111103)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 00:10:00 PDT 2024


https://github.com/HanKuanChen updated https://github.com/llvm/llvm-project/pull/111103

>From 38e0cf78730c7e8b3a6321ce87dd2cae4e3c8469 Mon Sep 17 00:00:00 2001
From: Han-Kuan Chen <hankuan.chen at sifive.com>
Date: Fri, 4 Oct 2024 00:07:25 -0700
Subject: [PATCH] [SLP] NFC. Set NumOperands directly if VL[0] is
 IntrinsicInst.

---
 llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 27e43df4949273..c3df0fcaed4c2d 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2312,10 +2312,10 @@ class BoUpSLP {
       assert((empty() || VL.size() == getNumLanes()) &&
              "Expected same number of lanes");
       assert(isa<Instruction>(VL[0]) && "Expected instruction");
-      unsigned NumOperands = cast<Instruction>(VL[0])->getNumOperands();
       constexpr unsigned IntrinsicNumOperands = 2;
-      if (isa<IntrinsicInst>(VL[0]))
-        NumOperands = IntrinsicNumOperands;
+      unsigned NumOperands = isa<IntrinsicInst>(VL[0])
+                                 ? IntrinsicNumOperands
+                                 : cast<Instruction>(VL[0])->getNumOperands();
       OpsVec.resize(NumOperands);
       unsigned NumLanes = VL.size();
       for (unsigned OpIdx = 0; OpIdx != NumOperands; ++OpIdx) {



More information about the llvm-commits mailing list