]> granicus.if.org Git - llvm/commit
[SCEV] Fix trip multiple calculation
authorEli Friedman <efriedma@codeaurora.org>
Mon, 20 Mar 2017 20:25:46 +0000 (20:25 +0000)
committerEli Friedman <efriedma@codeaurora.org>
Mon, 20 Mar 2017 20:25:46 +0000 (20:25 +0000)
commitf7acf0537eef8abc483736c05e6d921c378633b4
tree362f5cc96d26b775e78abbae092ae92a7ce99c00
parentfd60195706e03ad15be1c297e12668445700e577
[SCEV] Fix trip multiple calculation

If loop bound containing calculations like min(a,b), the Scalar
Evolution API getSmallConstantTripMultiple returns 4294967295 "-1"
as the trip multiple. The problem is that, SCEV use -1 * umax to
represent umin. The multiple constant -1 was returned, and the logic
of guarding against huge trip counts was skipped. Because -1 has 32
active bits.

The fix attempt to factor more general cases. First try to get the
greatest power of two divisor of trip count expression. In case
overflow happens, the trip count expression is still divisible by the
greatest power of two divisor returned. Returns 1 if not divisible by 2.

Patch by Huihui Zhang <huihuiz@codeaurora.org>

Differential Revision: https://reviews.llvm.org/D30840

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298301 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/tripmultiple_calculation.ll [new file with mode: 0644]