http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53774
Richard Guenther <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org |gnu.org | --- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-26 14:24:13 UTC --- I am testing instead @@ -2299,8 +2299,16 @@ rewrite_expr_tree (gimple stmt, unsigned print_gimple_stmt (dump_file, stmt, 0, 0); } - gimple_assign_set_rhs1 (stmt, oe1->op); - gimple_assign_set_rhs2 (stmt, oe2->op); + if (tree_swap_operands_p (oe1->op, oe2->op, true)) + { + gimple_assign_set_rhs1 (stmt, oe2->op); + gimple_assign_set_rhs2 (stmt, oe1->op); + } + else + { + gimple_assign_set_rhs1 (stmt, oe1->op); + gimple_assign_set_rhs2 (stmt, oe2->op); + } update_stmt (stmt); if (rhs1 != oe1->op && rhs1 != oe2->op) remove_visited_stmt_chain (rhs1); which fixes it. OTOH there are many other places reassoc adjusts stmt operands (but it eventually relies on operand order). Adding a canonicalize_operand_order_and_update_stmt () wherever we call update_stmt afer adjusting operands might be better ... or simply calling fold_stmt on all stmts we touch which does the re-ordering, too. Well, I'm not really sure where we should enforce canonical ordering ...