[PATCH] D30840: Fix trip multiple calculation

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 11:12:32 PST 2017


huihuiz created this revision.
Herald added a subscriber: mzolotukhin.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D30840

Files:
  include/llvm/Analysis/ScalarEvolution.h
  lib/Analysis/ScalarEvolution.cpp
  test/Analysis/ScalarEvolution/tripmultiple_calculation.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30840.91381.patch
Type: text/x-patch
Size: 11048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170310/addfaac1/attachment.bin>


More information about the llvm-commits mailing list