diff options
| author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-10-01 12:22:17 +0000 |
|---|---|---|
| committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-10-01 12:22:17 +0000 |
| commit | ec3753d09f91e135d95a3cb498533b46e7a35117 (patch) | |
| tree | addc07606e7868c2c10e5917c7b181b4897efeab | |
| parent | 7c0666667098987cfb44c664c15cf11c68f314f5 (diff) | |
| download | ppe42-gcc-ec3753d09f91e135d95a3cb498533b46e7a35117.tar.gz ppe42-gcc-ec3753d09f91e135d95a3cb498533b46e7a35117.zip | |
2008-09-30 Paolo Bonzini <bonzini@gnu.org>
PR tree-optimization/37662
* tree-ssa-ccp.c (fold_gimple_assign): Invert the operands of a
commutative binary operation if they are in the wrong order and
fold_build2 produces non-GIMPLE.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140809 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 7 | ||||
| -rw-r--r-- | gcc/tree-ssa-ccp.c | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ba26097f14b..b6f16013f84 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2008-09-30 Paolo Bonzini <bonzini@gnu.org> + + PR tree-optimization/37662 + * tree-ssa-ccp.c (fold_gimple_assign): Invert the operands of a + commutative binary operation if they are in the wrong order and + fold_build2 produces non-GIMPLE. + 2008-09-30 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/37662 diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 22626a53840..383367e9fb1 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2711,6 +2711,17 @@ fold_gimple_assign (gimple_stmt_iterator *si) STRIP_USELESS_TYPE_CONVERSION (result); if (valid_gimple_rhs_p (result)) return result; + + /* Fold might have produced non-GIMPLE, so if we trust it blindly + we lose canonicalization opportunities. Do not go again + through fold here though, or the same non-GIMPLE will be + produced. */ + if (commutative_tree_code (subcode) + && tree_swap_operands_p (gimple_assign_rhs1 (stmt), + gimple_assign_rhs2 (stmt), false)) + return build2 (subcode, TREE_TYPE (gimple_assign_lhs (stmt)), + gimple_assign_rhs2 (stmt), + gimple_assign_rhs1 (stmt)); } break; |

