Skip to content

Commit

Permalink
[arm64] JIT: Move LowerSIMD to shared lower.cpp (#67190)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo authored Mar 26, 2022
1 parent a56b106 commit 20761d0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 85 deletions.
63 changes: 63 additions & 0 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7386,3 +7386,66 @@ bool Lowering::TryTransformStoreObjAsStoreInd(GenTreeBlk* blkNode)
LowerStoreIndirCommon(blkNode->AsStoreInd());
return true;
}

#ifdef FEATURE_SIMD
//----------------------------------------------------------------------------------------------
// Lowering::LowerSIMD: Perform containment analysis for a SIMD intrinsic node.
//
// Arguments:
// simdNode - The SIMD intrinsic node.
//
void Lowering::LowerSIMD(GenTreeSIMD* simdNode)
{
if (simdNode->TypeGet() == TYP_SIMD12)
{
// GT_SIMD node requiring to produce TYP_SIMD12 in fact
// produces a TYP_SIMD16 result
simdNode->gtType = TYP_SIMD16;
}

if (simdNode->GetSIMDIntrinsicId() == SIMDIntrinsicInitN)
{
assert(simdNode->GetSimdBaseType() == TYP_FLOAT);

size_t argCount = simdNode->GetOperandCount();
size_t constArgCount = 0;
float constArgValues[4]{0, 0, 0, 0};

for (GenTree* arg : simdNode->Operands())
{
assert(arg->TypeIs(simdNode->GetSimdBaseType()));

if (arg->IsCnsFltOrDbl())
{
constArgValues[constArgCount] = static_cast<float>(arg->AsDblCon()->gtDconVal);
constArgCount++;
}
}

if (constArgCount == argCount)
{
for (GenTree* arg : simdNode->Operands())
{
BlockRange().Remove(arg);
}

assert(sizeof(constArgValues) == 16);

unsigned cnsSize = sizeof(constArgValues);
unsigned cnsAlign = (comp->compCodeOpt() != Compiler::SMALL_CODE) ? cnsSize : 1;

CORINFO_FIELD_HANDLE hnd =
comp->GetEmitter()->emitBlkConst(constArgValues, cnsSize, cnsAlign, simdNode->GetSimdBaseType());
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(GT_CLS_VAR_ADDR, TYP_I_IMPL, hnd, nullptr);
BlockRange().InsertBefore(simdNode, clsVarAddr);
simdNode->ChangeOper(GT_IND);
simdNode->AsOp()->gtOp1 = clsVarAddr;
ContainCheckIndir(simdNode->AsIndir());

return;
}
}

ContainCheckSIMD(simdNode);
}
#endif // FEATURE_SIMD
22 changes: 0 additions & 22 deletions src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,28 +612,6 @@ void Lowering::LowerRotate(GenTree* tree)
ContainCheckShiftRotate(tree->AsOp());
}

#ifdef FEATURE_SIMD
//----------------------------------------------------------------------------------------------
// Lowering::LowerSIMD: Perform containment analysis for a SIMD intrinsic node.
//
// Arguments:
// simdNode - The SIMD intrinsic node.
//
void Lowering::LowerSIMD(GenTreeSIMD* simdNode)
{
assert(simdNode->gtType != TYP_SIMD32);

if (simdNode->TypeGet() == TYP_SIMD12)
{
// GT_SIMD node requiring to produce TYP_SIMD12 in fact
// produces a TYP_SIMD16 result
simdNode->gtType = TYP_SIMD16;
}

ContainCheckSIMD(simdNode);
}
#endif // FEATURE_SIMD

#ifdef FEATURE_HW_INTRINSICS

//----------------------------------------------------------------------------------------------
Expand Down
63 changes: 0 additions & 63 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,69 +755,6 @@ void Lowering::LowerCast(GenTree* tree)
ContainCheckCast(tree->AsCast());
}

#ifdef FEATURE_SIMD
//----------------------------------------------------------------------------------------------
// Lowering::LowerSIMD: Perform containment analysis for a SIMD intrinsic node.
//
// Arguments:
// simdNode - The SIMD intrinsic node.
//
void Lowering::LowerSIMD(GenTreeSIMD* simdNode)
{
if (simdNode->TypeGet() == TYP_SIMD12)
{
// GT_SIMD node requiring to produce TYP_SIMD12 in fact
// produces a TYP_SIMD16 result
simdNode->gtType = TYP_SIMD16;
}

if (simdNode->GetSIMDIntrinsicId() == SIMDIntrinsicInitN)
{
assert(simdNode->GetSimdBaseType() == TYP_FLOAT);

size_t argCount = simdNode->GetOperandCount();
size_t constArgCount = 0;
float constArgValues[4]{0, 0, 0, 0};

for (GenTree* arg : simdNode->Operands())
{
assert(arg->TypeIs(simdNode->GetSimdBaseType()));

if (arg->IsCnsFltOrDbl())
{
constArgValues[constArgCount] = static_cast<float>(arg->AsDblCon()->gtDconVal);
constArgCount++;
}
}

if (constArgCount == argCount)
{
for (GenTree* arg : simdNode->Operands())
{
BlockRange().Remove(arg);
}

assert(sizeof(constArgValues) == 16);

unsigned cnsSize = sizeof(constArgValues);
unsigned cnsAlign = (comp->compCodeOpt() != Compiler::SMALL_CODE) ? cnsSize : 1;

CORINFO_FIELD_HANDLE hnd =
comp->GetEmitter()->emitBlkConst(constArgValues, cnsSize, cnsAlign, simdNode->GetSimdBaseType());
GenTree* clsVarAddr = new (comp, GT_CLS_VAR_ADDR) GenTreeClsVar(GT_CLS_VAR_ADDR, TYP_I_IMPL, hnd, nullptr);
BlockRange().InsertBefore(simdNode, clsVarAddr);
simdNode->ChangeOper(GT_IND);
simdNode->AsOp()->gtOp1 = clsVarAddr;
ContainCheckIndir(simdNode->AsIndir());

return;
}
}

ContainCheckSIMD(simdNode);
}
#endif // FEATURE_SIMD

#ifdef FEATURE_HW_INTRINSICS

//----------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 20761d0

Please sign in to comment.