mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-21 15:39:54 +08:00
re PR tree-optimization/3713 (Pointers to functions or member functions are not folded or inlined)
2013-03-18 Richard Biener <rguenther@suse.de> PR tree-optimization/3713 * tree-ssa-sccvn.c (visit_copy): Simplify. Always propagate has_constants and expr. (stmt_has_constants): Properly valueize SSA names when deciding whether the stmt has constants. * g++.dg/ipa/devirt-12.C: New testcase. From-SVN: r196771
This commit is contained in:
parent
789c34e3c7
commit
0d5a1b5694
@ -1,3 +1,11 @@
|
||||
2013-03-18 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/3713
|
||||
* tree-ssa-sccvn.c (visit_copy): Simplify. Always propagate
|
||||
has_constants and expr.
|
||||
(stmt_has_constants): Properly valueize SSA names when deciding
|
||||
whether the stmt has constants.
|
||||
|
||||
2013-03-18 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* tree-ssa-loop-manip.c (find_uses_to_rename): Do not scan the
|
||||
|
@ -1,3 +1,8 @@
|
||||
2013-03-18 Richard Biener <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/3713
|
||||
* g++.dg/ipa/devirt-12.C: New testcase.
|
||||
|
||||
2013-03-18 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c/56566
|
||||
|
22
gcc/testsuite/g++.dg/ipa/devirt-12.C
Normal file
22
gcc/testsuite/g++.dg/ipa/devirt-12.C
Normal file
@ -0,0 +1,22 @@
|
||||
// { dg-do compile }
|
||||
// { dg-options "-std=c++11 -O -fdump-ipa-inline" }
|
||||
|
||||
class Foo
|
||||
{
|
||||
public:
|
||||
void Bar() const
|
||||
{
|
||||
__builtin_puts ("Howdy!");
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Foo x;
|
||||
auto y = &Foo::Bar;
|
||||
(x.*y)();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// { dg-final { scan-ipa-dump "Inlined 1 calls, eliminated 1 functions" "inline" } }
|
||||
// { dg-final { cleanup-ipa-dump "inline" } }
|
@ -2652,18 +2652,13 @@ static tree valueize_expr (tree expr);
|
||||
static bool
|
||||
visit_copy (tree lhs, tree rhs)
|
||||
{
|
||||
/* Follow chains of copies to their destination. */
|
||||
while (TREE_CODE (rhs) == SSA_NAME
|
||||
&& SSA_VAL (rhs) != rhs)
|
||||
rhs = SSA_VAL (rhs);
|
||||
|
||||
/* The copy may have a more interesting constant filled expression
|
||||
(we don't, since we know our RHS is just an SSA name). */
|
||||
if (TREE_CODE (rhs) == SSA_NAME)
|
||||
{
|
||||
VN_INFO (lhs)->has_constants = VN_INFO (rhs)->has_constants;
|
||||
VN_INFO (lhs)->expr = VN_INFO (rhs)->expr;
|
||||
}
|
||||
VN_INFO (lhs)->has_constants = VN_INFO (rhs)->has_constants;
|
||||
VN_INFO (lhs)->expr = VN_INFO (rhs)->expr;
|
||||
|
||||
/* And finally valueize. */
|
||||
rhs = SSA_VAL (rhs);
|
||||
|
||||
return set_ssa_val_to (lhs, rhs);
|
||||
}
|
||||
@ -3062,25 +3057,38 @@ expr_has_constants (tree expr)
|
||||
static bool
|
||||
stmt_has_constants (gimple stmt)
|
||||
{
|
||||
tree tem;
|
||||
|
||||
if (gimple_code (stmt) != GIMPLE_ASSIGN)
|
||||
return false;
|
||||
|
||||
switch (get_gimple_rhs_class (gimple_assign_rhs_code (stmt)))
|
||||
{
|
||||
case GIMPLE_UNARY_RHS:
|
||||
return is_gimple_min_invariant (gimple_assign_rhs1 (stmt));
|
||||
case GIMPLE_TERNARY_RHS:
|
||||
tem = gimple_assign_rhs3 (stmt);
|
||||
if (TREE_CODE (tem) == SSA_NAME)
|
||||
tem = SSA_VAL (tem);
|
||||
if (is_gimple_min_invariant (tem))
|
||||
return true;
|
||||
/* Fallthru. */
|
||||
|
||||
case GIMPLE_BINARY_RHS:
|
||||
return (is_gimple_min_invariant (gimple_assign_rhs1 (stmt))
|
||||
|| is_gimple_min_invariant (gimple_assign_rhs2 (stmt)));
|
||||
case GIMPLE_TERNARY_RHS:
|
||||
return (is_gimple_min_invariant (gimple_assign_rhs1 (stmt))
|
||||
|| is_gimple_min_invariant (gimple_assign_rhs2 (stmt))
|
||||
|| is_gimple_min_invariant (gimple_assign_rhs3 (stmt)));
|
||||
tem = gimple_assign_rhs2 (stmt);
|
||||
if (TREE_CODE (tem) == SSA_NAME)
|
||||
tem = SSA_VAL (tem);
|
||||
if (is_gimple_min_invariant (tem))
|
||||
return true;
|
||||
/* Fallthru. */
|
||||
|
||||
case GIMPLE_SINGLE_RHS:
|
||||
/* Constants inside reference ops are rarely interesting, but
|
||||
it can take a lot of looking to find them. */
|
||||
return is_gimple_min_invariant (gimple_assign_rhs1 (stmt));
|
||||
case GIMPLE_UNARY_RHS:
|
||||
tem = gimple_assign_rhs1 (stmt);
|
||||
if (TREE_CODE (tem) == SSA_NAME)
|
||||
tem = SSA_VAL (tem);
|
||||
return is_gimple_min_invariant (tem);
|
||||
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user