[SLPVectorizer][TTI] Segfault in FixedVectorType::get for `<2 x ptr>` when datalayout has `p:40` on x86-64
With a module datalayout that has 40-bit pointers and an x86-64 target forced on the command line, SLP's cost
query for <2 x ptr> segfaults. getPointerTy returns an invalid MVT for 40 bits, and
EVT::getExtendedVectorVT then calls FixedVectorType::get(nullptr, 2).
Reproducer (opt -mtriple=x86_64-unknown-linux-gnu -passes=slp-vectorizer, also reproduces on f2808fc79 and 5e457cda8d5a):
target datalayout = "p:40:64:64:32"
define i1 @f() {
%a = icmp ult ptr null, null
%b = icmp ult ptr null, null
ret i1 %b
}
$ opt -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 -passes=slp-vectorizer -disable-output test.ll
Segmentation fault
#4 llvm::FixedVectorType::get(llvm::Type*, unsigned int)
#5 llvm::EVT::getExtendedVectorVT(llvm::LLVMContext&, llvm::EVT, llvm::ElementCount)
#6 llvm::TargetLoweringBase::getValueType(llvm::DataLayout const&, llvm::Type*, bool) const
#7 llvm::BasicTTIImplBase<llvm::X86TTIImpl>::computeTypeLegalizationCost(llvm::Type*) const
#8 llvm::BasicTTIImplBase<llvm::X86TTIImpl>::getTypeLegalizationCost(llvm::Type*) const
#9 llvm::BasicTTIImplBase<llvm::X86TTIImpl>::getNumberOfParts(llvm::Type*) const
#10 llvm::slpvectorizer::getFloorFullVectorNumberOfElements(llvm::TargetTransformInfo const&, llvm::Type*, unsigned int, bool)
#11 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool, bool)
#12 bool tryToVectorizeSequence<llvm::Value>(...)
#13 bool llvm::SLPVectorizerPass::vectorizeCmpInsts<...>(...)
#14 llvm::SLPVectorizerPass::vectorizeChainsInBlock(...)
Expected: no crash (treat the vector-of-pointer type as illegal/expensive, or reject the mismatched datalayout with a diagnostic).
Notes: this is an edge case. The datalayout does not match any x86 target, and without -mtriple there is no crash.
The crash is in generic TargetLoweringBase::getValueType/BasicTTIImpl, not in SLP itself.
p:48 crashes the same way; p:32/p:64 do not.
Found with a mutation-based IR fuzzer. Triage, test-case minimization and parts of this write-up were assisted by an LLM; verified the reproducer on 9dce18f0e.
Assisted-by: Claude (Anthropic)
@arie2026: Please consider to request triage role (examples) before mass issues creation, so you'll be able to label issues yourself, preferably at creation.