Skip to content

JIT: Allow containment of CnsVec under GetElement node with non-const index #117562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/coreclr/jit/hwintrinsiccodegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,14 @@ void CodeGen::genBaseIntrinsic(GenTreeHWIntrinsic* node, insOpts instOptions)
}
baseReg = (isEBPbased) ? REG_EBP : REG_ESP;
}
else if (op1->IsCnsVec())
{
CORINFO_FIELD_HANDLE hnd =
GetEmitter()->emitSimdConst(&op1->AsVecCon()->gtSimdVal, emitTypeSize(op1));

baseReg = internalRegisters.GetSingle(node);
GetEmitter()->emitIns_R_C(INS_lea, emitTypeSize(TYP_I_IMPL), baseReg, hnd, 0, INS_OPTS_NONE);
}
else
{
// Require GT_IND addr to be not contained.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10121,7 +10121,7 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node)
MakeSrcContained(node, op2);
}

if (IsContainableMemoryOp(op1) && IsSafeToContainMem(node, op1))
if (op1->IsCnsVec() || (IsContainableMemoryOp(op1) && IsSafeToContainMem(node, op1)))
{
MakeSrcContained(node, op1);
}
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/jit/lsraxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2304,12 +2304,17 @@ int LinearScan::BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree, int* pDstCou

if (!op2->OperIsConst() && !op1->isContained())
{
// If the index is not a constant or op1 is in register,
// If the index is not a constant and op1 is in register,
// we will use the SIMD temp location to store the vector.

var_types requiredSimdTempType = Compiler::getSIMDTypeForSize(intrinsicTree->GetSimdSize());
compiler->getSIMDInitTempVarNum(requiredSimdTempType);
}
else if (op1->IsCnsVec())
{
// We need an int reg to load the address of the CnsVec data.
buildInternalIntRegisterDefForNode(intrinsicTree);
}
break;
}

Expand Down
Loading