From: Richard Biener <richard.guenther@gmail.com>
To: Marc Glisse <marc.glisse@inria.fr>,
Prathamesh <bilbotheelffriend@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Move ABS detection from fold-const.c to match.pd
Date: Tue, 26 May 2015 09:30:00 -0000 [thread overview]
Message-ID: <CAFiYyc0xGmzoB=ToiByuK68Xc3g5jpby6YgbiTtQabu7kOgSGA@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1505241504030.1625@laptop-mg.saclay.inria.fr>
On Sun, May 24, 2015 at 3:17 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
>
> I forgot to mention I optimistically tried to write something like this:
>
> (match
> (negated_value_for_comparison @0)
> (negate @0))
> (match
> (negated_value_for_comparison (negate @0))
> @0)
> (match
> (negated_value_for_comparison (minus @0 @1))
> (if (!HONOR_SIGN_DEPENDENT_ROUNDING (type))
> (minus @1 @0))
>
> without success. There is already a comment for logical_inverted_value about
> related limitations in genmatch.
Yeah, Prathamesh was working on inlining - not sure if that ended up
in sth usable?
+(match zerop integer_zerop)
+(match zerop real_zerop)
Would it also include fixed_zerop? Note that with inlining implemented it would
duplicate the pattern for each match variant thus in this case adding a
tree.[ch] function zerop () might be better.
+ (simplify
+ (cnd (cmp @0 zerop) (convert?@2 @0) (negate@1 @2))
+ (if (cmp == EQ_EXPR || cmp == UNEQ_EXPR)
+ @1)
+ (if (cmp == NE_EXPR || cmp == LTGT_EXPR)
+ (non_lvalue @2))
+ (if (TYPE_SIGN (TREE_TYPE (@0)) == SIGNED /* implicit */
+ && TYPE_SIGN (type) == SIGNED
+ && element_precision (type) >= element_precision (TREE_TYPE (@0)))
+ (if (cmp == GE_EXPR || cmp == GT_EXPR
+ || (!flag_trapping_math && (cmp == UNGE_EXPR || cmp == UNGT_EXPR)))
+ (abs @2))
+ (if (cmp == LE_EXPR || cmp == LT_EXPR
+ || (!flag_trapping_math && (cmp == UNLE_EXPR || cmp == UNLT_EXPR)))
+ (negate (abs @2)))))
+ /* Now with the branches swapped. */
+ (simplify
+ (cnd (cmp @0 zerop) (negate@1 (convert?@2 @0)) @2)
not obvious from a quick look - but would you be able to remove the
swapped branch
vairant if (cnd:c (cmp @0 zerop) X Y) would work by swapping X and Y?
The fold-const.c code doesn't seem to handle as many variants (esp.
the swapping?),
so maybe you can add a testcase that exercises some of the above on GIMPLE?
Thanks,
Richard.
>
> --
> Marc Glisse
next prev parent reply other threads:[~2015-05-26 9:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-24 12:50 Marc Glisse
2015-05-24 15:54 ` Marc Glisse
2015-05-26 9:30 ` Richard Biener [this message]
2015-06-28 19:43 ` Marc Glisse
2015-06-29 10:31 ` 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='CAFiYyc0xGmzoB=ToiByuK68Xc3g5jpby6YgbiTtQabu7kOgSGA@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=bilbotheelffriend@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=marc.glisse@inria.fr \
/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).