This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix processing of ADDR_EXPR in get_expr_operands
- 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: Thu, 29 Jul 2004 13:12:33 -0400
- Subject: Fix processing of ADDR_EXPR in get_expr_operands
- Organization: Red Hat Canada
As discussed yesterday, is_gimple_min_invariant is the correct test for
checking constness in an ADDR_EXPR node.
Bootstrapped and tested x86, x86-64, alpha and ppc.
Diego.
* tree-ssa-operands.c (get_expr_operands): Revert changes
to ADDR_EXPR processing introduced by:
2004-06-21 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* tree-ssa-operands.c (get_expr_operands): Minor rearrangements.
testsuite/ChangeLog
* gcc.dg/tree-ssa/20040729-1.c: New test case.
Index: tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v
retrieving revision 2.26
diff -d -c -p -r2.26 tree-ssa-operands.c
*** tree-ssa-operands.c 28 Jul 2004 05:13:08 -0000 2.26
--- tree-ssa-operands.c 29 Jul 2004 17:07:51 -0000
*************** get_expr_operands (tree stmt, tree *expr
*** 859,867 ****
of interest to some passes (e.g. alias resolution). */
add_stmt_operand (expr_p, stmt, 0, NULL);
! /* If the address is constant (invariant is not sufficient), there will
! be no interesting variable references inside. */
! if (TREE_CONSTANT (expr))
return;
/* There should be no VUSEs created, since the referenced objects are
--- 859,867 ----
of interest to some passes (e.g. alias resolution). */
add_stmt_operand (expr_p, stmt, 0, NULL);
! /* If the address is invariant, there may be no interesting variable
! references inside. */
! if (is_gimple_min_invariant (expr))
return;
/* There should be no VUSEs created, since the referenced objects are
Index: testsuite/gcc.dg/tree-ssa/20040729-1.c
===================================================================
RCS file: testsuite/gcc.dg/tree-ssa/20040729-1.c
diff -N testsuite/gcc.dg/tree-ssa/20040729-1.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/tree-ssa/20040729-1.c 29 Jul 2004 17:07:55 -0000
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O1 -fdump-tree-dce3" } */
+
+ foo ()
+ {
+ volatile int *p;
+ volatile int x;
+
+ p = &x;
+ *p = 3;
+ return *p + 1;
+ }
+
+ /* The assignment to 'p' is dead and should be removed. But the
+ compiler was mistakenly thinking that the statement had volatile
+ operands. But 'p' itself is not volatile and taking the address of
+ a volatile does not constitute a volatile operand. */
+ /* { dg-final { scan-tree-dump-times "&x" 0 "dce3"} } */