[llvm] [DAG] expandVecReduce - pull out repeated getFlags() calls. NFC. (PR #195838)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue May 5 04:55:34 PDT 2026


https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/195838

None

>From 5397e0635a2e06e5c38729c82c5681b1d62f7e9b Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Tue, 5 May 2026 12:54:53 +0100
Subject: [PATCH] [DAG] expandVecReduce - pull out repeated getFlags() calls.
 NFC.

---
 llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 7bd96b98798c1..867fd87d3c137 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -12371,6 +12371,7 @@ SDValue TargetLowering::expandVecReduce(SDNode *Node, SelectionDAG &DAG) const {
   SDLoc dl(Node);
   ISD::NodeType BaseOpcode = ISD::getVecReduceBaseOpcode(Node->getOpcode());
   SDValue Op = Node->getOperand(0);
+  SDNodeFlags Flags = Node->getFlags();
   EVT VT = Op.getValueType();
 
   // Try to use a shuffle reduction for power of two vectors.
@@ -12407,7 +12408,7 @@ SDValue TargetLowering::expandVecReduce(SDNode *Node, SelectionDAG &DAG) const {
             std::tie(Lo, Hi) = DAG.SplitVector(Op, dl);
             Lo = DAG.getInsertSubvector(dl, DAG.getPOISON(WideVT), Lo, 0);
             Hi = DAG.getInsertSubvector(dl, DAG.getPOISON(WideVT), Hi, 0);
-            Op = DAG.getNode(BaseOpcode, dl, WideVT, Lo, Hi, Node->getFlags());
+            Op = DAG.getNode(BaseOpcode, dl, WideVT, Lo, Hi, Flags);
             Op = DAG.getExtractSubvector(dl, HalfVT, Op, 0);
             VT = HalfVT;
             continue;
@@ -12418,13 +12419,13 @@ SDValue TargetLowering::expandVecReduce(SDNode *Node, SelectionDAG &DAG) const {
 
       SDValue Lo, Hi;
       std::tie(Lo, Hi) = DAG.SplitVector(Op, dl);
-      Op = DAG.getNode(BaseOpcode, dl, HalfVT, Lo, Hi, Node->getFlags());
+      Op = DAG.getNode(BaseOpcode, dl, HalfVT, Lo, Hi, Flags);
       VT = HalfVT;
 
       // Stop if splitting is enough to make the reduction legal.
       if (isOperationLegalOrCustom(Node->getOpcode(), HalfVT))
         return DAG.getNode(Node->getOpcode(), dl, Node->getValueType(0), Op,
-                           Node->getFlags());
+                           Flags);
     }
   }
 
@@ -12440,7 +12441,7 @@ SDValue TargetLowering::expandVecReduce(SDNode *Node, SelectionDAG &DAG) const {
 
   SDValue Res = Ops[0];
   for (unsigned i = 1; i < NumElts; i++)
-    Res = DAG.getNode(BaseOpcode, dl, EltVT, Res, Ops[i], Node->getFlags());
+    Res = DAG.getNode(BaseOpcode, dl, EltVT, Res, Ops[i], Flags);
 
   // Result type may be wider than element type.
   if (EltVT != Node->getValueType(0))



More information about the llvm-commits mailing list