On Tue, 11 Aug 2015, Marek Polacek wrote: > On Wed, Jul 29, 2015 at 09:44:36AM +0200, Richard Biener wrote: > > @@ -3547,6 +3566,27 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, > > && maybe_canonicalize_mem_ref_addr (lhs)) > > changed = true; > > } > > + else > > + { > > + /* Canonicalize operand order. */ > > + enum tree_code code = gimple_assign_rhs_code (stmt); > > + if (TREE_CODE_CLASS (code) == tcc_comparison > > + || commutative_tree_code (code) > > + || commutative_ternary_tree_code (code)) > > + { > > + tree rhs1 = gimple_assign_rhs1 (stmt); > > + tree rhs2 = gimple_assign_rhs2 (stmt); > > + if (tree_swap_operands_p (rhs1, rhs2, false)) > > + { > > + gimple_assign_set_rhs1 (stmt, rhs2); > > + gimple_assign_set_rhs2 (stmt, rhs1); > > + if (TREE_CODE_CLASS (code) == tcc_comparison) > > Is the second check for tcc_comparison needed? We checked for that a few > lines above. > > > + gimple_assign_set_rhs_code (stmt, > > + swap_tree_comparison (code)); > > + changed = true;
Yep because it might also be a non-comparison. > Marek > > -- Richard Biener <rguent...@suse.de> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)