Skip to content

Commit ede442a

Browse files
authored
allow containment of CnsVec under GetElement node with non-const index (#117562)
1 parent 5aecfd2 commit ede442a

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/coreclr/jit/hwintrinsiccodegenxarch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,14 @@ void CodeGen::genBaseIntrinsic(GenTreeHWIntrinsic* node, insOpts instOptions)
20562056
}
20572057
baseReg = (isEBPbased) ? REG_EBP : REG_ESP;
20582058
}
2059+
else if (op1->IsCnsVec())
2060+
{
2061+
CORINFO_FIELD_HANDLE hnd =
2062+
GetEmitter()->emitSimdConst(&op1->AsVecCon()->gtSimdVal, emitTypeSize(op1));
2063+
2064+
baseReg = internalRegisters.GetSingle(node);
2065+
GetEmitter()->emitIns_R_C(INS_lea, emitTypeSize(TYP_I_IMPL), baseReg, hnd, 0, INS_OPTS_NONE);
2066+
}
20592067
else
20602068
{
20612069
// Require GT_IND addr to be not contained.

src/coreclr/jit/lowerxarch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10121,7 +10121,7 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node)
1012110121
MakeSrcContained(node, op2);
1012210122
}
1012310123

10124-
if (IsContainableMemoryOp(op1) && IsSafeToContainMem(node, op1))
10124+
if (op1->IsCnsVec() || (IsContainableMemoryOp(op1) && IsSafeToContainMem(node, op1)))
1012510125
{
1012610126
MakeSrcContained(node, op1);
1012710127
}

src/coreclr/jit/lsraxarch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,12 +2304,17 @@ int LinearScan::BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree, int* pDstCou
23042304

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

23102310
var_types requiredSimdTempType = Compiler::getSIMDTypeForSize(intrinsicTree->GetSimdSize());
23112311
compiler->getSIMDInitTempVarNum(requiredSimdTempType);
23122312
}
2313+
else if (op1->IsCnsVec())
2314+
{
2315+
// We need an int reg to load the address of the CnsVec data.
2316+
buildInternalIntRegisterDefForNode(intrinsicTree);
2317+
}
23132318
break;
23142319
}
23152320

0 commit comments

Comments
 (0)