Commit c22c0db2 by Richard Guenther Committed by Richard Biener

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
parent 88b76013
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.
2011-09-08 Iain Sandoe <iains@gcc.gnu.org> 2011-09-08 Iain Sandoe <iains@gcc.gnu.org>
*config/darwin-driver.c (darwin_find_version_from_kernel): New routine *config/darwin-driver.c (darwin_find_version_from_kernel): New routine
2011-09-08 Richard Guenther <rguenther@suse.de>
PR tree-optimization/19831
* gcc.dg/tree-ssa/ssa-dce-8.c: New testcase.
2011-09-08 Tobias Burnus <burnus@net-b.de> 2011-09-08 Tobias Burnus <burnus@net-b.de>
PR fortran/44646 PR fortran/44646
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-optimized" } */
int main()
{
int *p = __builtin_malloc (4);
*p = 4;
return 0;
}
/* { dg-final { scan-tree-dump-not "malloc" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
...@@ -299,17 +299,29 @@ mark_stmt_if_obviously_necessary (gimple stmt, bool aggressive) ...@@ -299,17 +299,29 @@ mark_stmt_if_obviously_necessary (gimple stmt, bool aggressive)
return; return;
case GIMPLE_CALL: 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 tree callee = gimple_call_fndecl (stmt);
functions) are unnecessary. */ if (callee != NULL_TREE
if (gimple_has_side_effects (stmt)) && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
{ switch (DECL_FUNCTION_CODE (callee))
mark_stmt_necessary (stmt, true); {
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; return;
} break;
if (!gimple_call_lhs (stmt)) }
return;
break;
case GIMPLE_DEBUG: case GIMPLE_DEBUG:
/* Debug temps without a value are not useful. ??? If we could /* Debug temps without a value are not useful. ??? If we could
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment