Fix a trip-count overflow issue in LoopUnroll.
authorMichael Zolotukhin <mzolotukhin@apple.com>
Thu, 20 Nov 2014 20:19:55 +0000 (20:19 +0000)
committerMichael Zolotukhin <mzolotukhin@apple.com>
Thu, 20 Nov 2014 20:19:55 +0000 (20:19 +0000)
commit4e7b10b07f0ca2c8185e96bdc58ae4d9d540b3a4
treedaf02aed512ca1f354e9af1671ffb7545e99129f
parentd23f04a165d7682fc09f5944cac66a7895e48dfe
Fix a trip-count overflow issue in LoopUnroll.

Currently LoopUnroll generates a prologue loop before the main loop
body to execute first N%UnrollFactor iterations. Also, this loop is
used if trip-count can overflow - it's determined by a runtime check.

However, we've been mistakenly optimizing this loop to a linear code for
UnrollFactor = 2, not taking into account that it also serves as a safe
version of the loop if its trip-count overflows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222451 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/LoopUnrollRuntime.cpp
test/Transforms/LoopUnroll/runtime-loop1.ll
test/Transforms/LoopUnroll/tripcount-overflow.ll [new file with mode: 0644]