[llvm] 7b33f60 - [RISCV] Remove vmv_v_x_vl workaround for constant splat. NFC

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 31 11:36:15 PDT 2023


Author: Luke Lau
Date: 2023-08-31T19:36:09+01:00
New Revision: 7b33f60f13dc28813510b4ce3b7629187a1beba6

URL: https://github.com/llvm/llvm-project/commit/7b33f60f13dc28813510b4ce3b7629187a1beba6
DIFF: https://github.com/llvm/llvm-project/commit/7b33f60f13dc28813510b4ce3b7629187a1beba6.diff

LOG: [RISCV] Remove vmv_v_x_vl workaround for constant splat. NFC

Now that DAG.getConstant uses splat_vector_parts if needed on RV32, we can use
it directly without having to manually lower to a vmv_v_x_vl.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D159287

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 7c0feb5931bc52..817cef88d85649 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -4247,31 +4247,16 @@ static SDValue lowerVECTOR_SHUFFLEAsRotate(ShuffleVectorSDNode *SVN,
                                                                RotateVT))
     return SDValue();
 
-  // If we just create the shift amount with
-  //
-  // DAG.getConstant(RotateAmt, DL, RotateVT)
-  //
-  // then for e64 we get a weird bitcasted build_vector on RV32 that we're
-  // unable to detect as a splat during pattern matching. So directly lower it
-  // to a vmv.v.x which gets matched to vror.vi.
-  MVT ContainerVT = getContainerForFixedLengthVector(DAG, RotateVT, Subtarget);
-  SDValue VL =
-      getDefaultVLOps(RotateVT, ContainerVT, DL, DAG, Subtarget).second;
   SDValue Op = DAG.getBitcast(RotateVT, SVN->getOperand(0));
 
   SDValue Rotate;
   // A rotate of an i16 by 8 bits either direction is equivalent to a byteswap,
   // so canonicalize to vrev8.
-  if (RotateVT.getScalarType() == MVT::i16 && RotateAmt == 8) {
+  if (RotateVT.getScalarType() == MVT::i16 && RotateAmt == 8)
     Rotate = DAG.getNode(ISD::BSWAP, DL, RotateVT, Op);
-  } else {
-    SDValue RotateAmtSplat = DAG.getNode(
-        RISCVISD::VMV_V_X_VL, DL, ContainerVT, DAG.getUNDEF(ContainerVT),
-        DAG.getConstant(RotateAmt, DL, Subtarget.getXLenVT()), VL);
-    RotateAmtSplat =
-        convertFromScalableVector(RotateVT, RotateAmtSplat, DAG, Subtarget);
-    Rotate = DAG.getNode(ISD::ROTL, DL, RotateVT, Op, RotateAmtSplat);
-  }
+  else
+    Rotate = DAG.getNode(ISD::ROTL, DL, RotateVT, Op,
+                         DAG.getConstant(RotateAmt, DL, RotateVT));
 
   return DAG.getBitcast(VT, Rotate);
 }


        


More information about the llvm-commits mailing list