[llvm] r273079 - [SCEV] Fix incorrect trip count computation
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 19 11:31:12 PDT 2016
On Fri, Jun 17, 2016 at 9:38 PM, Sanjoy Das via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: sanjoy
> Date: Fri Jun 17 23:38:31 2016
> New Revision: 273079
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273079&view=rev
> Log:
> [SCEV] Fix incorrect trip count computation
>
> The way we elide max expressions when computing trip counts is incorrect
> -- it breaks cases like this:
>
> ```
> static int wrapping_add(int a, int b) {
> return (int)((unsigned)a + (unsigned)b);
> }
>
> void test() {
> volatile int end_buf = 2147483548; // INT_MIN - 100
> int end = end_buf;
>
> unsigned counter = 0;
> for (int start = wrapping_add(end, 200); start < end; start++)
> counter++;
>
> print(counter);
> }
> ```
>
> Note: the `NoWrap` variable that was being tested has little to do with
> the values flowing into the max expression; it is a property of the
> induction variable.
>
It seems like it should be possible to optimize nsw-tripcount.ll
*somehow*... you're right that the NoWrap on the induction variable is
irrelevant, but it should be possible to use the NSW property of the RHS to
come up with the right conclusion.
-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160619/e6d96e1c/attachment.html>
More information about the llvm-commits
mailing list