optimize.c (copy_body_r): If MODIFY_EXPR has both arguments identical and they would be replaced with...

* optimize.c (copy_body_r): If MODIFY_EXPR has both arguments
	identical and they would be replaced with constant, remove
	MODIFY_EXPR from the tree.

	* g++.old-deja/g++.other/inline18.C: New test.

From-SVN: r39317
This commit is contained in:
Jakub Jelinek 2001-01-28 11:35:45 +01:00 committed by Jakub Jelinek
parent 666bd4e752
commit 6001735ea0
4 changed files with 43 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2001-01-28 Jakub Jelinek <jakub@redhat.com>
* optimize.c (copy_body_r): If MODIFY_EXPR has both arguments
identical and they would be replaced with constant, remove
MODIFY_EXPR from the tree.
2001-01-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Make-lang.in: Remove all dependencies on defaults.h.

View File

@ -338,6 +338,26 @@ copy_body_r (tp, walk_subtrees, data)
TREE_OPERAND (*tp, 1) = TREE_OPERAND (*tp, 3);
TREE_OPERAND (*tp, 3) = NULL_TREE;
}
else if (TREE_CODE (*tp) == MODIFY_EXPR
&& TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
&& nonstatic_local_decl_p (TREE_OPERAND (*tp, 0))
&& DECL_CONTEXT (TREE_OPERAND (*tp, 0)) == fn)
{
/* Assignments like a = a; don't generate any rtl code
and don't count as variable modification. Avoid
keeping bogosities like 0 = 0. */
tree decl = TREE_OPERAND (*tp, 0), value;
splay_tree_node n;
n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
if (n)
{
value = (tree) n->value;
STRIP_TYPE_NOPS (value);
if (TREE_CONSTANT (value) || TREE_READONLY_DECL_P (value))
*tp = value;
}
}
}
/* Keep iterating. */

View File

@ -1,3 +1,7 @@
2001-01-28 Jakub Jelinek <jakub@redhat.com>
* g++.old-deja/g++.other/inline18.C: New test.
2001-01-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.c-torture/execute/stdio-opt-2.c: Also test __builtin_puts

View File

@ -0,0 +1,13 @@
// Build don't link:
// Origin: Jakub Jelinek <jakub@redhat.com>
// Special g++ Options: -O3
static void foo (int a)
{
a = a;
}
static void bar (void)
{
foo (-1);
}