https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85598

--- Comment #21 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Created attachment 45567
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45567&action=edit
patch candidate, but causes gcov-10.c regression

It looks like evrp's record_ranges_from_phis() will use loop information if
SCEV has been initialized:

          struct loop *l;
          if (scev_initialized_p ()
              && interesting
              && (l = loop_containing_stmt (phi))
              && l->header == gimple_bb (phi))
          vr_values->adjust_range_with_scev (&vr_result, l, phi, lhs);

And sure enough, if we initialize SCEV in the sprintf pass, the range we get
from get_value_range for x_10 is now [0, 255] and no warning is generated.

If this is acceptable, this simple approach would be reasonable for this
release, IMO.

I tested the patch, but it causes a gcov-10.c regression which I haven't
investigated.

Thoughts?

Reply via email to