Skip to content

Commit

Permalink
Improve TryTransformStoreObjAsStoreInd optimization. (#55727)
Browse files Browse the repository at this point in the history
* Fix `TryTransformStoreObjAsStoreInd` optimization.

* Disable the assert.

It was failing on DevDiv_280120 arm32 linux, did not repro with an altjit.
  • Loading branch information
Sergey Andreenko authored Jul 15, 2021
1 parent 25686d5 commit 6d3bb36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ struct GenTree
return OperIsInitVal(OperGet());
}

bool IsConstInitVal()
bool IsConstInitVal() const
{
return (gtOper == GT_CNS_INT) || (OperIsInitVal() && (gtGetOp1()->gtOper == GT_CNS_INT));
}
Expand Down
9 changes: 5 additions & 4 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6730,7 +6730,7 @@ void Lowering::LowerBlockStoreCommon(GenTreeBlk* blkNode)
bool Lowering::TryTransformStoreObjAsStoreInd(GenTreeBlk* blkNode)
{
assert(blkNode->OperIs(GT_STORE_BLK, GT_STORE_DYN_BLK, GT_STORE_OBJ));
if (comp->opts.OptimizationEnabled())
if (!comp->opts.OptimizationEnabled())
{
return false;
}
Expand All @@ -6751,7 +6751,9 @@ bool Lowering::TryTransformStoreObjAsStoreInd(GenTreeBlk* blkNode)
{
return false;
}
if (varTypeIsSIMD(regType))

GenTree* src = blkNode->Data();
if (varTypeIsSIMD(regType) && src->IsConstInitVal())
{
// TODO-CQ: support STORE_IND SIMD16(SIMD16, CNT_INT 0).
return false;
Expand All @@ -6764,13 +6766,12 @@ bool Lowering::TryTransformStoreObjAsStoreInd(GenTreeBlk* blkNode)
return false;
}

GenTree* src = blkNode->Data();
if (src->OperIsInitVal() && !src->IsConstInitVal())
{
return false;
}

if (varTypeIsSmall(regType) && !src->IsConstInitVal())
if (varTypeIsSmall(regType) && !src->IsConstInitVal() && !src->IsLocal())
{
// source operand INDIR will use a widening instruction
// and generate worse code, like `movzx` instead of `mov`
Expand Down

0 comments on commit 6d3bb36

Please sign in to comment.