diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1200433e317..21b55857260 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-11-19 Joseph S. Myers + + * combine.c (make_compound_operation): Swap operands of + commutative operation if necessary before returning. + 2005-11-19 Richard Guenther PR middle-end/23294 diff --git a/gcc/combine.c b/gcc/combine.c index 9f910a7b336..b43b9b621c6 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6914,6 +6914,16 @@ make_compound_operation (rtx x, enum rtx_code in_code) SUBST (XEXP (x, i), new); } + /* If this is a commutative operation, the changes to the operands + may have made it noncanonical. */ + if (COMMUTATIVE_ARITH_P (x) + && swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1))) + { + tem = XEXP (x, 0); + SUBST (XEXP (x, 0), XEXP (x, 1)); + SUBST (XEXP (x, 1), tem); + } + return x; }