tree-ssa.c (kill_redundant_phi_nodes): More correctly handle PHIs where the destinati...
authorJeff Law <law@redhat.com>
Mon, 14 Jun 2004 20:41:41 +0000 (14:41 -0600)
committerJeff Law <law@gcc.gnu.org>
Mon, 14 Jun 2004 20:41:41 +0000 (14:41 -0600)
        * tree-ssa.c (kill_redundant_phi_nodes): More correctly handle
        PHIs where the destination or an argument is marked with
        SSA_NAME_OCCURS_IN_ABNORMAL_PHI.

* gcc.c-torture/20040614-1.c: New test.

From-SVN: r83132

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20040614-1.c [new file with mode: 0644]
gcc/tree-ssa.c

index d7faa5d7818cd70fc8f178d61ae001f99d84fc5c..19733748c7a0b769c6491329fb5ef8731bf842f8 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-14  Jeff Law  <law@redhat.com>
+
+       * tree-ssa.c (kill_redundant_phi_nodes): More correctly handle
+       PHIs where the destination or an argument is marked with
+       SSA_NAME_OCCURS_IN_ABNORMAL_PHI.
+
 2004-06-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/15945
index 36cb478b01c5d51c251cde08d4e2b2e9ae79042e..9c8a040da2d905f051a219b5df038a0865e159af 100644 (file)
@@ -1,3 +1,7 @@
+2004-06-14  Jeff Law  <law@redhat.com>
+
+       * gcc.c-torture/compile/20040614-1.c: New test.
+
 2004-06-14  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/15211
diff --git a/gcc/testsuite/gcc.c-torture/compile/20040614-1.c b/gcc/testsuite/gcc.c-torture/compile/20040614-1.c
new file mode 100644 (file)
index 0000000..d99d278
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef NO_LABEL_VALUES
+void f(int r1, int *fp) 
+{     
+  void *hlbl_tbl[] = { &&label1 }; 
+  goto *hlbl_tbl[r1]; 
+  *fp = 0; 
+ label0: 
+  fp += 8; 
+ label1: 
+  *fp = 0; 
+  if (r1)  
+    goto label2; 
+  if (r1) 
+    goto label0; 
+ label2: 
+  ; 
+} 
+#else
+int x;
+#endif
index d553676969f33e7cede2dffdc559744f577caa49..9cec5d5087f2f4257fd85ea62a1c3b03fe633c65 100644 (file)
@@ -885,6 +885,14 @@ kill_redundant_phi_nodes (void)
        {
          var = PHI_RESULT (phi);
 
+         /* If the destination of the PHI is associated with an
+            abnormal edge, then we can not propagate this PHI away.  */
+         if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (var))
+           {
+             raise_value (phi, var, eq_to);
+             continue;
+           }
+
          for (i = 0; i < (unsigned) PHI_NUM_ARGS (phi); i++)
            {
              t = PHI_ARG_DEF (phi, i);
@@ -897,12 +905,20 @@ kill_redundant_phi_nodes (void)
 
              stmt = SSA_NAME_DEF_STMT (t);
 
+             /* If any particular PHI argument is associated with
+                an abnormal edge, then we know that we should not
+                be propagating away this PHI.  Go ahead and raise
+                the result of this PHI to the top of the lattice.  */
+             if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (t))
+               {
+                 raise_value (phi, var, eq_to);
+                 continue;
+               }
+             
              /* If the defining statement for this argument is not a
-                phi node or the argument is associated with an abnormal
-                edge, then we need to recursively start the forward
+                phi node then we need to recursively start the forward
                 dataflow starting with PHI.  */
-             if (TREE_CODE (stmt) != PHI_NODE
-                 || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (t))
+             if (TREE_CODE (stmt) != PHI_NODE)
                {
                  eq_to[SSA_NAME_VERSION (t)] = t;
                  raise_value (phi, t, eq_to);