Possible typo in LoopUnrollPass.cpp

hi,

In "LoopUnrollPass.cpp", when trying to reduce unroll count to meet
the unroll threshold requirement in line 200 and line 206, variable
"CurrentThreshold" is used in the computation, instead of the variable
"Threshold", which is defined by:

  // Determine the current unrolling threshold. While this is normally set
  // from UnrollThreshold, it is overridden to a smaller value if the current
  // function is marked as optimize-for-size, and the unroll threshold was
  // not user specified.
  unsigned Threshold = CurrentThreshold;
  if (!UserThreshold &&
      Header->getParent()->hasFnAttr(Attribute::OptimizeForSize))
    Threshold = OptSizeUnrollThreshold;

As a result, the OptimizeForSize attribute is ignored when the pass
calculating the reduced count, which is not I expected.

Am i correct or i missed something? If i am correct, i am going to fix this.

best regards
ether

ps: the code contains typo
      if (TripCount) {
        // Reduce unroll count to be modulo of TripCount for partial unrolling
        Count = CurrentThreshold / LoopSize;
<--------------------------should use Threshold
        while (Count != 0 && TripCount%Count != 0)
          Count--;
      }
      else if (UnrollRuntime) {
        // Reduce unroll count to be a lower power-of-two value
        while (Count != 0 && Size > CurrentThreshold) {
<--------------------------should use Threshold
          Count >>= 1;
          Size = LoopSize*Count;
        }
      }

Hi Ether,

I think you're correct. The references to CurrentThreshold that you've
pointed out should be replaced with Threshold.

-- Brendon