X86: Fix VSCALE insert element crash in codegen (#177705)

When inserting elements into <vscale x N x i64> scalable vectors, the X86 backend now returns InstructionCost::getInvalid() instead of panicking.

Fixes #176823
This commit is contained in:
ChaseYalon 2026-01-24 10:13:45 -05:00 committed by GitHub
parent 0263baa0b5
commit 2deae0baf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -4815,6 +4815,10 @@ InstructionCost X86TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
};
assert(Val->isVectorTy() && "This must be a vector type");
auto *VT = cast<VectorType>(Val);
if (VT->isScalableTy())
return InstructionCost::getInvalid();
Type *ScalarType = Val->getScalarType();
InstructionCost RegisterFileMoveCost = 0;

View File

@ -0,0 +1,10 @@
; RUN: opt -passes=print<cost-model> -disable-output < %s
; This test triggers a crash in X86 TTI with scalable vectors
target triple = "x86_64-unknown-linux-gnu"
define <vscale x 1 x i64> @test(i64 %x) {
entry:
%v = insertelement <vscale x 1 x i64> poison, i64 %x, i64 0
ret <vscale x 1 x i64> %v
}