[LoopUnroll] Fix truncation bug in canUnrollCompletely.
authorSanjoy Das <sanjoy@playingwithpointers.com>
Sat, 6 Jun 2015 05:24:10 +0000 (05:24 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Sat, 6 Jun 2015 05:24:10 +0000 (05:24 +0000)
commit68081f41fafc13e194dfa639a3219b21c176489f
treec17d8d1e019adb49a31425c715af8c422a66bc1a
parente46e8af4d7f36f7d14acd515c11c61a9bc9deea5
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239218 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LoopUnrollPass.cpp
test/Transforms/LoopUnroll/full-unroll-bad-cost.ll [new file with mode: 0644]