summaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-18 11:59:34 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-18 11:59:34 +0000
commit6fec5449ffb1eab7e0304f988ce6c85d83ade73b (patch)
treeed06be32d0f633307c932b9633f8c7ecf01cec59 /gcc/gimple-fold.c
parent52f6cc19df24a2deda0b973746f05bce6453961a (diff)
downloadgcc-6fec5449ffb1eab7e0304f988ce6c85d83ade73b.tar.gz
2011-04-18 Richard Guenther <rguenther@suse.de>
* gimple.h (gimple_call_addr_fndecl): New function. (gimple_call_fndecl): Use it. * gimple-fold.c (gimple_fold_call): Fold away OBJ_TYPE_REFs for direct calls. * tree-ssa-ccp.c (ccp_fold_stmt): Remove OBJ_TYPE_REF folding. * tree-ssa-pre.c (eliminate): Also simplify indirect OBJ_TYPE_REFs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172644 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index f629fd565a1..9047f670e7d 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1450,11 +1450,11 @@ bool
gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
{
gimple stmt = gsi_stmt (*gsi);
-
- tree callee = gimple_call_fndecl (stmt);
+ tree callee;
/* Check for builtins that CCP can handle using information not
available in the generic fold routines. */
+ callee = gimple_call_fndecl (stmt);
if (!inplace && callee && DECL_BUILT_IN (callee))
{
tree result = gimple_fold_builtin (stmt);
@@ -1466,6 +1466,16 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
return true;
}
}
+
+ /* Check for virtual calls that became direct calls. */
+ callee = gimple_call_fn (stmt);
+ if (TREE_CODE (callee) == OBJ_TYPE_REF
+ && gimple_call_addr_fndecl (OBJ_TYPE_REF_EXPR (callee)) != NULL_TREE)
+ {
+ gimple_call_set_fn (stmt, OBJ_TYPE_REF_EXPR (callee));
+ return true;
+ }
+
return false;
}