On Wed, Mar 30, 2016 at 3:22 PM, Jan Hubicka <hubi...@ucw.cz> wrote: >> > - /* If access is not executed on every iteration, we must ensure that >> > overlow may >> > - not make the access valid later. */ >> > + /* If access is not executed on every iteration, we must ensure that >> > overlow >> > + may not make the access valid later. */ >> > if (!dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb >> > (data->stmt)) >> > && scev_probably_wraps_p (initial_condition_in_loop_num (ev, >> > loop->num), >> > step, data->stmt, loop, true)) >> > - reliable = false; >> > + upper = false; >> > >> > - record_nonwrapping_iv (loop, init, step, data->stmt, low, high, >> > reliable, upper); >> > + record_nonwrapping_iv (loop, init, step, data->stmt, low, high, false, >> > upper); >> > return true; >> > } >> Hi, >> I have a concern that GCC records bound information from basic blocks >> even that don't dominate loop latch. Given below example: >> >> extern int b[]; >> void bar (int *); >> int foo (int x, int n) >> { >> int i; >> int arr[128] = {0}; >> >> for (i = 0; i < n; i++) >> { >> if (x > i) >> { >> a[i] = i; >> b[i] = i; >> } >> } >> bar (arr); >> return 0; >> } > > This testcase is not affected, becase scev_probably_wraps_p returns false in > this case. > In the wrapping case, we can't derive upper bound - this is indeed a > correctness issue. In the wrapping case, we still can derive upper bound if the index's wrapping range is larger than array bound. But I agree it looks like very corner case and not likely be useful in practice.
Thanks, bin > > I am experiemtning with enabling loop peeling by default. For that I extended > the code > to record likely upper bounds, which can be used to test if the loop most > probably has > low trip count. This is also useful to trottle other transformations. > > In this case we can probably assume that no sane person would count > on wrapping and record this as likely bound. > > Honza