[PATCH] Fix ICE in vrp on aarch64 (PR tree-optimization/92452)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Fix ICE in vrp on aarch64 (PR tree-optimization/92452)

Jakub Jelinek
Hi!

The following testcase ICEs on aarch64-linux.  The problem is that maxbound
is POLY_INT_CST, eltsize is INTEGER_CST, but int_const_binop for
TRUNC_DIV_EXPR returns NULL_TREE as it can't simplify it to something
usable and we later try to MINUS_EXPR the NULL_TREE.

Fixed thusly, tested using cross to aarch64-linux, bootstrapped/regtested on
powerpc64le-linux, ok for trunk?

2019-11-11  Jakub Jelinek  <[hidden email]>

        PR tree-optimization/92452
        * tree-vrp.c (vrp_prop::check_array_ref): If TRUNC_DIV_EXPR folds
        into NULL_TREE, set up_bound to NULL_TREE instead of computing
        MINUS_EXPR on it.

        * c-c++-common/pr92452.c: New test.

--- gcc/tree-vrp.c.jj 2019-11-09 00:41:09.022921760 +0100
+++ gcc/tree-vrp.c 2019-11-11 17:03:36.844669691 +0100
@@ -4150,8 +4150,11 @@ vrp_prop::check_array_ref (location_t lo
 
   up_bound_p1 = int_const_binop (TRUNC_DIV_EXPR, maxbound, eltsize);
 
-  up_bound = int_const_binop (MINUS_EXPR, up_bound_p1,
-      build_int_cst (ptrdiff_type_node, 1));
+  if (up_bound_p1 != NULL_TREE)
+    up_bound = int_const_binop (MINUS_EXPR, up_bound_p1,
+ build_int_cst (ptrdiff_type_node, 1));
+  else
+    up_bound = NULL_TREE;
  }
     }
   else
--- gcc/testsuite/c-c++-common/pr92452.c.jj 2019-11-11 17:06:01.525495277 +0100
+++ gcc/testsuite/c-c++-common/pr92452.c 2019-11-11 17:05:31.256950180 +0100
@@ -0,0 +1,5 @@
+/* PR tree-optimization/92452 */
+/* { dg-do compile } */
+/* { dg-options "-Os -Warray-bounds=1" } */
+
+#include "pr60101.c"

        Jakub

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix ICE in vrp on aarch64 (PR tree-optimization/92452)

Richard Biener
On Mon, 11 Nov 2019, Jakub Jelinek wrote:

> Hi!
>
> The following testcase ICEs on aarch64-linux.  The problem is that maxbound
> is POLY_INT_CST, eltsize is INTEGER_CST, but int_const_binop for
> TRUNC_DIV_EXPR returns NULL_TREE as it can't simplify it to something
> usable and we later try to MINUS_EXPR the NULL_TREE.
>
> Fixed thusly, tested using cross to aarch64-linux, bootstrapped/regtested on
> powerpc64le-linux, ok for trunk?

OK.

Richard.

> 2019-11-11  Jakub Jelinek  <[hidden email]>
>
> PR tree-optimization/92452
> * tree-vrp.c (vrp_prop::check_array_ref): If TRUNC_DIV_EXPR folds
> into NULL_TREE, set up_bound to NULL_TREE instead of computing
> MINUS_EXPR on it.
>
> * c-c++-common/pr92452.c: New test.
>
> --- gcc/tree-vrp.c.jj 2019-11-09 00:41:09.022921760 +0100
> +++ gcc/tree-vrp.c 2019-11-11 17:03:36.844669691 +0100
> @@ -4150,8 +4150,11 @@ vrp_prop::check_array_ref (location_t lo
>  
>    up_bound_p1 = int_const_binop (TRUNC_DIV_EXPR, maxbound, eltsize);
>  
> -  up_bound = int_const_binop (MINUS_EXPR, up_bound_p1,
> -      build_int_cst (ptrdiff_type_node, 1));
> +  if (up_bound_p1 != NULL_TREE)
> +    up_bound = int_const_binop (MINUS_EXPR, up_bound_p1,
> + build_int_cst (ptrdiff_type_node, 1));
> +  else
> +    up_bound = NULL_TREE;
>   }
>      }
>    else
> --- gcc/testsuite/c-c++-common/pr92452.c.jj 2019-11-11 17:06:01.525495277 +0100
> +++ gcc/testsuite/c-c++-common/pr92452.c 2019-11-11 17:05:31.256950180 +0100
> @@ -0,0 +1,5 @@
> +/* PR tree-optimization/92452 */
> +/* { dg-do compile } */
> +/* { dg-options "-Os -Warray-bounds=1" } */
> +
> +#include "pr60101.c"
>
> Jakub
>
>
--
Richard Biener <[hidden email]>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)