From 0778d4e84ac1d0f4dadec932144198770a9b0318 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Sat, 21 Oct 2006 13:23:41 +0000 Subject: re PR tree-optimization/3511 (Inlined strlen() could be smarter) 2006-10-21 Richard Guenther PR tree-optimization/3511 * tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that got new invariant arguments during PHI translation. * gcc.dg/tree-ssa/ssa-pre-15.c: New testcase. From-SVN: r117932 --- gcc/tree-ssa-pre.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/tree-ssa-pre.c') diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 9c7b89f..ba32b3c 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1076,6 +1076,7 @@ phi_translate (tree expr, value_set_t set, basic_block pred, tree newexpr; tree vh = get_value_handle (expr); bool listchanged = false; + bool invariantarg = false; VEC (tree, gc) *vuses = VALUE_HANDLE_VUSES (vh); VEC (tree, gc) *tvuses; @@ -1134,10 +1135,26 @@ phi_translate (tree expr, value_set_t set, basic_block pred, if (newval != oldval) { listchanged = true; + invariantarg |= is_gimple_min_invariant (newval); TREE_VALUE (newwalker) = get_value_handle (newval); } } } + + /* In case of new invariant args we might try to fold the call + again. */ + if (invariantarg) + { + tree tmp = fold_ternary (CALL_EXPR, TREE_TYPE (expr), + newop0, newarglist, newop2); + if (tmp) + { + STRIP_TYPE_NOPS (tmp); + if (is_gimple_min_invariant (tmp)) + return tmp; + } + } + if (listchanged) vn_lookup_or_add (newarglist, NULL); -- cgit v1.1