From: Marc Glisse <marc.glisse@inria.fr>
To: Tamar Christina <Tamar.Christina@arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
nd <nd@arm.com>, "law@redhat.com" <law@redhat.com>,
"ian@airs.com" <ian@airs.com>,
"rguenther@suse.de" <rguenther@suse.de>,
"joseph@codesourcery.com" <joseph@codesourcery.com>
Subject: Re: [GCC][middle-end] Add rules to strip away unneeded type casts in expressions (2nd patch)
Date: Mon, 07 Jan 2019 14:56:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.21.1901071536430.7012@grove.saclay.inria.fr> (raw)
In-Reply-To: <DB6PR0802MB230913AFE63FDC02AD1CB040FF890@DB6PR0802MB2309.eurprd08.prod.outlook.com>
On Mon, 7 Jan 2019, Tamar Christina wrote:
> The 01/04/2019 17:50, Marc Glisse wrote:
>>> + (convert:newtype (op (convert:newtype @1) (convert:newtype @2)))
>>
>> The outer 'convert' is unnecessary, op already has the same type.
>>
>
> Does it? The only comparison that has been done between the type of op and "type" is that
> they are both a decimal floating point type. I don't see any reason why they have to be the
> same type.
op is just PLUS_EXPR (or another operation), it isn't related to @0, it
does not have a type in itself. When you build the sum of 2 objects of
type newtype, the result has type newtype. On the other hand, if newtype
is not the same as type, you may be missing a conversion of the result to
type. Ah, I see that newtype is always == type here.
>>> + (nop:type (op (convert:ty1 @1) (convert:ty2 @2)))))
>>
>> Please don't use 'nop' directly, use 'convert' instead. This line is very
>> suspicious, both arguments of op should have the same type. Specifying the
>> outertype should be unnecessary, it is always 'type'. And if necessary, I
>> expect '(convert:ty1 @1)' is the same as '{ arg0; }'.
>>
>
> Ah I wasn't aware I could use arg0 here. I've updated the patch, though I don't
> really find this clearer.
> + (convert (op (convert:ty1 { arg0; }) (convert:ty2 { arg1; })))))
I think you misunderstood my point. What you wrote is equivalent to:
(convert (op { arg0; } { arg1; }))))
since arg0 already has type ty1. And I am complaining that both arguments
to op must have the same type, but you are creating one of type ty1 and
one of type ty2, which doesn't clearly indicate that ty1==ty2.
Maybe experiment with
(long double)some_float * (long double)some_double
cast to either float or double.
SCALAR_FLOAT_TYPE_P may be safer than FLOAT_TYPE_P.
--
Marc Glisse
next prev parent reply other threads:[~2019-01-07 14:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-04 10:46 Tamar Christina
2019-01-04 17:51 ` Marc Glisse
2019-01-07 14:32 ` Tamar Christina
2019-01-07 14:56 ` Marc Glisse [this message]
2019-01-08 13:57 ` Tamar Christina
2019-06-25 8:31 Tamar Christina
2019-06-25 8:33 ` Tamar Christina
2019-06-25 9:02 ` Richard Biener
2019-07-02 9:41 ` Tamar Christina
2019-07-02 10:20 ` Richard Biener
2019-07-02 16:44 ` Tamar Christina
2019-07-03 9:06 ` 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.21.1901071536430.7012@grove.saclay.inria.fr \
--to=marc.glisse@inria.fr \
--cc=Tamar.Christina@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ian@airs.com \
--cc=joseph@codesourcery.com \
--cc=law@redhat.com \
--cc=nd@arm.com \
--cc=rguenther@suse.de \
/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).