diff options
author | Pat Gavlin <pagavlin@microsoft.com> | 2017-07-18 09:24:26 -0700 |
---|---|---|
committer | Pat Gavlin <pagavlin@microsoft.com> | 2017-07-18 14:10:53 -0700 |
commit | 058c8e068fe484dfdd280d5956f66f88f1a0e095 (patch) | |
tree | f56129de08ce092afaa16dff3537351bec48cc46 | |
parent | d9925811fc787ed0668c73cc3155ffb2e24d161d (diff) | |
download | coreclr-058c8e068fe484dfdd280d5956f66f88f1a0e095.tar.gz coreclr-058c8e068fe484dfdd280d5956f66f88f1a0e095.tar.bz2 coreclr-058c8e068fe484dfdd280d5956f66f88f1a0e095.zip |
Add helpers to set, clear, and check IsUnusedValue.
Just what it says on the tin.
-rw-r--r-- | src/jit/decomposelongs.cpp | 20 | ||||
-rw-r--r-- | src/jit/gentree.h | 5 | ||||
-rw-r--r-- | src/jit/lir.cpp | 9 | ||||
-rw-r--r-- | src/jit/lir.h | 27 | ||||
-rw-r--r-- | src/jit/liveness.cpp | 2 | ||||
-rw-r--r-- | src/jit/lower.cpp | 8 | ||||
-rw-r--r-- | src/jit/lsra.cpp | 3 | ||||
-rw-r--r-- | src/jit/lsraarm.cpp | 2 | ||||
-rw-r--r-- | src/jit/lsraxarch.cpp | 2 | ||||
-rw-r--r-- | src/jit/rationalize.cpp | 8 |
10 files changed, 52 insertions, 34 deletions
diff --git a/src/jit/decomposelongs.cpp b/src/jit/decomposelongs.cpp index 9c67549012..96d3b0bb71 100644 --- a/src/jit/decomposelongs.cpp +++ b/src/jit/decomposelongs.cpp @@ -341,11 +341,11 @@ GenTree* DecomposeLongs::FinalizeDecomposition(LIR::Use& use, GenTree* gtLong = new (m_compiler, GT_LONG) GenTreeOp(GT_LONG, TYP_LONG, loResult, hiResult); if (use.IsDummyUse()) { - gtLong->gtLIRFlags |= LIR::Flags::IsUnusedValue; + gtLong->SetUnusedValue(); } - loResult->gtLIRFlags &= ~LIR::Flags::IsUnusedValue; - hiResult->gtLIRFlags &= ~LIR::Flags::IsUnusedValue; + loResult->ClearUnusedValue(); + hiResult->ClearUnusedValue(); Range().InsertAfter(insertResultAfter, gtLong); @@ -1127,7 +1127,7 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use) } else { - hiOp1->gtLIRFlags |= LIR::Flags::IsUnusedValue; + hiOp1->SetUnusedValue(); } if (count < 64) @@ -1175,7 +1175,7 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use) } else { - loOp1->gtLIRFlags |= LIR::Flags::IsUnusedValue; + loOp1->SetUnusedValue(); } // Zero out hi (shift of >= 64 bits moves all the bits out of the two registers) @@ -1235,7 +1235,7 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use) } else { - loOp1->gtLIRFlags |= LIR::Flags::IsUnusedValue; + loOp1->SetUnusedValue(); } assert(count >= 32); @@ -1271,7 +1271,7 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use) } else { - hiOp1->gtLIRFlags |= LIR::Flags::IsUnusedValue; + hiOp1->SetUnusedValue(); } // Zero out lo @@ -1333,7 +1333,7 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use) } else { - loOp1->gtLIRFlags |= LIR::Flags::IsUnusedValue; + loOp1->SetUnusedValue(); } if (count < 64) @@ -1426,9 +1426,9 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use) GenTree* call = m_compiler->gtNewHelperCallNode(helper, TYP_LONG, 0, argList); call->gtFlags |= shift->gtFlags & GTF_ALL_EFFECT; - if ((shift->gtLIRFlags & LIR::Flags::IsUnusedValue) != 0) + if (shift->IsUnusedValue()) { - call->gtLIRFlags |= LIR::Flags::IsUnusedValue; + call->SetUnusedValue(); } GenTreeCall* callNode = call->AsCall(); diff --git a/src/jit/gentree.h b/src/jit/gentree.h index 08154367cb..33d6b203fb 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -1169,6 +1169,11 @@ public: } } + // NOTE: the three UnusedValue helpers immediately below are defined in lir.h. + inline void SetUnusedValue(); + inline void ClearUnusedValue(); + inline bool IsUnusedValue() const; + bool OperIs(genTreeOps oper) { return OperGet() == oper; diff --git a/src/jit/lir.cpp b/src/jit/lir.cpp index b5a6adb035..ecfe6c5dbd 100644 --- a/src/jit/lir.cpp +++ b/src/jit/lir.cpp @@ -981,7 +981,7 @@ void LIR::Range::Remove(GenTree* node, bool markOperandsUnused) if (markOperandsUnused) { node->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { - operand->gtLIRFlags |= Flags::IsUnusedValue; + operand->SetUnusedValue(); return GenTree::VisitResult::Continue; }); } @@ -1189,7 +1189,7 @@ bool LIR::Range::TryGetUse(GenTree* node, Use* use) // Don't bother looking for uses of nodes that are not values. // If the node is the last node, we won't find a use (and we would // end up creating an illegal range if we tried). - if (node->IsValue() && ((node->gtLIRFlags & Flags::IsUnusedValue) == 0) && (node != LastNode())) + if (node->IsValue() && !node->IsUnusedValue() && (node != LastNode())) { for (GenTree* n : ReadOnlyRange(node->gtNext, m_lastNode)) { @@ -1499,8 +1499,7 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const { GenTree* def = *useEdge; - assert((!checkUnusedValues || ((def->gtLIRFlags & LIR::Flags::IsUnusedValue) == 0)) && - "operands should never be marked as unused values"); + assert(!(checkUnusedValues && def->IsUnusedValue()) && "operands should never be marked as unused values"); if (def->OperGet() == GT_ARGPLACE) { @@ -1562,7 +1561,7 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const for (auto kvp : unusedDefs) { GenTree* node = kvp.Key(); - assert(((node->gtLIRFlags & LIR::Flags::IsUnusedValue) != 0) && "found an unmarked unused value"); + assert(node->IsUnusedValue() && "found an unmarked unused value"); } } diff --git a/src/jit/lir.h b/src/jit/lir.h index 088b5e523f..762c79c3c3 100644 --- a/src/jit/lir.h +++ b/src/jit/lir.h @@ -32,12 +32,12 @@ public: // a more expensive data structure when processing a set // of LIR nodes. See for example `LIR::GetTreeRange`. - IsUnusedValue = 0x02, // Set on a node if it produces a value that is not - // subsequently used. Should never be set on nodes - // that return `false` for `GenTree::IsValue`. Note - // that this bit should not be assumed to be valid - // at all points during compilation: it is currently - // only computed during target-dependent lowering. + UnusedValue = 0x02, // Set on a node if it produces a value that is not + // subsequently used. Should never be set on nodes + // that return `false` for `GenTree::IsValue`. Note + // that this bit should not be assumed to be valid + // at all points during compilation: it is currently + // only computed during target-dependent lowering. }; }; @@ -309,4 +309,19 @@ public: static void InsertBeforeTerminator(BasicBlock* block, LIR::Range&& range); }; +inline void GenTree::SetUnusedValue() +{ + gtLIRFlags |= LIR::Flags::UnusedValue; +} + +inline void GenTree::ClearUnusedValue() +{ + gtLIRFlags &= ~LIR::Flags::UnusedValue; +} + +inline bool GenTree::IsUnusedValue() const +{ + return (gtLIRFlags & LIR::Flags::UnusedValue) != 0; +} + #endif // _LIR_H_ diff --git a/src/jit/liveness.cpp b/src/jit/liveness.cpp index 432ac80065..4b8d602aac 100644 --- a/src/jit/liveness.cpp +++ b/src/jit/liveness.cpp @@ -2359,7 +2359,7 @@ bool Compiler::fgTryRemoveDeadLIRStore(LIR::Range& blockRange, GenTree* node, Ge // do not remove it. Instead, just remove the store. store->VisitOperands([](GenTree* operand) -> GenTree::VisitResult { - operand->gtLIRFlags |= LIR::Flags::IsUnusedValue; + operand->SetUnusedValue(); return GenTree::VisitResult::Continue; }); diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp index 42e43103e5..7981972c33 100644 --- a/src/jit/lower.cpp +++ b/src/jit/lower.cpp @@ -2216,7 +2216,7 @@ void Lowering::LowerCompare(GenTree* cmp) } else { - loSrc1->gtLIRFlags |= LIR::Flags::IsUnusedValue; + loSrc1->SetUnusedValue(); } hiCmp = comp->gtNewOperNode(GT_CMP, TYP_VOID, hiSrc1, hiSrc2); @@ -2247,7 +2247,7 @@ void Lowering::LowerCompare(GenTree* cmp) hiCmp->gtFlags |= GTF_SET_FLAGS; if (hiCmp->IsValue()) { - hiCmp->gtLIRFlags |= LIR::Flags::IsUnusedValue; + hiCmp->SetUnusedValue(); } LIR::Use cmpUse; @@ -4538,7 +4538,7 @@ GenTree* Lowering::LowerArrElem(GenTree* node) } else { - leaNode->gtLIRFlags |= LIR::Flags::IsUnusedValue; + leaNode->SetUnusedValue(); } BlockRange().Remove(arrElem); @@ -4682,7 +4682,7 @@ void Lowering::DoPhase() assert((node->gtLsraInfo.dstCount == 0) || node->IsValue()); // If the node produces an unused value, mark it as a local def-use - if (node->IsValue() && ((node->gtLIRFlags & LIR::Flags::IsUnusedValue) != 0)) + if (node->IsValue() && node->IsUnusedValue()) { node->gtLsraInfo.isLocalDefUse = true; node->gtLsraInfo.dstCount = 0; diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp index 2261f87424..28617b9583 100644 --- a/src/jit/lsra.cpp +++ b/src/jit/lsra.cpp @@ -4714,8 +4714,7 @@ void LinearScan::buildIntervals() for (GenTree* node : blockRange.NonPhiNodes()) { assert(node->gtLsraInfo.loc >= currentLoc); - assert(!node->IsValue() || ((node->gtLIRFlags & LIR::Flags::IsUnusedValue) == 0) || - node->gtLsraInfo.isLocalDefUse); + assert(!node->IsValue() || !node->IsUnusedValue() || node->gtLsraInfo.isLocalDefUse); currentLoc = node->gtLsraInfo.loc; buildRefPositionsForNode(node, block, listNodePool, operandToLocationInfoMap, currentLoc); diff --git a/src/jit/lsraarm.cpp b/src/jit/lsraarm.cpp index 1f79ed8320..053b593e20 100644 --- a/src/jit/lsraarm.cpp +++ b/src/jit/lsraarm.cpp @@ -462,7 +462,7 @@ void Lowering::TreeNodeInfoInit(GenTree* tree) break; case GT_LONG: - if ((tree->gtLIRFlags & LIR::Flags::IsUnusedValue) != 0) + if (tree->IsUnusedValue()) { // An unused GT_LONG node needs to consume its sources. info->srcCount = 2; diff --git a/src/jit/lsraxarch.cpp b/src/jit/lsraxarch.cpp index a30a4f9e51..6613fc3ba3 100644 --- a/src/jit/lsraxarch.cpp +++ b/src/jit/lsraxarch.cpp @@ -169,7 +169,7 @@ void Lowering::TreeNodeInfoInit(GenTree* tree) #if !defined(_TARGET_64BIT_) case GT_LONG: - if ((tree->gtLIRFlags & LIR::Flags::IsUnusedValue) != 0) + if (tree->IsUnusedValue()) { // An unused GT_LONG node needs to consume its sources. info->srcCount = 2; diff --git a/src/jit/rationalize.cpp b/src/jit/rationalize.cpp index 875d9ec9f3..23d4f99fb8 100644 --- a/src/jit/rationalize.cpp +++ b/src/jit/rationalize.cpp @@ -750,9 +750,9 @@ Compiler::fgWalkResult Rationalizer::RewriteNode(GenTree** useEdge, ArrayStack<G BlockRange().Delete(comp, m_block, std::move(lhsRange)); } - else + else if (op1->IsValue()) { - op1->gtLIRFlags |= LIR::Flags::IsUnusedValue; + op1->SetUnusedValue(); } BlockRange().Remove(node); @@ -953,9 +953,9 @@ Compiler::fgWalkResult Rationalizer::RewriteNode(GenTree** useEdge, ArrayStack<G node->gtFlags &= ~GTF_CALL; } - if (use.IsDummyUse()) + if (node->IsValue() && use.IsDummyUse()) { - node->gtLIRFlags |= LIR::Flags::IsUnusedValue; + node->SetUnusedValue(); } if (node->TypeGet() == TYP_LONG) |