Skip to content

Commit 5f17108

Browse files
Delete GTF_VAR_CAST
It is unused. Tighten an assert in the ref counter.
1 parent 1f761f5 commit 5f17108

File tree

8 files changed

+22
-78
lines changed

8 files changed

+22
-78
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9219,10 +9219,6 @@ void cTreeFlags(Compiler* comp, GenTree* tree)
92199219
{
92209220
chars += printf("[VAR_USEASG]");
92219221
}
9222-
if (tree->gtFlags & GTF_VAR_CAST)
9223-
{
9224-
chars += printf("[VAR_CAST]");
9225-
}
92269222
if (tree->gtFlags & GTF_VAR_ITERATOR)
92279223
{
92289224
chars += printf("[VAR_ITERATOR]");

src/coreclr/jit/gentree.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10424,12 +10424,6 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
1042410424
--msgLength;
1042510425
break;
1042610426
}
10427-
if (tree->gtFlags & GTF_VAR_CAST)
10428-
{
10429-
printf("C");
10430-
--msgLength;
10431-
break;
10432-
}
1043310427
if (tree->gtFlags & GTF_VAR_CONTEXT)
1043410428
{
1043510429
printf("!");

src/coreclr/jit/gentree.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,10 @@ enum GenTreeFlags : unsigned int
468468

469469
GTF_LIVENESS_MASK = GTF_VAR_DEF | GTF_VAR_USEASG | GTF_VAR_DEATH_MASK,
470470

471-
GTF_VAR_CAST = 0x01000000, // GT_LCL_VAR -- has been explicitly cast (variable node may not be type of local)
472-
GTF_VAR_ITERATOR = 0x00800000, // GT_LCL_VAR -- this is a iterator reference in the loop condition
473-
GTF_VAR_CLONED = 0x00400000, // GT_LCL_VAR -- this node has been cloned or is a clone
474-
GTF_VAR_CONTEXT = 0x00200000, // GT_LCL_VAR -- this node is part of a runtime lookup
475-
GTF_VAR_FOLDED_IND = 0x00100000, // GT_LCL_VAR -- this node was folded from *(typ*)&lclVar expression tree in fgMorphSmpOp()
471+
GTF_VAR_ITERATOR = 0x01000000, // GT_LCL_VAR -- this is a iterator reference in the loop condition
472+
GTF_VAR_CLONED = 0x00800000, // GT_LCL_VAR -- this node has been cloned or is a clone
473+
GTF_VAR_CONTEXT = 0x00400000, // GT_LCL_VAR -- this node is part of a runtime lookup
474+
GTF_VAR_FOLDED_IND = 0x00200000, // GT_LCL_VAR -- this node was folded from *(typ*)&lclVar expression tree in fgMorphSmpOp()
476475
// where 'typ' is a small type and 'lclVar' corresponds to a normalized-on-store local variable.
477476
// This flag identifies such nodes in order to make sure that fgDoNormalizeOnStore() is called
478477
// on their parents in post-order morph.
@@ -2313,20 +2312,18 @@ struct GenTree
23132312
bool IsReuseRegVal() const
23142313
{
23152314
// This can be extended to non-constant nodes, but not to local or indir nodes.
2316-
if (IsInvariant() && ((gtFlags & GTF_REUSE_REG_VAL) != 0))
2317-
{
2318-
return true;
2319-
}
2320-
return false;
2315+
return OperIsConst() && ((gtFlags & GTF_REUSE_REG_VAL) != 0);
23212316
}
2317+
23222318
void SetReuseRegVal()
23232319
{
2324-
assert(IsInvariant());
2320+
assert(OperIsConst());
23252321
gtFlags |= GTF_REUSE_REG_VAL;
23262322
}
2323+
23272324
void ResetReuseRegVal()
23282325
{
2329-
assert(IsInvariant());
2326+
assert(OperIsConst());
23302327
gtFlags &= ~GTF_REUSE_REG_VAL;
23312328
}
23322329

src/coreclr/jit/lclvars.cpp

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4435,7 +4435,7 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,
44354435

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

4449-
bool allowStructs = false;
4450-
#ifdef UNIX_AMD64_ABI
4451-
// On System V the type of the var could be a struct type.
4452-
allowStructs = varTypeIsStruct(varDsc);
4453-
#endif // UNIX_AMD64_ABI
4454-
4455-
/* Variables must be used as the same type throughout the method */
4456-
noway_assert(varDsc->lvType == TYP_UNDEF || tree->gtType == TYP_UNKNOWN || allowStructs ||
4457-
genActualType(varDsc->TypeGet()) == genActualType(tree->gtType) ||
4458-
(tree->gtType == TYP_BYREF && varDsc->TypeGet() == TYP_I_IMPL) ||
4459-
(tree->gtType == TYP_I_IMPL && varDsc->TypeGet() == TYP_BYREF) || (tree->gtFlags & GTF_VAR_CAST) ||
4460-
(varTypeIsFloating(varDsc) && varTypeIsFloating(tree)) ||
4461-
(varTypeIsStruct(varDsc) == varTypeIsStruct(tree)));
4462-
4463-
/* Remember the type of the reference */
4464-
4465-
if (tree->gtType == TYP_UNKNOWN || varDsc->lvType == TYP_UNDEF)
4466-
{
4467-
varDsc->lvType = tree->gtType;
4468-
noway_assert(genActualType(varDsc->TypeGet()) == tree->gtType); // no truncation
4469-
}
4470-
4471-
#ifdef DEBUG
4472-
if (tree->gtFlags & GTF_VAR_CAST)
4473-
{
4474-
// it should never be bigger than the variable slot
4475-
4476-
// Trees don't store the full information about structs
4477-
// so we can't check them.
4478-
if (tree->TypeGet() != TYP_STRUCT)
4479-
{
4480-
unsigned treeSize = genTypeSize(tree->TypeGet());
4481-
unsigned varSize = genTypeSize(varDsc->TypeGet());
4482-
if (varDsc->TypeGet() == TYP_STRUCT)
4483-
{
4484-
varSize = varDsc->lvSize();
4485-
}
4486-
4487-
assert(treeSize <= varSize);
4488-
}
4489-
}
4490-
#endif
4449+
// Check that the LCL_VAR node has the same type as the underlying variable, save a few mismatches we allow.
4450+
assert(tree->TypeIs(varDsc->TypeGet(), genActualType(varDsc)) ||
4451+
(tree->TypeIs(TYP_I_IMPL) && (varDsc->TypeGet() == TYP_BYREF)) || // Created for spill clique import.
4452+
(tree->TypeIs(TYP_BYREF) && (varDsc->TypeGet() == TYP_I_IMPL)) || // Created by inliner substitution.
4453+
(tree->TypeIs(TYP_INT) && (varDsc->TypeGet() == TYP_LONG))); // Created by "optNarrowTree".
44914454
}
44924455
}
44934456

src/coreclr/jit/morph.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4548,8 +4548,8 @@ GenTree* Compiler::fgMorphIndexAddr(GenTreeIndexAddr* indexAddr)
45484548
{
45494549
unsigned arrRefTmpNum = lvaGrabTemp(true DEBUGARG("arr expr"));
45504550
arrRefDefn = gtNewTempAssign(arrRefTmpNum, arrRef);
4551-
arrRef = gtNewLclvNode(arrRefTmpNum, arrRef->TypeGet());
4552-
arrRef2 = gtNewLclvNode(arrRefTmpNum, arrRef->TypeGet());
4551+
arrRef = gtNewLclvNode(arrRefTmpNum, lvaGetDesc(arrRefTmpNum)->TypeGet());
4552+
arrRef2 = gtNewLclvNode(arrRefTmpNum, lvaGetDesc(arrRefTmpNum)->TypeGet());
45534553
}
45544554
else
45554555
{
@@ -4563,8 +4563,8 @@ GenTree* Compiler::fgMorphIndexAddr(GenTreeIndexAddr* indexAddr)
45634563
{
45644564
unsigned indexTmpNum = lvaGrabTemp(true DEBUGARG("index expr"));
45654565
indexDefn = gtNewTempAssign(indexTmpNum, index);
4566-
index = gtNewLclvNode(indexTmpNum, index->TypeGet());
4567-
index2 = gtNewLclvNode(indexTmpNum, index->TypeGet());
4566+
index = gtNewLclvNode(indexTmpNum, lvaGetDesc(indexTmpNum)->TypeGet());
4567+
index2 = gtNewLclvNode(indexTmpNum, lvaGetDesc(indexTmpNum)->TypeGet());
45684568
}
45694569
else
45704570
{
@@ -17266,7 +17266,7 @@ bool Compiler::fgMorphArrayOpsStmt(MorphMDArrayTempCache* pTempCache, BasicBlock
1726617266
// Side-effect; create a temp.
1726717267
// unsigned newIdxLcl = m_compiler->lvaGrabTemp(true DEBUGARG("MD array index copy"));
1726817268
unsigned newIdxLcl = m_pTempCache->GrabTemp(idx->TypeGet());
17269-
GenTree* newIdx = m_compiler->gtNewLclvNode(newIdxLcl, idx->TypeGet());
17269+
GenTree* newIdx = m_compiler->gtNewLclvNode(newIdxLcl, genActualType(idx));
1727017270
idxToUse[i] = newIdx;
1727117271
idxToCopy[i] = newIdxLcl;
1727217272
anyIdxWithSideEffects = true;

src/coreclr/jit/morphblock.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,6 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
14091409
(m_srcVarDsc->lvType == TYP_STRUCT) ? m_srcVarDsc->lvExactSize : genTypeSize(m_srcVarDsc);
14101410
if (destSize == srcSize)
14111411
{
1412-
m_srcLclNode->gtFlags |= GTF_VAR_CAST;
14131412
m_srcLclNode->ChangeOper(GT_LCL_FLD);
14141413
m_srcLclNode->gtType = destType;
14151414
m_comp->lvaSetVarDoNotEnregister(m_srcLclNum DEBUGARG(DoNotEnregisterReason::LocalField));

src/coreclr/jit/optimizer.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5860,12 +5860,6 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu
58605860

58615861
tree->gtType = dstt;
58625862
tree->SetVNs(vnpNarrow);
5863-
5864-
/* Make sure we don't mess up the variable type */
5865-
if ((oper == GT_LCL_VAR) || (oper == GT_LCL_FLD))
5866-
{
5867-
tree->gtFlags |= GTF_VAR_CAST;
5868-
}
58695863
}
58705864

58715865
return true;

src/coreclr/jit/valuenum.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8443,7 +8443,8 @@ void Compiler::fgValueNumberTree(GenTree* tree)
84438443
}
84448444
else
84458445
{
8446-
assert((varDsc->TypeGet() == TYP_I_IMPL) && lcl->TypeIs(TYP_BYREF));
8446+
assert(((varDsc->TypeGet() == TYP_I_IMPL) && lcl->TypeIs(TYP_BYREF)) ||
8447+
((varDsc->TypeGet() == TYP_BYREF) && lcl->TypeIs(TYP_LONG)));
84478448
lcl->gtVNPair = wholeLclVarVNP;
84488449
}
84498450
}

0 commit comments

Comments
 (0)