Chromium Code Reviews| 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; |