[llvm] [RISCV] Update matchSplatAsGather to use the index of extract_elt if in-bounds (PR #118873)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 14:49:28 PST 2025
================
@@ -3517,27 +3517,44 @@ static SDValue matchSplatAsGather(SDValue SplatVal, MVT VT, const SDLoc &DL,
// different
// FIXME: Support i1 vectors, maybe by promoting to i8?
MVT EltTy = VT.getVectorElementType();
- if (EltTy == MVT::i1 ||
- EltTy != Vec.getSimpleValueType().getVectorElementType())
+ MVT VecVT = Vec.getSimpleValueType();
+ if (EltTy == MVT::i1 || EltTy != VecVT.getVectorElementType())
return SDValue();
SDValue Idx = SplatVal.getOperand(1);
// The index must be a legal type.
if (Idx.getValueType() != Subtarget.getXLenVT())
return SDValue();
- // Check that Index lies within VT
- // TODO: Can we check if the Index is constant and known in-bounds?
- if (!TypeSize::isKnownLE(Vec.getValueSizeInBits(), VT.getSizeInBits()))
- return SDValue();
+ // Check that we know Idx lies within VT
+ if (!TypeSize::isKnownLE(Vec.getValueSizeInBits(), VT.getSizeInBits())) {
+ auto *CIdx = dyn_cast(Idx);
----------------
preames wrote:
Does this compile? dyn_cast<X> would be more typical?
https://github.com/llvm/llvm-project/pull/118873
More information about the llvm-commits
mailing list