diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-31 23:53:57 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-31 23:53:57 +0000 |
commit | 3064bb7bdf4b3e57842207a7cfbb72d686ace48a (patch) | |
tree | eae0d52d578dbcd38c56a08992fb9bb1ddb7b2ac /gcc/tree-ssa-propagate.c | |
parent | 8081d3a635c46337db187a9f6971e707986bf1a8 (diff) | |
download | gcc-3064bb7bdf4b3e57842207a7cfbb72d686ace48a.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182761 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-propagate.c')
-rw-r--r-- | gcc/tree-ssa-propagate.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 80b33e11d80..a057ad72bed 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1,5 +1,5 @@ /* Generic SSA value propagation engine. - Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Diego Novillo <dnovillo@redhat.com> @@ -1056,6 +1056,12 @@ substitute_and_fold (ssa_prop_get_value_fn get_value_fn, } else if (is_gimple_call (def_stmt)) { + int flags = gimple_call_flags (def_stmt); + + /* Don't optimize away calls that have side-effects. */ + if ((flags & (ECF_CONST|ECF_PURE)) == 0 + || (flags & ECF_LOOPING_CONST_OR_PURE)) + continue; if (update_call_from_tree (&gsi, val) && maybe_clean_or_replace_eh_stmt (def_stmt, gsi_stmt (gsi))) gimple_purge_dead_eh_edges (gimple_bb (gsi_stmt (gsi))); |