diff mbox

Fix ICE in set_lattice_value

Message ID 201207181605.08990.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou July 18, 2012, 2:05 p.m. UTC
This is a regression present on mainline and 4.7 branch for targets using SJLJ 
exceptions by default in Ada (e.g. ARM).  The error message is:

+===========================GNAT BUG DETECTED==============================+
| 4.8.0 20120716 (experimental) [trunk revision 189525] (x86_64-suse-linux) GCC 
error:|
| in set_lattice_value, at tree-ssa-ccp.c:452                              |
| Error detected around p.adb:16:4  

It's valid_lattice_transition returning false on a transition from INTEGER_CST 
to a constant &x.  It occurs for an array reference with non-constant index: on 
the first round, &x + i is non-constant so the algorithm computes an alignment 
factor which is an INTEGER_CST; on the second round, i is 0 so the new value is 
the constant &x.

valid_lattice_transition accepts the reverse transition.  The attached patch 
makes the function accept this transition as well.

Tested on x86_64-suse-linux, OK for the mainline and 4.7 branch?


2012-07-18  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-ssa-ccp.c (valid_lattice_transition): Allow transitioning from
	as well as to INTEGER_CST.


2012-07-18  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/loop_optimization11.adb: New test.
	* gnat.dg/loop_optimization11_pkg.ads: New helper.

Comments

Richard Biener July 18, 2012, 2:59 p.m. UTC | #1
On Wed, Jul 18, 2012 at 4:05 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> This is a regression present on mainline and 4.7 branch for targets using SJLJ
> exceptions by default in Ada (e.g. ARM).  The error message is:
>
> +===========================GNAT BUG DETECTED==============================+
> | 4.8.0 20120716 (experimental) [trunk revision 189525] (x86_64-suse-linux) GCC
> error:|
> | in set_lattice_value, at tree-ssa-ccp.c:452                              |
> | Error detected around p.adb:16:4
>
> It's valid_lattice_transition returning false on a transition from INTEGER_CST
> to a constant &x.  It occurs for an array reference with non-constant index: on
> the first round, &x + i is non-constant so the algorithm computes an alignment
> factor which is an INTEGER_CST; on the second round, i is 0 so the new value is
> the constant &x.
>
> valid_lattice_transition accepts the reverse transition.  The attached patch
> makes the function accept this transition as well.
>
> Tested on x86_64-suse-linux, OK for the mainline and 4.7 branch?

Hmm, the point is of couse to not allow transitions that could form a cycle,
which is why the reverse transition is not allowed.

Let me have a closer look here.

Richard.

> 2012-07-18  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * tree-ssa-ccp.c (valid_lattice_transition): Allow transitioning from
>         as well as to INTEGER_CST.
>
>
> 2012-07-18  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gnat.dg/loop_optimization11.adb: New test.
>         * gnat.dg/loop_optimization11_pkg.ads: New helper.
>
>
> --
> Eric Botcazou
Eric Botcazou July 19, 2012, 7:30 a.m. UTC | #2
> Hmm, the point is of couse to not allow transitions that could form a
> cycle, which is why the reverse transition is not allowed.
> 
> Let me have a closer look here.

You can reproduce on your favorite platform by locally copying the system.ads 
from gcc/ada/rts in your build tree and turning ZCX_By_Default to False.
diff mbox

Patch

Index: tree-ssa-ccp.c
===================================================================
--- tree-ssa-ccp.c	(revision 189525)
+++ tree-ssa-ccp.c	(working copy)
@@ -405,9 +405,9 @@  valid_lattice_transition (prop_value_t o
 
   /* Now both lattice values are CONSTANT.  */
 
-  /* Allow transitioning from &x to &x & ~3.  */
-  if (TREE_CODE (old_val.value) != INTEGER_CST
-      && TREE_CODE (new_val.value) == INTEGER_CST)
+  /* Allow transitioning from &x to &x & ~3 and vice versa.  */
+  if ((TREE_CODE (old_val.value) == INTEGER_CST)
+      != (TREE_CODE (new_val.value) == INTEGER_CST))
     return true;
 
   /* Bit-lattices have to agree in the still valid bits.  */