[llvm] 44e0427 - [RISCV] Use lowerScalarInsert in lowerReductionSeq [nfc]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 09:08:54 PST 2022


Author: Philip Reames
Date: 2022-12-13T09:08:39-08:00
New Revision: 44e0427cf08516028206e266563ecc3dbfe09f2f

URL: https://github.com/llvm/llvm-project/commit/44e0427cf08516028206e266563ecc3dbfe09f2f
DIFF: https://github.com/llvm/llvm-project/commit/44e0427cf08516028206e266563ecc3dbfe09f2f.diff

LOG: [RISCV] Use lowerScalarInsert in lowerReductionSeq [nfc]

Use the newly introduced helper routine.  At the moment, this generates the same code (at this call site!) since LMUL is restricted to LMUL1 or less, and VL is hard coded to 1.  In a future patch, I will loosen the second part.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 5d3545a4a206..02345d89788a 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -5858,16 +5858,16 @@ static SDValue lowerReductionSeq(unsigned RVVOpcode, SDValue StartValue,
   // The reduction needs an LMUL1 input; do the splat at either LMUL1
   // or the original VT if fractional.
   auto InnerVT = VecVT.bitsLE(M1VT) ? VecVT : M1VT;
-  SDValue InitialSplat =
-      lowerScalarSplat(SDValue(), StartValue, DAG.getConstant(1, DL, XLenVT),
-                       InnerVT, DL, DAG, Subtarget);
+  SDValue InitialValue =
+    lowerScalarInsert(StartValue, DAG.getConstant(1, DL, XLenVT),
+                      InnerVT, DL, DAG, Subtarget);
   if (M1VT != InnerVT)
-    InitialSplat = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, M1VT,
+    InitialValue = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, M1VT,
                                DAG.getUNDEF(M1VT),
-                               InitialSplat, DAG.getConstant(0, DL, XLenVT));
-  SDValue PassThru = hasNonZeroAVL(VL) ? DAG.getUNDEF(M1VT) : InitialSplat;
+                               InitialValue, DAG.getConstant(0, DL, XLenVT));
+  SDValue PassThru = hasNonZeroAVL(VL) ? DAG.getUNDEF(M1VT) : InitialValue;
   SDValue Reduction = DAG.getNode(RVVOpcode, DL, M1VT, PassThru, Vec,
-                                  InitialSplat, Mask, VL);
+                                  InitialValue, Mask, VL);
   return DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, VecEltVT, Reduction,
                      DAG.getConstant(0, DL, XLenVT));
 }


        


More information about the llvm-commits mailing list