https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85598
--- Comment #22 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Aldy Hernandez from comment #21) > Created attachment 45567 [details] > 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? Might be a reasonable thing (with investigating gcov-10.c first of course). It has the chance of causing code-gen differences if that loop_optimizer_init () is done dependent on -W* which we do not want. There's AVOID_CFG_MANIPULATIONS flag but likely SCEV wants normalized loops.