This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/11373] [tree-ssa] asm generated lhs expressions are discarded
- From: "dnovillo at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Jul 2003 23:51:24 -0000
- Subject: [Bug optimization/11373] [tree-ssa] asm generated lhs expressions are discarded
- References: <20030629143256.11373.marcus@jet.franken.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11373
------- Additional Comments From dnovillo at redhat dot com 2003-07-25 23:51 -------
Subject: Re: [tree-ssa] asm generated lhs
expressions are discarded
This patch should fix the problem. I will commit it in my next round of
patches.
Diego.
PR optimization/11373
* tree-ssa-dce.c (stmt_useful_p): Scan operands before checking
for volatile operands.
* tree-dfa.c (get_expr_operands): If a nonzero constant is used in
an INDIRECT_REF expression, mark the statement as having volatile
operands.
(may_access_global_mem_p): Return true if the pointer is a nonzero
constant.
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dce.c,v
retrieving revision 1.1.2.47
diff -d -u -p -r1.1.2.47 tree-ssa-dce.c
--- tree-ssa-dce.c 22 Jul 2003 02:50:15 -0000 1.1.2.47
+++ tree-ssa-dce.c 25 Jul 2003 23:48:44 -0000
@@ -283,12 +283,12 @@ stmt_useful_p (tree stmt)
return true;
}
+ /* Examine all the stores in this statement. */
+ get_stmt_operands (stmt);
+
/* If the statement has volatile operands, it needs to be preserved. */
if (stmt_ann (stmt)->has_volatile_ops)
return true;
-
- /* Examine all the stores in this statement. */
- get_stmt_operands (stmt);
ops = def_ops (stmt);
for (i = 0; ops && i < VARRAY_ACTIVE_SIZE (ops); i++)
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.135
diff -d -u -p -r1.1.4.135 tree-dfa.c
--- tree-dfa.c 25 Jul 2003 03:13:07 -0000 1.1.4.135
+++ tree-dfa.c 25 Jul 2003 23:48:44 -0000
@@ -377,6 +377,15 @@ get_expr_operands (tree stmt, tree *expr
add_stmt_operand (&TREE_OPERAND (ptr, 0), stmt, flags, prev_vops);
return;
}
+ else if (TREE_CONSTANT (ptr) && !integer_zerop (ptr))
+ {
+ /* If a constant is used as a pointer, we can't generate a real
+ operand for it but we mark the statement volatile to prevent
+ optimizations from messing things up. */
+ stmt_ann (stmt)->has_volatile_ops = true;
+ return;
+ }
+
/* Add a USE operand for the base pointer. */
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), opf_none, prev_vops);
@@ -2103,6 +2112,10 @@ may_access_global_mem_p (tree expr)
/* Call expressions that return pointers may point to global memory. */
if (TREE_CODE (expr) == CALL_EXPR)
+ return true;
+
+ /* A non-NULL constant used as a pointer points to global memory. */
+ if (TREE_CONSTANT (expr) && !integer_zerop (expr))
return true;
/* Recursively check the expression's operands. */