From: Marc Glisse <marc.glisse@inria.fr>
To: Richard Biener <richard.guenther@gmail.com>
Cc: "Hurugalawadi, Naveen" <Naveen.Hurugalawadi@caviumnetworks.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: Multiply Optimization in match and Simplify
Date: Fri, 30 Oct 2015 10:44:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.20.1510301119570.1907@laptop-mg.saclay.inria.fr> (raw)
In-Reply-To: <CAFiYyc1ZsiVhgeEOSCdkbXr+HuXLNbL6MkfJxe=ZRFhyk9eQdA@mail.gmail.com>
On Fri, 30 Oct 2015, Richard Biener wrote:
> +/* Convert (A + A) * C -> A * 2 * C. */
> +(simplify
> + (mult:c (convert? (plus @0 @0)) (convert? @1))
> + (if (tree_nop_conversion_p (TREE_TYPE (@0), type))
> + (convert (mult @0 (mult { build_int_cst (TREE_TYPE (@1), 2); } @1)))))
> +(simplify
> + (mult:c (convert? (plus @0 @0)) INTEGER_CST@1)
> + (if (tree_nop_conversion_p (TREE_TYPE (@0), type))
> + (convert (mult @0 (mult { build_int_cst (TREE_TYPE (@1), 2); } @1)))))
>
> fold-const.c only handles constant C, so we only need to 2nd pattern.
> Also the :c on the mult in that is not needed due to canonicalization rules.
> Please build the result of the inner multiplication directly.
> I think the fold-const.c code has an overflow issue when the outer
> multiplication
> is signed and the inner addition unsigned. (signed)((unsigned)INT_MAX
> + (unsigned)INT_MAX)*2
> is valid but INT_MAX * 4 is not as it overflows. So I think we should
> _not_ allow
> nop conversions here (it's fine if all ops are signed or unsigned).
Is there a reason why the simple transformation A+A->2*A is not
generally a desirable canonicalization? We currently restrict it to
SCALAR_FLOAT_TYPE_P.
--
Marc Glisse
next prev parent reply other threads:[~2015-10-30 10:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 8:21 Hurugalawadi, Naveen
2015-10-30 10:08 ` Richard Biener
2015-10-30 10:44 ` Marc Glisse [this message]
2015-10-30 11:06 ` Richard Biener
2015-11-03 5:13 ` Hurugalawadi, Naveen
2015-11-03 15:42 ` Richard Biener
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=alpine.DEB.2.20.1510301119570.1907@laptop-mg.saclay.inria.fr \
--to=marc.glisse@inria.fr \
--cc=Naveen.Hurugalawadi@caviumnetworks.com \
--cc=gcc-patches@gcc.gnu.org \
--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).