[Unrolling] Refactor the start and step offsets to simplify overflow
authorChandler Carruth <chandlerc@gmail.com>
Tue, 12 May 2015 23:32:56 +0000 (23:32 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 12 May 2015 23:32:56 +0000 (23:32 +0000)
commit36ae8103b1d866ad0a344d693543b8ea6bf6dcfc
tree77b9a3415d16a50cbfe67b12bb75d21f79ab2324
parenta5a1b190d8f3d14eaf191a397a471fea12e7f93a
[Unrolling] Refactor the start and step offsets to simplify overflow
checking and make the cache faster and smaller.

I had thought that using an APInt here would be useful, but I think
I was just wrong. Notably, we don't have to do any fancy overflow
checking, we can just bound the values as quite small and do the math in
a higher precision integer. I've switched to a signed integer so that
UBSan will even point out if we ever have integer overflow. I've added
various asserts to try to catch things as well and hoisted the overflow
checks so that we just leave the too-large offsets out of the SCEV-GEP
cache. This makes the value in the cache quite a bit smaller which is
probably worthwhile.

No functionality changed here (for trip counts under 1 billion).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237209 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/LoopUnrollPass.cpp