Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Remove GenTreeIndexAddr::gtStructElemClass
Browse files Browse the repository at this point in the history
There is no need to store this. GenTreeIndexAddr is only used in minopts where VN doesn't run. It's only remaining use is to recover the struct handle in gtGetStructHandleIfPresent. But that can be done by generating a OBJ instead of IND in fgMorphArrayIndex.
  • Loading branch information
mikedn committed Jul 20, 2019
1 parent e695bf4 commit b2b41be
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 34 deletions.
8 changes: 0 additions & 8 deletions src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9569,14 +9569,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
return false;
}

if (indir->gtOp1->OperIs(GT_INDEX_ADDR))
{
GenTreeIndexAddr* const indexAddr = indir->gtOp1->AsIndexAddr();
*arrayInfo = ArrayInfo(indexAddr->gtElemType, indexAddr->gtElemSize, indexAddr->gtElemOffset,
indexAddr->gtStructElemClass);
return true;
}

bool found = GetArrayInfoMap()->Lookup(indir, arrayInfo);
assert(found);
return true;
Expand Down
18 changes: 10 additions & 8 deletions src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void GenTree::InitNodeSize()
GenTree::s_gtNodeSizes[GT_FTN_ADDR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_BOX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INDEX] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INDEX_ADDR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_INDEX_ADDR] = TREE_NODE_SZ_LARGE;
GenTree::s_gtNodeSizes[GT_ARR_BOUNDS_CHECK] = TREE_NODE_SZ_LARGE;
#ifdef FEATURE_SIMD
GenTree::s_gtNodeSizes[GT_SIMD_CHK] = TREE_NODE_SZ_LARGE;
Expand Down Expand Up @@ -7038,9 +7038,8 @@ GenTree* Compiler::gtCloneExpr(
GenTreeIndexAddr* asIndAddr = tree->AsIndexAddr();

copy = new (this, GT_INDEX_ADDR)
GenTreeIndexAddr(asIndAddr->Arr(), asIndAddr->Index(), asIndAddr->gtElemType,
asIndAddr->gtStructElemClass, asIndAddr->gtElemSize, asIndAddr->gtLenOffset,
asIndAddr->gtElemOffset);
GenTreeIndexAddr(asIndAddr->Arr(), asIndAddr->Index(), asIndAddr->gtElemType, asIndAddr->gtElemSize,
asIndAddr->gtLenOffset, asIndAddr->gtElemOffset);
copy->AsIndexAddr()->gtIndRngFailBB = asIndAddr->gtIndRngFailBB;
}
break;
Expand Down Expand Up @@ -16426,9 +16425,6 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleIfPresent(GenTree* tree)
case GT_INDEX:
structHnd = tree->gtIndex.gtStructElemClass;
break;
case GT_INDEX_ADDR:
structHnd = tree->AsIndexAddr()->gtStructElemClass;
break;
case GT_FIELD:
info.compCompHnd->getFieldType(tree->gtField.gtFldHnd, &structHnd);
break;
Expand All @@ -16450,8 +16446,14 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleIfPresent(GenTree* tree)
structHnd = gtGetStructHandleIfPresent(tree->gtOp.gtOp1);
break;
case GT_IND:
if (tree->AsIndir()->Addr()->OperIs(GT_INDEX_ADDR))
{
// There's no way to recover the handle from a IND(GT_INDEX_ADDR) tree and
// that should not be needed.
}
else
#ifdef FEATURE_SIMD
if (varTypeIsSIMD(tree))
if (varTypeIsSIMD(tree))
{
structHnd = gtGetStructHandleForSIMD(tree->gtType, TYP_FLOAT);
#ifdef FEATURE_HW_INTRINSICS
Expand Down
12 changes: 2 additions & 10 deletions src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4321,24 +4321,16 @@ struct GenTreeIndexAddr : public GenTreeOp
return gtOp2;
}

CORINFO_CLASS_HANDLE gtStructElemClass; // If the element type is a struct, this is the struct type.

BasicBlock* gtIndRngFailBB; // Basic block to jump to for array-index-out-of-range

var_types gtElemType; // The element type of the array.
unsigned gtElemSize; // size of elements in the array
unsigned gtLenOffset; // The offset from the array's base address to its length.
unsigned gtElemOffset; // The offset from the array's base address to its first element.

GenTreeIndexAddr(GenTree* arr,
GenTree* ind,
var_types elemType,
CORINFO_CLASS_HANDLE structElemClass,
unsigned elemSize,
unsigned lenOffset,
unsigned elemOffset)
GenTreeIndexAddr(
GenTree* arr, GenTree* ind, var_types elemType, unsigned elemSize, unsigned lenOffset, unsigned elemOffset)
: GenTreeOp(GT_INDEX_ADDR, TYP_BYREF, arr, ind)
, gtStructElemClass(structElemClass)
, gtIndRngFailBB(nullptr)
, gtElemType(elemType)
, gtElemSize(elemSize)
Expand Down
22 changes: 14 additions & 8 deletions src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5656,8 +5656,8 @@ GenTree* Compiler::fgMorphArrayIndex(GenTree* tree)
GenTree* const index = fgMorphTree(asIndex->Index());

GenTreeIndexAddr* const indexAddr =
new (this, GT_INDEX_ADDR) GenTreeIndexAddr(array, index, elemTyp, elemStructType, elemSize,
static_cast<unsigned>(lenOffs), static_cast<unsigned>(elemOffs));
new (this, GT_INDEX_ADDR) GenTreeIndexAddr(array, index, elemTyp, elemSize, static_cast<unsigned>(lenOffs),
static_cast<unsigned>(elemOffs));
indexAddr->gtFlags |= (array->gtFlags | index->gtFlags) & GTF_ALL_EFFECT;

// Mark the indirection node as needing a range check if necessary.
Expand All @@ -5667,15 +5667,21 @@ GenTree* Compiler::fgMorphArrayIndex(GenTree* tree)
fgSetRngChkTarget(indexAddr);
}

// Change `tree` into an indirection and return.
tree->ChangeOper(GT_IND);
if (elemStructType == NO_CLASS_HANDLE)
{
tree->ChangeOper(GT_IND);
}
else
{
tree->ChangeOper(GT_OBJ);
tree->AsObj()->SetLayout(typGetObjLayout(elemStructType));
}

GenTreeIndir* const indir = tree->AsIndir();
indir->Addr() = indexAddr;
indir->gtFlags = GTF_IND_ARR_INDEX | (indexAddr->gtFlags & GTF_ALL_EFFECT);
indir->gtFlags = indexAddr->gtFlags & GTF_ALL_EFFECT;

#ifdef DEBUG
indexAddr->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;
#endif // DEBUG
INDEBUG(indexAddr->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED;)

return indir;
}
Expand Down

0 comments on commit b2b41be

Please sign in to comment.