[LoopUnroll] Fix truncation bug in canUnrollCompletely.

Summary:
canUnrollCompletely takes `unsigned` values for `UnrolledCost` and
`RolledDynamicCost` but is passed in `uint64_t`s that are silently
truncated.  Because of this, when `UnrolledSize` is a large integer
that has a small remainder with UINT32_MAX, LLVM tries to completely
unroll loops with high trip counts.

Reviewers: mzolotukhin, chandlerc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10293

llvm-svn: 239218
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index d8ba964..e831d83 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -227,7 +227,7 @@
     bool canUnrollCompletely(Loop *L, unsigned Threshold,
                              unsigned PercentDynamicCostSavedThreshold,
                              unsigned DynamicCostSavingsDiscount,
-                             unsigned UnrolledCost, unsigned RolledDynamicCost);
+                             uint64_t UnrolledCost, uint64_t RolledDynamicCost);
   };
 }
 
@@ -768,8 +768,8 @@
 bool LoopUnroll::canUnrollCompletely(Loop *L, unsigned Threshold,
                                      unsigned PercentDynamicCostSavedThreshold,
                                      unsigned DynamicCostSavingsDiscount,
-                                     unsigned UnrolledCost,
-                                     unsigned RolledDynamicCost) {
+                                     uint64_t UnrolledCost,
+                                     uint64_t RolledDynamicCost) {
 
   if (Threshold == NoThreshold) {
     DEBUG(dbgs() << "  Can fully unroll, because no threshold is set.\n");