This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Tiny -fssa-ccp fix
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, law at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 4 Mar 2002 15:11:56 +0100
- Subject: [PATCH] Tiny -fssa-ccp fix
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following testcase ICEs because VARRAY_RTX (ssa_definition, i) is NULL.
All other users of this seem to check for NULL and if it
is not single_set, it skips it anyway.
2002-03-04 Jakub Jelinek <jakub@redhat.com>
* ssa-ccp.c (ssa_ccp_substitute_constants): Don't crash if def
is NULL.
* gcc.dg/20020304-1.c: New test.
--- gcc/testsuite/gcc.dg/20020304-1.c.jj Mon Mar 4 15:16:52 2002
+++ gcc/testsuite/gcc.dg/20020304-1.c Mon Mar 4 15:16:22 2002
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fssa -fssa-ccp" } */
+
+double a[10][35], b[10][8];
+int c, c, d, e, f, g, h;
+
+int foo ()
+{
+ int i, j, k, l;
+
+ if (c > 10)
+ c = 10;
+
+ for (j = 0; j < c; j++)
+ {
+ k = 0;
+ for (l = 0; l < h; l++)
+ {
+ if (d != 5)
+ return -1;
+ k = l * g;
+ a[j][k] = (double) e; k++;
+ a[j][k] = (double) f; k++;
+ }
+ for (i = 0;i < 35; i++)
+ {
+ if (a[j][i] >= 0.9)
+ a[j][i] = 0.9;
+ if (a[j][i] <= 0.1)
+ a[j][i] = 0.1;
+ }
+ k = 0;
+ b[j][k] = (double) e; k++;
+ b[j][k] = (double) f; k++;
+ }
+ return 0;
+}
--- gcc/ssa-ccp.c.jj Wed Jan 23 16:29:01 2002
+++ gcc/ssa-ccp.c Mon Mar 4 15:15:21 2002
@@ -856,10 +856,13 @@ ssa_ccp_substitute_constants ()
{
if (values[i].lattice_val == CONSTANT)
{
- rtx def = VARRAY_RTX (ssa_definition, i);
- rtx set = single_set (def);
+ rtx def = VARRAY_RTX (ssa_definition, i), set;
struct df_link *curruse;
+ if (! def)
+ continue;
+
+ set = single_set (def);
if (! set)
continue;
Jakub