This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: VRP: x+1 and -x cannot be INT_MIN
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 11 Nov 2017 23:11:16 +0100
- Subject: Re: VRP: x+1 and -x cannot be INT_MIN
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.20.1711112244260.7206@stedding.saclay.inria.fr>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Sat, Nov 11, 2017 at 11:03:06PM +0100, Marc Glisse wrote:
> --- gcc/tree-vrp.c (revision 254629)
> +++ gcc/tree-vrp.c (working copy)
> @@ -2086,20 +2086,38 @@ extract_range_from_binary_expr_1 (value_
> else
> set_value_range_to_varying (vr);
>
> return;
> }
>
> /* For integer ranges, apply the operation to each end of the
> range and see what we end up with. */
> if (code == PLUS_EXPR || code == MINUS_EXPR)
> {
> + /* If one argument is varying, we can sometimes still deduce a
> + range for the output: any + [3, +INF] is in [MIN+3, +INF]. */
> + if (TYPE_OVERFLOW_UNDEFINED (expr_type))
> + {
> + if(vr0.type == VR_VARYING && vr1.type == VR_RANGE)
> + {
> + vr0.type = type = VR_RANGE;
> + vr0.min = vrp_val_min (expr_type);
> + vr0.max = vrp_val_max (expr_type);
> + }
> + if(vr1.type == VR_VARYING && vr0.type == VR_RANGE)
Missing space before ( in 2 places.
Shouldn't this second if be actually else if?
> + {
> + vr1.type = VR_RANGE;
> + vr1.min = vrp_val_min (expr_type);
> + vr1.max = vrp_val_max (expr_type);
> + }
> + }
> +
Jakub