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

Commit 8e8f049

Browse files
authored
Merge pull request #6077 from pgavlin/RemoveGtfDead
Remove GTF_DEAD.
2 parents 7487889 + a26d86b commit 8e8f049

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

src/jit/compiler.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8280,12 +8280,6 @@ int cTreeFlagsIR(Compiler *comp, GenTree *tree)
82808280
chars += printf("[IND_NONFAULTING]");
82818281
}
82828282
}
8283-
#if FEATURE_ANYCSE
8284-
if (tree->gtFlags & GTF_DEAD)
8285-
{
8286-
chars += printf("[DEAD]");
8287-
}
8288-
#endif
82898283
if (tree->gtFlags & GTF_MAKE_CSE)
82908284
{
82918285
chars += printf("[MAKE_CSE]");

src/jit/gentree.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,11 +635,14 @@ struct GenTree
635635
#define GTF_GLOB_EFFECT (GTF_SIDE_EFFECT|GTF_GLOB_REF)
636636
#define GTF_ALL_EFFECT (GTF_GLOB_EFFECT|GTF_ORDER_SIDEEFF)
637637

638-
// The extra flag GTF_DEAD is used to tell the consumer of these flags
639-
// that we are calling in the context of performing a CSE, thus we
638+
// The extra flag GTF_IS_IN_CSE is used to tell the consumer of these flags
639+
// that we are calling in the context of performing a CSE, thus we
640640
// should allow the run-once side effects of running a class constructor.
641641
//
642-
#define GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE (GTF_ASG|GTF_CALL|GTF_DEAD)
642+
// The only requirement of this flag is that it not overlap any of the
643+
// side-effect flags. The actual bit used is otherwise arbitrary.
644+
#define GTF_IS_IN_CSE GTF_MAKE_CSE
645+
#define GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE (GTF_ASG|GTF_CALL|GTF_IS_IN_CSE)
643646

644647
// Can any side-effects be observed externally, say by a caller method?
645648
// For assignments, only assignments to global memory can be observed
@@ -673,10 +676,6 @@ struct GenTree
673676
#endif
674677
#define GTF_IND_NONFAULTING 0x00000800 // An indir that cannot fault. GTF_SET_FLAGS is not used on indirs
675678

676-
#if FEATURE_ANYCSE
677-
#define GTF_DEAD 0x00001000 // this node won't be used any more
678-
#endif // FEATURE_ANYCSE
679-
680679
#define GTF_MAKE_CSE 0x00002000 // Hoisted Expression: try hard to make this into CSE (see optPerformHoistExpr)
681680
#define GTF_DONT_CSE 0x00004000 // don't bother CSE'ing this expr
682681
#define GTF_COLON_COND 0x00008000 // this node is conditionally executed (part of ? :)

src/jit/optcse.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ Compiler::CSEdsc * Compiler::optCSEfindDsc(unsigned index)
8787

8888
void Compiler::optUnmarkCSE(GenTreePtr tree)
8989
{
90-
noway_assert(IS_CSE_INDEX(tree->gtCSEnum));
90+
if (!IS_CSE_INDEX(tree->gtCSEnum))
91+
{
92+
// This tree is not a CSE candidate, so there is nothing
93+
// to do.
94+
return;
95+
}
9196

9297
unsigned CSEnum = GET_CSE_INDEX(tree->gtCSEnum);
9398
CSEdsc * desc;
@@ -230,7 +235,6 @@ Compiler::fgWalkResult Compiler::optUnmarkCSEs(GenTreePtr *pTree, fgWalkDat
230235
if (tree == op1)
231236
{
232237
// This tree and all of its sub trees are being kept
233-
// so we skip marking with GTF_DEAD, etc...
234238
return WALK_SKIP_SUBTREES;
235239
}
236240

@@ -242,20 +246,14 @@ Compiler::fgWalkResult Compiler::optUnmarkCSEs(GenTreePtr *pTree, fgWalkDat
242246
if (tree == keptTree)
243247
{
244248
// This tree and all of its sub trees are being kept
245-
// so we skip marking with GTF_DEAD, etc...
246249
return WALK_SKIP_SUBTREES;
247250
}
248251
}
249252

250253
// This node is being removed from the graph of GenTreePtr
251-
// Mark with GTF_DEAD, call optUnmarkCSE and
252-
// decrement the LclVar ref counts.
253-
//
254-
assert((tree->gtFlags & GTF_DEAD) == 0);
255-
tree->gtFlags |= GTF_DEAD;
256-
257-
if (IS_CSE_INDEX(tree->gtCSEnum))
258-
comp->optUnmarkCSE(tree);
254+
// Call optUnmarkCSE and decrement the LclVar ref counts.
255+
comp->optUnmarkCSE(tree);
256+
assert(!IS_CSE_INDEX(tree->gtCSEnum));
259257

260258
/* Look for any local variable references */
261259

@@ -1713,13 +1711,8 @@ class CSE_Heuristic
17131711
// Assert if we used DEBUG_DESTROY_NODE on this CSE exp
17141712
assert(exp->gtOper != GT_COUNT);
17151713

1716-
/* Ignore the node if it's part of a removed CSE */
1717-
if (exp->gtFlags & GTF_DEAD)
1718-
continue;
1719-
17201714
/* Ignore the node if it's not been marked as a CSE */
1721-
1722-
if (!IS_CSE_INDEX(exp->gtCSEnum))
1715+
if (!IS_CSE_INDEX(exp->gtCSEnum))
17231716
continue;
17241717

17251718
/* Make sure we update the weighted ref count correctly */

src/jit/optimizer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6832,8 +6832,7 @@ Compiler::fgWalkResult Compiler::optRemoveTreeVisitor(GenTreePtr *pTree, fg
68326832
//
68336833
if (tree == op1)
68346834
{
6835-
// This tree and all of its sub trees are being kept
6836-
// so we skip marking with GTF_DEAD, etc...
6835+
// This tree and all of its sub trees are being kept.
68376836
return WALK_SKIP_SUBTREES;
68386837
}
68396838

@@ -6844,8 +6843,7 @@ Compiler::fgWalkResult Compiler::optRemoveTreeVisitor(GenTreePtr *pTree, fg
68446843
}
68456844
if (tree == keptTree)
68466845
{
6847-
// This tree and all of its sub trees are being kept
6848-
// so we skip marking with GTF_DEAD, etc...
6846+
// This tree and all of its sub trees are being kept.
68496847
return WALK_SKIP_SUBTREES;
68506848
}
68516849
}

0 commit comments

Comments
 (0)