From: Richard Biener <richard.guenther@gmail.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jeff Law <law@redhat.com>
Subject: Re: More type narrowing in match.pd
Date: Thu, 30 Apr 2015 11:18:00 -0000 [thread overview]
Message-ID: <CAFiYyc3q1Lw4t3sL82y9HJuPnrd5j9fkAnex0Ycqj5LhtCU36A@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1504301247330.9338@stedding.saclay.inria.fr>
On Thu, Apr 30, 2015 at 12:53 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Thu, 30 Apr 2015, Richard Biener wrote:
>
>> I have in my local dev tree (so completely untested...)
>>
>> @@ -1040,31 +1052,22 @@ (define_operator_list CBRT BUILT_IN_CBRT
>> operation and convert the result to the desired type. */
>> (for op (plus minus)
>> (simplify
>> - (convert (op (convert@2 @0) (convert@3 @1)))
>> + (convert (op:c@4 (convert@2 @0) (convert?@3 @1)))
>
>
> I believe the :c here requires extra code further down, so we don't turn a-b
> into b-a.
Indeed. I've added :c only for minus as 5 - x can't be canonicalized to
move the constant to 2nd position which is always possible for plus.
Might be cleaner to add a separate pattern for that case.
Richard.
>
>> (if (INTEGRAL_TYPE_P (type)
>> - /* We check for type compatibility between @0 and @1 below,
>> - so there's no need to check that @1/@3 are integral types. */
>> && INTEGRAL_TYPE_P (TREE_TYPE (@0))
>> - && INTEGRAL_TYPE_P (TREE_TYPE (@2))
>> + && INTEGRAL_TYPE_P (TREE_TYPE (@4))
>> /* The precision of the type of each operand must match the
>> precision of the mode of each operand, similarly for the
>> result. */
>> && (TYPE_PRECISION (TREE_TYPE (@0))
>> == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@0))))
>> - && (TYPE_PRECISION (TREE_TYPE (@1))
>> - == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@1))))
>> - && TYPE_PRECISION (type) == GET_MODE_PRECISION (TYPE_MODE (type))
>> /* The inner conversion must be a widening conversion. */
>> && TYPE_PRECISION (TREE_TYPE (@2)) > TYPE_PRECISION (TREE_TYPE
>> (@0))
>> - && ((GENERIC
>> - && (TYPE_MAIN_VARIANT (TREE_TYPE (@0))
>> - == TYPE_MAIN_VARIANT (TREE_TYPE (@1)))
>> - && (TYPE_MAIN_VARIANT (TREE_TYPE (@0))
>> - == TYPE_MAIN_VARIANT (type)))
>> - || (GIMPLE
>> - && types_compatible_p (TREE_TYPE (@0), TREE_TYPE (@1))
>> - && types_compatible_p (TREE_TYPE (@0), type))))
>> + /* The final precision should match that of operand @0. */
>> + && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (@0))
>> + /* Make sure the wide operation is dead after the transform. */
>> + && (TREE_CODE (@4) != SSA_NAME || has_single_use (@4)))
>> (if (TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0)))
>> - (convert (op @0 @1)))
>> + (convert (op @0 (convert @1))))
>> (with { tree utype = unsigned_type_for (TREE_TYPE (@0)); }
>> (convert (op (convert:utype @0) (convert:utype @1)))))))
>
>
> --
> Marc Glisse
next prev parent reply other threads:[~2015-04-30 11:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 3:57 Jeff Law
2015-04-30 7:28 ` Marc Glisse
2015-04-30 17:29 ` Jeff Law
2015-04-30 23:23 ` Marc Glisse
2015-05-01 18:41 ` Jeff Law
2015-04-30 9:22 ` Richard Biener
2015-04-30 11:10 ` Marc Glisse
2015-04-30 11:18 ` Richard Biener [this message]
2015-05-01 18:57 ` Jeff Law
2015-04-30 16:04 ` 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=CAFiYyc3q1Lw4t3sL82y9HJuPnrd5j9fkAnex0Ycqj5LhtCU36A@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.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).