This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] VRP (x << 31) < -1 fix (PR tree-optimization/56984)
- From: Richard Biener <rguenther at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 18 Apr 2013 09:49:15 +0200 (CEST)
- Subject: Re: [PATCH] VRP (x << 31) < -1 fix (PR tree-optimization/56984)
- References: <20130418063521 dot GX12880 at tucnak dot redhat dot com>
On Thu, 18 Apr 2013, Jakub Jelinek wrote:
> Hi!
>
> Like in the case a few lines below, if new_val is a minimum resp. a few
> lines below maximum value, we end up with always true resp. always false
> assertion, which VRP asserts that those aren't created. So, we should punt
> on those, and instead fold-const or gimple_fold should ideally optimize
> those cases to false resp. true.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8
> branch?
Ok.
When VRP asserts that we don't build such assert stmts can it at that
point simply drop the assert? That's more user-friendly (instead of
just ICEing ...) I think.
Thanks.
Richard.
> 2013-04-18 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/56984
> * tree-vrp.c (register_edge_assert_for_2): For (x >> M) < N
> and (x >> M) >= N don't register any assertion if N << M is the
> minimum value.
>
> * gcc.c-torture/compile/pr56984.c: New test.
>
> --- gcc/tree-vrp.c.jj 2013-04-11 09:09:33.000000000 +0200
> +++ gcc/tree-vrp.c 2013-04-17 09:17:34.278242462 +0200
> @@ -4895,7 +4895,13 @@ register_edge_assert_for_2 (tree name, e
> new_comp_code = comp_code == EQ_EXPR ? LE_EXPR : GT_EXPR;
> }
> else if (comp_code == LT_EXPR || comp_code == GE_EXPR)
> - new_val = val2;
> + {
> + double_int minval
> + = double_int::min_value (prec, TYPE_UNSIGNED (TREE_TYPE (val)));
> + new_val = val2;
> + if (minval == tree_to_double_int (new_val))
> + new_val = NULL_TREE;
> + }
> else
> {
> double_int maxval
> --- gcc/testsuite/gcc.c-torture/compile/pr56984.c.jj 2013-04-17 09:24:44.689719328 +0200
> +++ gcc/testsuite/gcc.c-torture/compile/pr56984.c 2013-04-17 09:24:25.000000000 +0200
> @@ -0,0 +1,9 @@
> +/* PR tree-optimization/56984 */
> +
> +int
> +foo (int x)
> +{
> + if ((x >> 31) < -1)
> + x++;
> + return x;
> +}
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend