Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1005)

Unified Diff: src/IceOperand.cpp

Issue 1318553003: Compute the loop nest depth of each CfgNode and weight Variables by it. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: calculate -> compute (consistency) Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceOperand.cpp
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp
index 32316ba6ffda6d4f1e8bcab3e1a1ddd589960695..f0c5c73f805ec0085f60348d5b0461b8115594aa 100644
--- a/src/IceOperand.cpp
+++ b/src/IceOperand.cpp
@@ -157,8 +157,16 @@ void VariableTracking::markUse(MetadataKind TrackingKind, const Inst *Instr,
CfgNode *Node, bool IsImplicit) {
(void)TrackingKind;
- // TODO(ascull): get the loop nest depth from CfgNode
- UseWeight += 1;
+ // Increment the use weight depending on the loop nest depth. The weight is
+ // exponential in the nest depth as inner loops are expected to be executed
+ // an exponentially greater number of times.
+ constexpr uint32_t LogTypicalLoopTripCount = 3; // 2^3 = 8
Jim Stichnoth 2015/09/01 22:17:37 nit: "Typical" implies knowledge we don't have. I
ascull 2015/09/03 19:52:38 Done.
+ uint32_t ThisUseWeight =
Jim Stichnoth 2015/09/01 22:17:37 Maybe SizeT instead of uint32_t?
ascull 2015/09/03 19:52:38 Done.
+ 1 << std::min(Node->getLoopNestDepth() * LogTypicalLoopTripCount, 31u);
Jim Stichnoth 2015/09/01 22:17:37 No magic constants please. :) CHAR_BIT * sizeof(T
ascull 2015/09/03 19:52:38 Done.
+ uint32_t NewWeight = UseWeight + ThisUseWeight;
+ // Make sure the weight doesn't overflow or become infinite.
+ UseWeight = NewWeight < UseWeight ? RegWeight::Inf - 1
Jim Stichnoth 2015/09/01 22:17:38 How about something defining something like RegWei
+ : std::min(NewWeight, RegWeight::Inf - 1);
if (MultiBlock == MBS_MultiBlock)
return;

Powered by Google App Engine
This is Rietveld 408576698