[llvm] [RISCV] Update matchSplatAsGather to convert vectors if they have different sizes (PR #117878)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 4 06:03:45 PST 2024


================
@@ -3496,21 +3496,26 @@ static SDValue matchSplatAsGather(SDValue SplatVal, MVT VT, const SDLoc &DL,
   if (SplatVal.getOpcode() != ISD::EXTRACT_VECTOR_ELT)
     return SDValue();
   SDValue Vec = SplatVal.getOperand(0);
-  // Only perform this optimization on vectors of the same size for simplicity.
   // Don't perform this optimization for i1 vectors.
   // FIXME: Support i1 vectors, maybe by promoting to i8?
-  if (Vec.getValueType() != VT || VT.getVectorElementType() == MVT::i1)
+  if (VT.getVectorElementType() == MVT::i1)
     return SDValue();
   SDValue Idx = SplatVal.getOperand(1);
   // The index must be a legal type.
   if (Idx.getValueType() != Subtarget.getXLenVT())
     return SDValue();
 
+  if (Vec.getValueSizeInBits().getKnownMinValue() >
----------------
lukel97 wrote:

I think that should be fine because vscale has to be at least one. Or are you talking about if checking Vec <= VT is enough?

https://github.com/llvm/llvm-project/pull/117878


More information about the llvm-commits mailing list