aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dce.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-09-08 09:21:39 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-09-08 09:21:39 +0000
commitc22c0db26ad16673415d7523781fcf80c8e545ba (patch)
treecacd1b123bb8053812cddbd152f5ddd2121054b5 /gcc/tree-ssa-dce.c
parent88b7601303a76eae0d7b831014cba0ff96360e73 (diff)
downloadgcc-c22c0db26ad16673415d7523781fcf80c8e545ba.zip
gcc-c22c0db26ad16673415d7523781fcf80c8e545ba.tar.gz
gcc-c22c0db26ad16673415d7523781fcf80c8e545ba.tar.bz2
re PR tree-optimization/19831 (Missing DSE/malloc/free optimization)
2011-09-08 Richard Guenther <rguenther@suse.de> PR tree-optimization/19831 * tree-ssa-dce.c (mark_stmt_if_obviously_necessary): Do not mark allocation functions as necessary. * gcc.dg/tree-ssa/ssa-dce-8.c: New testcase. From-SVN: r178683
Diffstat (limited to 'gcc/tree-ssa-dce.c')
-rw-r--r--gcc/tree-ssa-dce.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index c9ad311..e29f365 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -299,17 +299,29 @@ mark_stmt_if_obviously_necessary (gimple stmt, bool aggressive)
return;
case GIMPLE_CALL:
- /* Most, but not all function calls are required. Function calls that
- produce no result and have no side effects (i.e. const pure
- functions) are unnecessary. */
- if (gimple_has_side_effects (stmt))
- {
- mark_stmt_necessary (stmt, true);
+ {
+ tree callee = gimple_call_fndecl (stmt);
+ if (callee != NULL_TREE
+ && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+ switch (DECL_FUNCTION_CODE (callee))
+ {
+ case BUILT_IN_MALLOC:
+ case BUILT_IN_CALLOC:
+ case BUILT_IN_ALLOCA:
+ return;
+ }
+ /* Most, but not all function calls are required. Function calls that
+ produce no result and have no side effects (i.e. const pure
+ functions) are unnecessary. */
+ if (gimple_has_side_effects (stmt))
+ {
+ mark_stmt_necessary (stmt, true);
+ return;
+ }
+ if (!gimple_call_lhs (stmt))
return;
- }
- if (!gimple_call_lhs (stmt))
- return;
- break;
+ break;
+ }
case GIMPLE_DEBUG:
/* Debug temps without a value are not useful. ??? If we could