This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] PATCH: more predicate tweaks
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 Aug 2003 14:59:50 -0400
- Subject: [tree-ssa] PATCH: more predicate tweaks
deep copy/gimplify is a rather large hammer to use to scan an initializer
for labels that we need to mark. walk_tree is a more appropriate tool.
With that change, is_gimple_initializer can go away, as can the call to
gimplify_constructor from gimplify_expr.
It seems that we can't just check BLKmode to find types that shouldn't be
considered register types; some array types get other modes (i.e. char[8]
gets DImode), but we still don't want to create array temps.
I also noticed that is_gimple_reg would break if someone actually tried to
use it on an SSA_NAME; fixed.
Tested athlon-pc-linux-gnu, applied to tree-ssa.
2003-08-25 Jason Merrill <jason@redhat.com>
* c-simplify.c (mark_labels_r): New fn.
(gimplify_decl_stmt): Use it to mark labels in static initializers.
* tree-simple.c (is_gimple_initializer): Remove.
(is_gimple_reg_type): New fn.
(is_gimple_reg): Use it. Handle SSA_NAMEs properly.
* tree-simple.h: Adjust.
* gimplify.c (gimplify_expr) <CONSTRUCTOR>: Do nothing here.
*** c-simplify.c.~1~ Thu Aug 21 03:47:13 2003
--- c-simplify.c Mon Aug 25 13:55:31 2003
*************** gimplify_return_stmt (tree *stmt_p)
*** 782,787 ****
--- 782,800 ----
*stmt_p = expr;
}
+ /* walk_tree helper function for gimplify_decl_stmt. */
+
+ static tree
+ mark_labels_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
+ {
+ if (TYPE_P (*tp))
+ *walk_subtrees = 0;
+ if (TREE_CODE (*tp) == LABEL_DECL)
+ FORCED_LABEL (*tp) = 1;
+
+ return NULL_TREE;
+ }
+
/* Gimplifies a DECL_STMT node T.
If a declaration V has an initial value I, create an expression 'V = I'
*************** gimplify_decl_stmt (tree *stmt_p, tree *
*** 863,878 ****
else
{
/* We must still examine initializers for static variables
! as they may contain a label address. However, we must not
! make any changes to the node or the queues. So we
! make a copy of the node before calling the gimplifier
! and we use throw-away queues. */
! tree pre = NULL;
! tree post = NULL;
! tree dummy_init = unshare_expr (init);
! gimplify_expr (&dummy_init, &pre, &post,
! is_gimple_initializer,
! fb_rvalue);
}
}
--- 876,883 ----
else
{
/* We must still examine initializers for static variables
! as they may contain a label address. */
! walk_tree (&init, mark_labels_r, NULL, NULL);
}
}
*** gimplify.c.~1~ Fri Aug 22 13:08:51 2003
--- gimplify.c Mon Aug 25 11:56:14 2003
*************** gimplify_expr (tree *expr_p, tree *pre_p
*** 571,580 ****
break;
case CONSTRUCTOR:
! if (gimple_test_f != is_gimple_rhs)
! /* Don't reduce this yet if we're on the rhs of an assignment.
! Let gimplify_init_constructor work its magic. */
! gimplify_constructor (*expr_p, pre_p, post_p);
break;
/* The following are special cases that are not handled by the
--- 571,578 ----
break;
case CONSTRUCTOR:
! /* Don't reduce this in place; let gimplify_init_constructor work
! its magic. */
break;
/* The following are special cases that are not handled by the
*** tree-simple.c.~1~ Fri Aug 22 13:08:51 2003
--- tree-simple.c Mon Aug 25 11:56:14 2003
*************** is_gimple_constructor_elt (tree t)
*** 231,247 ****
|| TREE_CODE (t) == CONSTRUCTOR);
}
- /* Returns nonzero if T is a GIMPLE initializer for a decl. This is the
- same as the right side of a MODIFY_EXPR, but uses a different function
- so that we will actually simplify a CONSTRUCTOR. */
-
- int
- is_gimple_initializer (tree t)
- {
- return (is_gimple_rhs (t));
- }
-
-
/* Return nonzero if T is a valid LHS for a GIMPLE assignment expression. */
int
--- 231,236 ----
*************** is_gimple_id (tree t)
*** 423,435 ****
|| TREE_CODE (t) == STRING_CST);
}
/* Return nonzero if T is a scalar register variable. */
int
is_gimple_reg (tree t)
{
return (is_gimple_variable (t)
! && TYPE_MODE (TREE_TYPE (t)) != BLKmode
&& ! TREE_STATIC (t)
&& ! DECL_EXTERNAL (t)
&& ! TREE_ADDRESSABLE (t)
--- 412,438 ----
|| TREE_CODE (t) == STRING_CST);
}
+ /* Return nonzero if TYPE is a suitable type for a scalar register
+ variable. */
+
+ bool
+ is_gimple_reg_type (tree type)
+ {
+ return (TYPE_MODE (type) != BLKmode
+ && TREE_CODE (type) != ARRAY_TYPE
+ && !TREE_ADDRESSABLE (type));
+ }
+
/* Return nonzero if T is a scalar register variable. */
int
is_gimple_reg (tree t)
{
+ if (TREE_CODE (t) == SSA_NAME)
+ t = SSA_NAME_VAR (t);
+
return (is_gimple_variable (t)
! && is_gimple_reg_type (TREE_TYPE (t))
&& ! TREE_STATIC (t)
&& ! DECL_EXTERNAL (t)
&& ! TREE_ADDRESSABLE (t)
*************** is_gimple_val (tree t)
*** 447,454 ****
#if 0
/* Make loads from volatiles and memory vars explicit. */
if (is_gimple_variable (t)
! && !(is_gimple_reg (t)
! || TYPE_MODE (TREE_TYPE (t)) == BLKmode))
return 0;
#else
/* A volatile decl or _REF is not a valid operand, because we can't reuse
--- 450,457 ----
#if 0
/* Make loads from volatiles and memory vars explicit. */
if (is_gimple_variable (t)
! && is_gimple_reg_type (TREE_TYPE (t))
! && !is_gimple_reg (t))
return 0;
#else
/* A volatile decl or _REF is not a valid operand, because we can't reuse
*** tree-simple.h.~1~ Fri Aug 22 13:08:51 2003
--- tree-simple.h Mon Aug 25 11:56:14 2003
*************** extern void annotate_all_with_file_line
*** 43,48 ****
--- 43,50 ----
/* Returns 1 iff T is a valid GIMPLE statement. */
int is_gimple_stmt (tree);
+ /* Returns 1 iff TYPE is a valid type for a scalar register variable. */
+ bool is_gimple_reg_type (tree);
/* Returns 1 iff T is a scalar register variable. */
int is_gimple_reg (tree);
/* Returns 1 iff T is any sort of variable. */
*************** int is_gimple_cast (tree);
*** 69,77 ****
/* Returns 1 iff T is a valid CONSTRUCTOR element (either an rvalue or
another CONSTRUCTOR). */
int is_gimple_constructor_elt (tree);
- /* Returns 1 iff T is a valid initializer for a variable (like _rhs, but
- without the magic treatment of CONSTRUCTOR). */
- int is_gimple_initializer (tree);
void recalculate_side_effects (tree);
--- 71,76 ----