[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
Mon Dec 2 17:28:34 PST 2024
================
@@ -3496,21 +3496,30 @@ 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();
+ // Additionally the element types should match
+ if (Vec.getSimpleValueType().getVectorElementType() !=
+ VT.getVectorElementType())
return SDValue();
SDValue Idx = SplatVal.getOperand(1);
// The index must be a legal type.
if (Idx.getValueType() != Subtarget.getXLenVT())
return SDValue();
+ // FIXME: Can we use the indexes that are in-bound here instead?
----------------
lukel97 wrote:
Nit, can you add a comment explaining that we need to check the sizes to ensure that index lies within VT?
Also can also leave this a TODO instead. FIXME makes me think of miscompiles/incorrectness
https://github.com/llvm/llvm-project/pull/117878
More information about the llvm-commits
mailing list