diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 25 | 
1 files changed, 13 insertions, 12 deletions
| diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index e43c9e2708d..0401b9a7f7d 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -748,21 +748,22 @@ static void GetBranchWeights(TerminatorInst *TI,    }  } -/// Sees if any of the weights are too big for a uint32_t, and halves all the -/// weights if any are. +/// Keep halving the weights until all can fit in uint32_t.  static void FitWeights(MutableArrayRef<uint64_t> Weights) { -  bool Halve = false; -  for (unsigned i = 0; i < Weights.size(); ++i) -    if (Weights[i] > UINT_MAX) { -      Halve = true; -      break; -    } +  while (true) { +    bool Halve = false; +    for (unsigned i = 0; i < Weights.size(); ++i) +      if (Weights[i] > UINT_MAX) { +        Halve = true; +        break; +      } -  if (! Halve) -    return; +    if (! Halve) +      return; -  for (unsigned i = 0; i < Weights.size(); ++i) -    Weights[i] /= 2; +    for (unsigned i = 0; i < Weights.size(); ++i) +      Weights[i] /= 2; +  }  }  /// FoldValueComparisonIntoPredecessors - The specified terminator is a value | 

