diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-11-10 07:46:31 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-11-10 07:46:31 +0000 |
commit | 3d053ea5c19cfe989d10c3d847d0bbe1c73a7386 (patch) | |
tree | 93916a577dc944948c3fc3c3b0feb8354f23744a /gcc/tree-inline.c | |
parent | 69a837167a2ec4f5c8f7d92c1713561e69a1c6b2 (diff) | |
download | gcc-3d053ea5c19cfe989d10c3d847d0bbe1c73a7386.tar.gz |
PR middle-end/34018
* tree-inline.h (copy_body_data): Add regimplify field.
* tree-inline.c (copy_body_r): Set id->regimplify to true
if an TREE_INVARIANT ADDR_EXPR is no longer invariant after
substitutions.
(copy_bb): Clear id->regimplify before walk_tree, if it is
set afterwards, regimplify the whole statement.
* g++.dg/opt/inline14.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130068 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e7abeff0093..e0d4093a38c 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -748,6 +748,7 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data) and friends are up-to-date. */ else if (TREE_CODE (*tp) == ADDR_EXPR) { + int invariant = TREE_INVARIANT (*tp); walk_tree (&TREE_OPERAND (*tp, 0), copy_body_r, id, NULL); /* Handle the case where we substituted an INDIRECT_REF into the operand of the ADDR_EXPR. */ @@ -755,6 +756,10 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data) *tp = TREE_OPERAND (TREE_OPERAND (*tp, 0), 0); else recompute_tree_invariant_for_addr_expr (*tp); + /* If this used to be invariant, but is not any longer, + then regimplification is probably needed. */ + if (invariant && !TREE_INVARIANT (*tp)) + id->regimplify = true; *walk_subtrees = 0; } } @@ -792,6 +797,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, int count_scal tree stmt = bsi_stmt (bsi); tree orig_stmt = stmt; + id->regimplify = false; walk_tree (&stmt, copy_body_r, id, NULL); /* RETURN_EXPR might be removed, @@ -804,9 +810,10 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, int count_scal /* With return slot optimization we can end up with non-gimple (foo *)&this->m, fix that here. */ - if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT - && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1)) == NOP_EXPR - && !is_gimple_val (TREE_OPERAND (GIMPLE_STMT_OPERAND (stmt, 1), 0))) + if ((TREE_CODE (stmt) == GIMPLE_MODIFY_STMT + && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1)) == NOP_EXPR + && !is_gimple_val (TREE_OPERAND (GIMPLE_STMT_OPERAND (stmt, 1), 0))) + || id->regimplify) gimplify_stmt (&stmt); bsi_insert_after (©_bsi, stmt, BSI_NEW_STMT); |