ssa-ccp.c (ssa_ccp_substitute_constants): Don't crash if def is NULL.
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Mar 2002 11:01:09 +0000 (12:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 5 Mar 2002 11:01:09 +0000 (12:01 +0100)
* ssa-ccp.c (ssa_ccp_substitute_constants): Don't crash if def
is NULL.
* gcc.dg/20020304-1.c: New test.

From-SVN: r50311

gcc/ChangeLog
gcc/ssa-ccp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20020304-1.c [new file with mode: 0644]

index dc43ba38ef55c7f4ae68d304f6f4dfa40cbbf631..1ea58afb6b6b15e2feb78d36abeaa523e4809e77 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       * ssa-ccp.c (ssa_ccp_substitute_constants): Don't crash if def
+       is NULL.
+
 2002-03-05  Richard Henderson  <rth@redhat.com>
 
         * rs6000.h (TOTAL_ALTIVEC_REGS): Fix off-by-one error.
index 9d2d9c9170e72a2998fcdd5795b409a4f7ae2854..d1b597c1b294187283fe7fcb88a72ccb20626e2e 100644 (file)
@@ -856,10 +856,14 @@ 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;
 
+         /* Definition might have been deleted already.  */
+         if (! def)
+           continue;
+
+         set = single_set (def);
          if (! set)
            continue;
 
index 8e4daad4f607ba030745f8fcb6598f68ae833ff5..378dba70cbf4d0a2c53a195a51b1d4a9aa612dea 100644 (file)
@@ -1,3 +1,7 @@
+2002-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/20020304-1.c: New test.
+
 2002-03-04  Zack Weinberg  <zack@codesourcery.com>
 
        * gcc.c-torture/compile/20020304-1.c: New test case
diff --git a/gcc/testsuite/gcc.dg/20020304-1.c b/gcc/testsuite/gcc.dg/20020304-1.c
new file mode 100644 (file)
index 0000000..f6d6b4e
--- /dev/null
@@ -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;
+}