This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Fix ia64 bootstrap problems [patch]
- From: Diego Novillo <dnovillo at redhat dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: 23 Jul 2003 18:42:50 -0400
- Subject: [tree-ssa] Fix ia64 bootstrap problems [patch]
- Organization: Red Hat Canada
This patch fixes the IA64 problems I described in
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02183.html.
Jason suggested moving DECL_C_HARD_REGISTER into tree.h and using
another unused tree_decl field. The new flag is DECL_HARD_REGISTER. It
has the exact same semantics and it can be used in the tree optimizers.
This attribute is needed to prevent copy propagation from propagating
copies into variables assigned to hard registers by the user. The patch
introduces a new predicate may_copy_propagate() that tests whether a
variable can be propagated into another.
It also fixes an inconsistency in copy propagation. In the copy
propagator we were preventing copies from being propagated across
abnormal edges. That wasn't checked in the dominator optimizations.
Now both functions call the same predicate. It doesn't seem to fix any
regressions, though.
Bootstrapped and tested x86 and ia64.
Diego.
2003-07-23 Jason Merrill <jason@redhat.com>
Diego Novillo <dnovillo@redhat.com>
* c-common.h (DECL_C_HARD_REGISTER): Replace ...
* tree.h (DECL_HARD_REGISTER): ... with this. Update all users.
2003-07-23 Diego Novillo <dnovillo@redhat.com>
* tree-flow-inline.h (may_propagate_copy): New function.
* tree-flow.h (may_propagate_copy): Declare.
* tree-ssa-copyprop.c (copyprop_stmt): Call it.
(get_original): Likewise.
* tree-ssa-dom.c (optimize_stmt): Likewise.
Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.141.2.26
diff -d -u -p -r1.141.2.26 c-common.h
--- c-common.h 23 Jul 2003 16:59:29 -0000 1.141.2.26
+++ c-common.h 23 Jul 2003 19:28:06 -0000
@@ -1186,10 +1186,6 @@ extern int anon_aggr_type_p (tree);
#define CLEAR_DECL_C_BIT_FIELD(NODE) \
(DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
-/* In a VAR_DECL, nonzero if the decl is a register variable with
- an explicit asm specification. */
-#define DECL_C_HARD_REGISTER(DECL) DECL_LANG_FLAG_4 (VAR_DECL_CHECK (DECL))
-
extern void emit_local_var (tree);
extern void make_rtl_for_local_static (tree);
extern tree expand_cond (tree);
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.334.2.54
diff -d -u -p -r1.334.2.54 c-decl.c
--- c-decl.c 23 Jul 2003 16:59:29 -0000 1.334.2.54
+++ c-decl.c 23 Jul 2003 19:28:07 -0000
@@ -2923,7 +2923,7 @@ finish_decl (tree decl, tree init, tree
keyword indicates that we should place the variable
in a particular register. */
if (DECL_REGISTER (decl))
- DECL_C_HARD_REGISTER (decl) = 1;
+ DECL_HARD_REGISTER (decl) = 1;
/* If this is not a static variable, issue a warning.
It doesn't make any sense to give an ASMSPEC for an
Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.43.2.16
diff -d -u -p -r1.43.2.16 c-semantics.c
--- c-semantics.c 23 Jul 2003 16:59:31 -0000 1.43.2.16
+++ c-semantics.c 23 Jul 2003 19:28:07 -0000
@@ -269,7 +269,7 @@ emit_local_var (tree decl)
/* Create RTL for this variable. */
if (!DECL_RTL_SET_P (decl))
{
- if (DECL_C_HARD_REGISTER (decl))
+ if (DECL_HARD_REGISTER (decl))
/* The user specified an assembler name for this variable.
Set that up now. */
rest_of_decl_compilation
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.43
diff -d -u -p -r1.1.2.43 tree-flow-inline.h
--- tree-flow-inline.h 22 Jul 2003 02:50:15 -0000 1.1.2.43
+++ tree-flow-inline.h 23 Jul 2003 19:28:07 -0000
@@ -517,4 +517,12 @@ is_optimizable_addr_expr (tree val)
|| TREE_CODE (TREE_OPERAND (val, 0)) == PARM_DECL));
}
+static inline bool
+may_propagate_copy (tree dest, tree orig)
+{
+ return (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI (dest)
+ && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig)
+ && !DECL_HARD_REGISTER (SSA_NAME_VAR (dest)));
+}
+
#endif /* _TREE_FLOW_INLINE_H */
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.96
diff -d -u -p -r1.1.4.96 tree-flow.h
--- tree-flow.h 22 Jul 2003 02:50:15 -0000 1.1.4.96
+++ tree-flow.h 23 Jul 2003 19:28:07 -0000
@@ -490,7 +490,7 @@ static inline int phi_arg_from_edge (tre
static inline struct phi_arg_d *phi_element_for_edge (tree, edge);
static inline bool is_unchanging_value (tree);
static inline bool is_optimizable_addr_expr (tree);
-
+static inline bool may_propagate_copy (tree, tree);
/* In tree-must-alias.c */
void tree_compute_must_alias (tree);
Index: tree-ssa-copyprop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-copyprop.c,v
retrieving revision 1.1.2.9
diff -d -u -p -r1.1.2.9 tree-ssa-copyprop.c
--- tree-ssa-copyprop.c 23 Jul 2003 16:59:59 -0000 1.1.2.9
+++ tree-ssa-copyprop.c 23 Jul 2003 19:28:08 -0000
@@ -111,9 +111,7 @@ copyprop_stmt (tree stmt)
tree *use_p = (tree *) VARRAY_GENERIC_PTR (uses, i);
tree orig = get_original (*use_p);
- if (orig
- && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (*use_p)
- && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig))
+ if (orig && may_propagate_copy (*use_p, orig))
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@@ -209,10 +207,10 @@ get_original (tree var)
void
propagate_copy (tree *op_p, tree var)
{
- /* FIXME: Hideous hack. If *OP_P is a variable forced into a register by
- the user, don't copy propagate into it. */
- if (DECL_LANG_FLAG_4 (SSA_NAME_VAR (*op_p)))
- return;
+#if defined ENABLE_CHECKING
+ if (!may_propagate_copy (*op_p, var))
+ abort ();
+#endif
/* If VAR doesn't have a memory tag, copy the one from the original
operand. */
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.9
diff -d -u -p -r1.1.2.9 tree-ssa-dom.c
--- tree-ssa-dom.c 23 Jul 2003 11:31:30 -0000 1.1.2.9
+++ tree-ssa-dom.c 23 Jul 2003 19:28:08 -0000
@@ -474,6 +474,11 @@ optimize_stmt (block_stmt_iterator si, v
val = get_value_for (*op_p, const_and_copies);
if (val)
{
+ /* Make sure that copy propagation can be done here. */
+ if (TREE_CODE (val) == SSA_NAME
+ && !may_propagate_copy (*op_p, val))
+ continue;
+
/* Gather statistics. */
if (is_unchanging_value (val)
|| is_optimizable_addr_expr (val))
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.342.2.80
diff -d -u -p -r1.342.2.80 tree.h
--- tree.h 23 Jul 2003 16:59:59 -0000 1.342.2.80
+++ tree.h 23 Jul 2003 19:28:08 -0000
@@ -1785,6 +1785,10 @@ struct tree_type GTY(())
where it is called. */
#define DECL_INLINE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.inline_flag)
+/* In a VAR_DECL, nonzero if the decl is a register variable with
+ an explicit asm specification. */
+#define DECL_HARD_REGISTER(NODE) (DECL_CHECK (NODE)->decl.inline_flag)
+
/* Nonzero in a FUNCTION_DECL means this function has been found inlinable
only by virtue of -finline-functions */
#define DID_INLINE_FUNC(NODE) \
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.911.2.37
diff -d -u -p -r1.911.2.37 decl.c
--- cp/decl.c 23 Jul 2003 17:01:07 -0000 1.911.2.37
+++ cp/decl.c 23 Jul 2003 19:28:11 -0000
@@ -7837,7 +7837,7 @@ make_rtl_for_nonlocal_decl (tree decl, t
asm-specification, indicates that the variable should be
placed in a particular register. */
if (DECL_REGISTER (decl))
- DECL_C_HARD_REGISTER (decl) = 1;
+ DECL_HARD_REGISTER (decl) = 1;
}
/* We don't create any RTL for local variables. */