Skip to content
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

Delete GTF_VAR_CAST #74461

Merged
merged 2 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 0 additions & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9219,10 +9219,6 @@ void cTreeFlags(Compiler* comp, GenTree* tree)
{
chars += printf("[VAR_USEASG]");
}
if (tree->gtFlags & GTF_VAR_CAST)
{
chars += printf("[VAR_CAST]");
}
if (tree->gtFlags & GTF_VAR_ITERATOR)
{
chars += printf("[VAR_ITERATOR]");
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10424,12 +10424,6 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
--msgLength;
break;
}
if (tree->gtFlags & GTF_VAR_CAST)
{
printf("C");
--msgLength;
break;
}
if (tree->gtFlags & GTF_VAR_CONTEXT)
{
printf("!");
Expand Down
21 changes: 9 additions & 12 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,10 @@ enum GenTreeFlags : unsigned int

GTF_LIVENESS_MASK = GTF_VAR_DEF | GTF_VAR_USEASG | GTF_VAR_DEATH_MASK,

GTF_VAR_CAST = 0x01000000, // GT_LCL_VAR -- has been explicitly cast (variable node may not be type of local)
GTF_VAR_ITERATOR = 0x00800000, // GT_LCL_VAR -- this is a iterator reference in the loop condition
GTF_VAR_CLONED = 0x00400000, // GT_LCL_VAR -- this node has been cloned or is a clone
GTF_VAR_CONTEXT = 0x00200000, // GT_LCL_VAR -- this node is part of a runtime lookup
GTF_VAR_FOLDED_IND = 0x00100000, // GT_LCL_VAR -- this node was folded from *(typ*)&lclVar expression tree in fgMorphSmpOp()
GTF_VAR_ITERATOR = 0x01000000, // GT_LCL_VAR -- this is a iterator reference in the loop condition
GTF_VAR_CLONED = 0x00800000, // GT_LCL_VAR -- this node has been cloned or is a clone
GTF_VAR_CONTEXT = 0x00400000, // GT_LCL_VAR -- this node is part of a runtime lookup
GTF_VAR_FOLDED_IND = 0x00200000, // GT_LCL_VAR -- this node was folded from *(typ*)&lclVar expression tree in fgMorphSmpOp()
// where 'typ' is a small type and 'lclVar' corresponds to a normalized-on-store local variable.
// This flag identifies such nodes in order to make sure that fgDoNormalizeOnStore() is called
// on their parents in post-order morph.
Expand Down Expand Up @@ -2313,20 +2312,18 @@ struct GenTree
bool IsReuseRegVal() const
{
// This can be extended to non-constant nodes, but not to local or indir nodes.
if (IsInvariant() && ((gtFlags & GTF_REUSE_REG_VAL) != 0))
{
return true;
}
return false;
return OperIsConst() && ((gtFlags & GTF_REUSE_REG_VAL) != 0);
}

void SetReuseRegVal()
{
assert(IsInvariant());
assert(OperIsConst());
gtFlags |= GTF_REUSE_REG_VAL;
}

void ResetReuseRegVal()
{
assert(IsInvariant());
assert(OperIsConst());
gtFlags &= ~GTF_REUSE_REG_VAL;
}

Expand Down
49 changes: 6 additions & 43 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4435,7 +4435,7 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,

#if FEATURE_PARTIAL_SIMD_CALLEE_SAVE
// TODO-CQ: If the varType needs partial callee save, conservatively do not enregister
// such variable. In future, need to enable enregisteration for such variables.
// such variable. In future, we should enable enregisteration for such variables.
if (!varTypeNeedsPartialCalleeSave(varDsc->GetRegisterType()))
#endif
{
Expand All @@ -4446,48 +4446,11 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
}
}

bool allowStructs = false;
#ifdef UNIX_AMD64_ABI
// On System V the type of the var could be a struct type.
allowStructs = varTypeIsStruct(varDsc);
#endif // UNIX_AMD64_ABI

/* Variables must be used as the same type throughout the method */
noway_assert(varDsc->lvType == TYP_UNDEF || tree->gtType == TYP_UNKNOWN || allowStructs ||
genActualType(varDsc->TypeGet()) == genActualType(tree->gtType) ||
(tree->gtType == TYP_BYREF && varDsc->TypeGet() == TYP_I_IMPL) ||
(tree->gtType == TYP_I_IMPL && varDsc->TypeGet() == TYP_BYREF) || (tree->gtFlags & GTF_VAR_CAST) ||
(varTypeIsFloating(varDsc) && varTypeIsFloating(tree)) ||
(varTypeIsStruct(varDsc) == varTypeIsStruct(tree)));

/* Remember the type of the reference */

if (tree->gtType == TYP_UNKNOWN || varDsc->lvType == TYP_UNDEF)
{
varDsc->lvType = tree->gtType;
noway_assert(genActualType(varDsc->TypeGet()) == tree->gtType); // no truncation
}

#ifdef DEBUG
if (tree->gtFlags & GTF_VAR_CAST)
{
// it should never be bigger than the variable slot

// Trees don't store the full information about structs
// so we can't check them.
if (tree->TypeGet() != TYP_STRUCT)
{
unsigned treeSize = genTypeSize(tree->TypeGet());
unsigned varSize = genTypeSize(varDsc->TypeGet());
if (varDsc->TypeGet() == TYP_STRUCT)
{
varSize = varDsc->lvSize();
}

assert(treeSize <= varSize);
}
}
#endif
// Check that the LCL_VAR node has the same type as the underlying variable, save a few mismatches we allow.
assert(tree->TypeIs(varDsc->TypeGet(), genActualType(varDsc)) ||
(tree->TypeIs(TYP_I_IMPL) && (varDsc->TypeGet() == TYP_BYREF)) || // Created for spill clique import.
(tree->TypeIs(TYP_BYREF) && (varDsc->TypeGet() == TYP_I_IMPL)) || // Created by inliner substitution.
(tree->TypeIs(TYP_INT) && (varDsc->TypeGet() == TYP_LONG))); // Created by "optNarrowTree".
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4548,8 +4548,8 @@ GenTree* Compiler::fgMorphIndexAddr(GenTreeIndexAddr* indexAddr)
{
unsigned arrRefTmpNum = lvaGrabTemp(true DEBUGARG("arr expr"));
arrRefDefn = gtNewTempAssign(arrRefTmpNum, arrRef);
arrRef = gtNewLclvNode(arrRefTmpNum, arrRef->TypeGet());
arrRef2 = gtNewLclvNode(arrRefTmpNum, arrRef->TypeGet());
arrRef = gtNewLclvNode(arrRefTmpNum, lvaGetDesc(arrRefTmpNum)->TypeGet());
arrRef2 = gtNewLclvNode(arrRefTmpNum, lvaGetDesc(arrRefTmpNum)->TypeGet());
}
else
{
Expand All @@ -4563,8 +4563,8 @@ GenTree* Compiler::fgMorphIndexAddr(GenTreeIndexAddr* indexAddr)
{
unsigned indexTmpNum = lvaGrabTemp(true DEBUGARG("index expr"));
indexDefn = gtNewTempAssign(indexTmpNum, index);
index = gtNewLclvNode(indexTmpNum, index->TypeGet());
index2 = gtNewLclvNode(indexTmpNum, index->TypeGet());
index = gtNewLclvNode(indexTmpNum, lvaGetDesc(indexTmpNum)->TypeGet());
index2 = gtNewLclvNode(indexTmpNum, lvaGetDesc(indexTmpNum)->TypeGet());
}
else
{
Expand Down Expand Up @@ -17266,7 +17266,7 @@ bool Compiler::fgMorphArrayOpsStmt(MorphMDArrayTempCache* pTempCache, BasicBlock
// Side-effect; create a temp.
// unsigned newIdxLcl = m_compiler->lvaGrabTemp(true DEBUGARG("MD array index copy"));
unsigned newIdxLcl = m_pTempCache->GrabTemp(idx->TypeGet());
GenTree* newIdx = m_compiler->gtNewLclvNode(newIdxLcl, idx->TypeGet());
GenTree* newIdx = m_compiler->gtNewLclvNode(newIdxLcl, genActualType(idx));
idxToUse[i] = newIdx;
idxToCopy[i] = newIdxLcl;
anyIdxWithSideEffects = true;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/morphblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,6 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
(m_srcVarDsc->lvType == TYP_STRUCT) ? m_srcVarDsc->lvExactSize : genTypeSize(m_srcVarDsc);
if (destSize == srcSize)
{
m_srcLclNode->gtFlags |= GTF_VAR_CAST;
m_srcLclNode->ChangeOper(GT_LCL_FLD);
m_srcLclNode->gtType = destType;
m_comp->lvaSetVarDoNotEnregister(m_srcLclNum DEBUGARG(DoNotEnregisterReason::LocalField));
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5860,12 +5860,6 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu

tree->gtType = dstt;
tree->SetVNs(vnpNarrow);

/* Make sure we don't mess up the variable type */
if ((oper == GT_LCL_VAR) || (oper == GT_LCL_FLD))
{
tree->gtFlags |= GTF_VAR_CAST;
}
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8443,7 +8443,8 @@ void Compiler::fgValueNumberTree(GenTree* tree)
}
else
{
assert((varDsc->TypeGet() == TYP_I_IMPL) && lcl->TypeIs(TYP_BYREF));
assert(((varDsc->TypeGet() == TYP_I_IMPL) && lcl->TypeIs(TYP_BYREF)) ||
((varDsc->TypeGet() == TYP_BYREF) && lcl->TypeIs(TYP_LONG)));
SingleAccretion marked this conversation as resolved.
Show resolved Hide resolved
lcl->gtVNPair = wholeLclVarVNP;
}
}
Expand Down