This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improve stmt folding with match-and-simplify
- From: Richard Biener <rguenther at suse dot de>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 11 Aug 2015 15:18:13 +0200 (CEST)
- Subject: Re: [PATCH] Improve stmt folding with match-and-simplify
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1507290939220 dot 19642 at zhemvz dot fhfr dot qr> <20150811131624 dot GD3335 at redhat dot com>
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 <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)