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

Commit dd63211

Browse files
committed
Remove pointless use of GTF_ZSF_SET
It doesn't make sense to ContainCheckBinary and others set GTF_ZSF_SET on all nodes. There are far more ADD/SUB/AND/OR/XOR nodes than relop nodes that may reuse the flags set by the previous node.
1 parent 7b29e9f commit dd63211

File tree

4 files changed

+6
-27
lines changed

4 files changed

+6
-27
lines changed

src/jit/compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9781,11 +9781,11 @@ int cTreeFlagsIR(Compiler* comp, GenTree* tree)
97819781
{
97829782
chars += printf("[SPILLED_OP2]");
97839783
}
9784-
#endif
97859784
if (tree->gtFlags & GTF_ZSF_SET)
97869785
{
97879786
chars += printf("[ZSF_SET]");
97889787
}
9788+
#endif
97899789
#if FEATURE_SET_FLAGS
97909790
if (tree->gtFlags & GTF_SET_FLAGS)
97919791
{

src/jit/gentree.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,11 @@ struct GenTree
856856
#ifdef LEGACY_BACKEND
857857
#define GTF_SPILLED_OPER 0x00000100 // op1 has been spilled
858858
#define GTF_SPILLED_OP2 0x00000200 // op2 has been spilled
859+
#define GTF_ZSF_SET 0x00000400 // the zero(ZF) and sign(SF) flags set to the operand
859860
#else // !LEGACY_BACKEND
860861
#define GTF_NOREG_AT_USE 0x00000100 // tree node is in memory at the point of use
861862
#endif // !LEGACY_BACKEND
862863

863-
#define GTF_ZSF_SET 0x00000400 // the zero(ZF) and sign(SF) flags set to the operand
864864
#define GTF_SET_FLAGS 0x00000800 // Requires that codegen for this node set the flags. Use gtSetFlags() to check this flag.
865865
#define GTF_USE_FLAGS 0x00001000 // Indicates that this node uses the flags bits.
866866

@@ -2123,12 +2123,14 @@ struct GenTree
21232123
bool gtSetFlags() const;
21242124
bool gtRequestSetFlags();
21252125

2126+
#ifdef LEGACY_BACKEND
21262127
// Returns true if the codegen of this tree node
21272128
// sets ZF and SF flags.
21282129
bool gtSetZSFlags() const
21292130
{
21302131
return (gtFlags & GTF_ZSF_SET) != 0;
21312132
}
2133+
#endif
21322134

21332135
#ifdef DEBUG
21342136
bool gtIsValid64RsltMul();

src/jit/lower.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,6 @@ GenTree* Lowering::LowerNode(GenTree* node)
142142
ContainCheckBinary(node->AsOp());
143143
break;
144144

145-
#ifdef _TARGET_XARCH_
146-
case GT_NEG:
147-
// Codegen of this tree node sets ZF and SF flags.
148-
if (!varTypeIsFloating(node))
149-
{
150-
node->gtFlags |= GTF_ZSF_SET;
151-
}
152-
break;
153-
#endif // _TARGET_XARCH_
154-
155145
case GT_MUL:
156146
case GT_MULHI:
157147
#if defined(_TARGET_X86_) && !defined(LEGACY_BACKEND)
@@ -2618,8 +2608,8 @@ GenTree* Lowering::LowerCompare(GenTree* cmp)
26182608
GenTree* op2 = cmp->gtGetOp2();
26192609
LIR::Use cmpUse;
26202610

2621-
if (op1->gtSetZSFlags() && op2->IsIntegralConst(0) && (op1->gtNext == op2) && (op2->gtNext == cmp) &&
2622-
BlockRange().TryGetUse(cmp, &cmpUse))
2611+
if (op1->OperIs(GT_AND, GT_OR, GT_XOR, GT_ADD, GT_SUB, GT_NEG) && op2->IsIntegralConst(0) &&
2612+
(op1->gtNext == op2) && (op2->gtNext == cmp) && BlockRange().TryGetUse(cmp, &cmpUse))
26232613
{
26242614
genTreeOps condition = cmp->OperGet();
26252615
GenTree* next = cmp->gtNext;
@@ -5402,16 +5392,6 @@ void Lowering::ContainCheckNode(GenTree* node)
54025392
ContainCheckBinary(node->AsOp());
54035393
break;
54045394

5405-
#ifdef _TARGET_XARCH_
5406-
case GT_NEG:
5407-
// Codegen of this tree node sets ZF and SF flags.
5408-
if (!varTypeIsFloating(node))
5409-
{
5410-
node->gtFlags |= GTF_ZSF_SET;
5411-
}
5412-
break;
5413-
#endif // _TARGET_XARCH_
5414-
54155395
#if defined(_TARGET_X86_)
54165396
case GT_MUL_LONG:
54175397
#endif

src/jit/lowerxarch.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,9 +2010,6 @@ void Lowering::ContainCheckBinary(GenTreeOp* node)
20102010
return;
20112011
}
20122012

2013-
// Codegen of these tree nodes sets ZF and SF flags.
2014-
node->gtFlags |= GTF_ZSF_SET;
2015-
20162013
// We're not marking a constant hanging on the left of an add
20172014
// as containable so we assign it to a register having CQ impact.
20182015
// TODO-XArch-CQ: Detect this case and support both generating a single instruction

0 commit comments

Comments
 (0)