diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2017-05-01 10:18:18 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2017-05-01 10:18:18 +0000 |
commit | 3a324b98c577fd46d4eb56ffa61bbf67e6951a59 (patch) | |
tree | 3ebb68d33165ffaceb78449da165c12e1fda516a /gcc | |
parent | 30776a1468d25d156c02b2484d5ad7578f829d2e (diff) | |
download | gcc-3a324b98c577fd46d4eb56ffa61bbf67e6951a59.zip gcc-3a324b98c577fd46d4eb56ffa61bbf67e6951a59.tar.gz gcc-3a324b98c577fd46d4eb56ffa61bbf67e6951a59.tar.bz2 |
tree.c (substitute_in_expr): Also inline a call if the replacement expression is another instance of one of...
* tree.c (substitute_in_expr) <tcc_vl_exp>: Also inline a call if the
replacement expression is another instance of one of its arguments.
From-SVN: r247431
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/tree.c | 24 |
2 files changed, 24 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 52c6a4e..07b205c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-05-01 Eric Botcazou <ebotcazou@adacore.com> + + * tree.c (substitute_in_expr) <tcc_vl_exp>: Also inline a call if the + replacement expression is another instance of one of its arguments. + 2017-05-01 Jakub Jelinek <jakub@redhat.com> PR target/79430 @@ -3886,15 +3886,29 @@ substitute_in_expr (tree exp, tree f, tree r) new_tree = NULL_TREE; - /* If we are trying to replace F with a constant, inline back + /* If we are trying to replace F with a constant or with another + instance of one of the arguments of the call, inline back functions which do nothing else than computing a value from the arguments they are passed. This makes it possible to fold partially or entirely the replacement expression. */ - if (CONSTANT_CLASS_P (r) && code == CALL_EXPR) + if (code == CALL_EXPR) { - tree t = maybe_inline_call_in_expr (exp); - if (t) - return SUBSTITUTE_IN_EXPR (t, f, r); + bool maybe_inline = false; + if (CONSTANT_CLASS_P (r)) + maybe_inline = true; + else + for (i = 3; i < TREE_OPERAND_LENGTH (exp); i++) + if (operand_equal_p (TREE_OPERAND (exp, i), r, 0)) + { + maybe_inline = true; + break; + } + if (maybe_inline) + { + tree t = maybe_inline_call_in_expr (exp); + if (t) + return SUBSTITUTE_IN_EXPR (t, f, r); + } } for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++) |