From: Jakub Jelinek <jakub@redhat.com>
To: Jeff Law <law@redhat.com>
Cc: Christophe Lyon <christophe.lyon@linaro.org>,
Richard Biener <richard.guenther@gmail.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFA] [PATCH][PR tree-optimization/64910] Fix reassociation of binary bitwise operations with 3 operands
Date: Wed, 06 Sep 2017 09:26:00 -0000 [thread overview]
Message-ID: <20170906092618.GL2323@tucnak> (raw)
In-Reply-To: <9611166b-76e6-c28f-32bf-03e03eae9194@redhat.com>
On Tue, Sep 05, 2017 at 11:21:48PM -0600, Jeff Law wrote:
> --- a/gcc/tree-ssa-reassoc.c
> +++ b/gcc/tree-ssa-reassoc.c
> @@ -5763,14 +5763,15 @@ reassociate_bb (basic_block bb)
> "Width = %d was chosen for reassociation\n", width);
>
>
> - /* For binary bit operations, if the last operand in
> - OPS is a constant, move it to the front. This
> - helps ensure that we generate (X & Y) & C rather
> - than (X & C) & Y. The former will often match
> - a canonical bit test when we get to RTL. */
> - if ((rhs_code == BIT_AND_EXPR
> - || rhs_code == BIT_IOR_EXPR
> - || rhs_code == BIT_XOR_EXPR)
> + /* For binary bit operations, if there are at least 3
> + operands and the last last operand in OPS is a constant,
> + move it to the front. This helps ensure that we generate
> + (X & Y) & C rather than (X & C) & Y. The former will
> + often match a canonical bit test when we get to RTL. */
> + if (ops.length () != 2
So wouldn't it be clearer to write ops.length () > 2 ?
if (ops.length () == 0)
else if (ops.length () == 1)
come earlier, so it is the same thing, but might help the reader.
> + && (rhs_code == BIT_AND_EXPR
> + || rhs_code == BIT_IOR_EXPR
> + || rhs_code == BIT_XOR_EXPR)
> && TREE_CODE (ops.last ()->op) == INTEGER_CST)
> std::swap (*ops[0], *ops[ops_num - 1]);
Don't you then want to put the constant as second operand rather than first,
i.e. swap with *ops[1]?
And doesn't swap_ops_for_binary_stmt undo it again?
Jakub
next prev parent reply other threads:[~2017-09-06 9:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-21 23:39 Jeff Law
2016-01-08 9:37 ` Richard Biener
2016-01-08 23:20 ` Jeff Law
2016-01-11 10:32 ` Richard Biener
2016-01-12 5:10 ` Jeff Law
2016-01-12 15:11 ` Richard Biener
2016-01-13 6:40 ` Jeff Law
2016-01-13 12:30 ` Richard Biener
2017-09-03 14:45 ` Jeff Law
2017-09-04 9:36 ` Richard Biener
2017-09-05 6:38 ` Christophe Lyon
2017-09-05 17:26 ` Jeff Law
2017-09-06 5:21 ` Jeff Law
2017-09-06 9:26 ` Jakub Jelinek [this message]
2017-10-13 16:37 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170906092618.GL2323@tucnak \
--to=jakub@redhat.com \
--cc=christophe.lyon@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).