This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/71031] [6/7 Regression] ICE in extract_range_from_binary_expr_1, at tree-vrp.c:2535 w/ -Os
- From: "ebotcazou at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 19 May 2016 10:13:12 +0000
- Subject: [Bug tree-optimization/71031] [6/7 Regression] ICE in extract_range_from_binary_expr_1, at tree-vrp.c:2535 w/ -Os
- Auto-submitted: auto-generated
- References: <bug-71031-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71031
--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> The situation (+ UINT_MAX) is equal to [1, od_5] - 1 which would mean
> a result range of ideally [0, od_5 - 1].
Right.
> I think Eric added this code so he may want to have a look here to see
> what general solution is appropriate.
>
> But yes, instead of asserting we can always drop to VR_VARYING ...
That's what the block of code just above was added for:
/* If we have overflow for the constant part and the resulting
range will be symbolic, drop to VR_VARYING. */
if ((min_ovf && sym_min_op0 != sym_min_op1)
|| (max_ovf && sym_max_op0 != sym_max_op1))
{
set_value_range_to_varying (vr);
return;
}
so a safe fix is to extend it to catch this case:
/* If we have overflow for the constant part and the resulting
range will be symbolic, drop to VR_VARYING. */
if ((min_ovf || max_ovf)
&& (sym_min_op0 != sym_min_op1 || sym_max_op0 != sym_max_op1))
{
set_value_range_to_varying (vr);
return;
}
If we want to compute the above expected range, we need to enter the business
of symbolic ranges with TYPE_OVERFLOW_WRAPS, which is rather delicate. And we
also need to short circuit the final call to compare_values, which will drop to
VR_VARYING if I'm not mistaken.