This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Don't disallow copyprop for virtual ops for loop depth check
- From: Andrew Pinski <pinskia at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Nov 2006 23:23:35 -0800
- Subject: Re: [PATCH] Don't disallow copyprop for virtual ops for loop depth check
- References: <1164698153.29420.22.camel@celery.andrew.com>
> ChangeLog:
>
> * tree-ssa-dom.c (cprop_operand): Ignore the loop depth when
> copyproping on virtual operands.
> (propagate_rhs_into_lhs): Likewise.
> * tree-ssa-copy.c (copy_prop_visit_phi_node): Likewise.
>
> * gcc.c-torture/compile/pr29922.c: New test.
> * gfortran.fortran-torture/compile/pr29922.f: New test.
Lets try that with the patch this time.
-- Pinski
Index: testsuite/gcc.c-torture/compile/pr29922.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr29922.c (revision 0)
+++ testsuite/gcc.c-torture/compile/pr29922.c (revision 0)
@@ -0,0 +1,25 @@
+struct menu {
+ struct menu *next;
+ struct menu *list;
+};
+char line[128];
+int conf_choice(struct menu *menu)
+{
+ struct menu *child;
+ while (1)
+ {
+ for (child = menu->list; child; child = child->next)
+ {
+ if (menu_is_visible())
+ break;
+ }
+ if (!child)
+ continue;
+ if (__builtin_strlen(line) == 100)
+ {
+ f();
+ continue;
+ }
+ return 1;
+ }
+}
Index: testsuite/gfortran.fortran-torture/compile/pr29922.f
===================================================================
--- testsuite/gfortran.fortran-torture/compile/pr29922.f (revision 0)
+++ testsuite/gfortran.fortran-torture/compile/pr29922.f (revision 0)
@@ -0,0 +1,14 @@
+C This test used to ICE in PRE because of VOPs with one argument.
+ REAL Q( 2, 2 )
+ DO 90 IM3 = 1, 3
+ DO 10 J1 = 1, 2
+ RES = Q( J1, 1 )*CS + Q( J1, 2 )*SN
+ Q( J1, 2 ) =-Q( J1, 1 ) + Q( J1, 2 )*CS
+ 10 CONTINUE
+ RES = RES + Q( 2, 2 ) / EPS
+ IF( RES.GT.RMAX ) THEN
+ RMAX = RES
+ END IF
+ 90 CONTINUE
+ END
+
Index: tree-ssa-dom.c
===================================================================
--- tree-ssa-dom.c (revision 119245)
+++ tree-ssa-dom.c (working copy)
@@ -1700,8 +1700,10 @@
depth than the propagatee. Otherwise, this may move loop variant
variables outside of their loops and prevent coalescing
opportunities. If the value was loop invariant, it will be hoisted
- by LICM and exposed for copy propagation. */
- if (loop_depth_of_name (val) > loop_depth_of_name (op))
+ by LICM and exposed for copy propagation. We don't care much about
+ virtual operands. */
+ if (loop_depth_of_name (val) > loop_depth_of_name (op)
+ && is_gimple_reg (val))
return false;
/* Dump details. */
@@ -2136,12 +2138,13 @@
propagate_rhs_into_lhs (tree stmt, tree lhs, tree rhs, bitmap interesting_names)
{
/* First verify that propagation is valid and isn't going to move a
- loop variant variable outside its loop. */
+ loop variant variable outside its loop except for vops. */
if (! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)
&& (TREE_CODE (rhs) != SSA_NAME
|| ! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs))
&& may_propagate_copy (lhs, rhs)
- && loop_depth_of_name (lhs) >= loop_depth_of_name (rhs))
+ && (loop_depth_of_name (lhs) > loop_depth_of_name (rhs)
+ || !is_gimple_reg (lhs)))
{
use_operand_p use_p;
imm_use_iterator iter;
Index: tree-ssa-copy.c
===================================================================
--- tree-ssa-copy.c (revision 119245)
+++ tree-ssa-copy.c (working copy)
@@ -801,8 +801,11 @@
Otherwise, this may move loop variant variables outside of
their loops and prevent coalescing opportunities. If the
value was loop invariant, it will be hoisted by LICM and
- exposed for copy propagation. */
- if (loop_depth_of_name (arg) > loop_depth_of_name (lhs))
+ exposed for copy propagation. We don't care much about
+ virtual operands as they don't get coalesced during out-
+ of-ssa. */
+ if (loop_depth_of_name (arg) > loop_depth_of_name (lhs)
+ && is_gimple_reg (arg))
{
phi_val.value = lhs;
break;