[llvm] [GlobalISel] Enhance iPTR type support in SDAG patterns (PR #111503)
Evgenii Kudriashov via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 16 07:26:54 PDT 2025
e-kud wrote:
> This is just a bug, the vector index type is separate from the pointer type
@arsenm if this is a bug it's already buried too deep.
```
/// Returns the type to be used for the index operand vector operations. By
/// default we assume it will have the same size as an address space 0
/// pointer.
virtual unsigned getVectorIdxWidth(const DataLayout &DL) const {
return DL.getPointerSizeInBits(0);
}
/// Returns the type to be used for the index operand of:
/// ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT,
/// ISD::INSERT_SUBVECTOR, and ISD::EXTRACT_SUBVECTOR
MVT getVectorIdxTy(const DataLayout &DL) const {
return MVT::getIntegerVT(getVectorIdxWidth(DL));
}
/// Returns the type to be used for the index operand of:
/// G_INSERT_VECTOR_ELT, G_EXTRACT_VECTOR_ELT,
/// G_INSERT_SUBVECTOR, and G_EXTRACT_SUBVECTOR
LLT getVectorIdxLLT(const DataLayout &DL) const {
return LLT::scalar(getVectorIdxWidth(DL));
}
```
So each target that has vectors implemented in SDAG must overwrite default interface and whole SDAG implementation to enable vector patterns in GlobalISel. It looks like supporting `iPTR` as a HW dependent integer type could be more straightforward in terms of GlobalISel adoption. What do you think?
cc @aemerson @davemgreen @topperc
https://github.com/llvm/llvm-project/pull/111503
More information about the llvm-commits
mailing list