diff options
author | Jakub Jelinek <jakub@redhat.com> | 2012-01-01 00:53:57 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2012-01-01 00:53:57 +0100 |
commit | 45a5b21a77abdc519b14f8c1a8d3340b58be43f2 (patch) | |
tree | eae0d52d578dbcd38c56a08992fb9bb1ddb7b2ac /gcc/tree-ssa-ccp.c | |
parent | 6f2ffb4b99ccfb64adc0edc9998329ee9de32eff (diff) | |
download | gcc-45a5b21a77abdc519b14f8c1a8d3340b58be43f2.zip gcc-45a5b21a77abdc519b14f8c1a8d3340b58be43f2.tar.gz gcc-45a5b21a77abdc519b14f8c1a8d3340b58be43f2.tar.bz2 |
re PR tree-optimization/51683 (__builtin_memcpy etc. with constant first argument optimized away by ccp)
PR tree-optimization/51683
* tree-ssa-propagate.c (substitute_and_fold): Don't optimize away
calls with side-effects.
* tree-ssa-ccp.c (ccp_fold_stmt): Likewise.
* gcc.dg/pr51683.c: New test.
From-SVN: r182761
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index a9c38ee..738606f 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1,6 +1,6 @@ /* Conditional constant propagation pass for the GNU compiler. Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, - 2010, 2011 Free Software Foundation, Inc. + 2010, 2011, 2012 Free Software Foundation, Inc. Adapted from original RTL SSA-CCP by Daniel Berlin <dberlin@dberlin.org> Adapted to GIMPLE trees by Diego Novillo <dnovillo@redhat.com> @@ -1878,6 +1878,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi) case GIMPLE_CALL: { tree lhs = gimple_call_lhs (stmt); + int flags = gimple_call_flags (stmt); tree val; tree argt; bool changed = false; @@ -1888,7 +1889,10 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi) type issues. */ if (lhs && TREE_CODE (lhs) == SSA_NAME - && (val = get_constant_value (lhs))) + && (val = get_constant_value (lhs)) + /* Don't optimize away calls that have side-effects. */ + && (flags & (ECF_CONST|ECF_PURE)) != 0 + && (flags & ECF_LOOPING_CONST_OR_PURE) == 0) { tree new_rhs = unshare_expr (val); bool res; |