From: Marc Glisse <marc.glisse@inria.fr>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Prathamesh <bilbotheelffriend@gmail.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Move ABS detection from fold-const.c to match.pd
Date: Sun, 28 Jun 2015 19:43:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.11.1505261318470.15445@stedding.saclay.inria.fr> (raw)
In-Reply-To: <CAFiYyc0xGmzoB=ToiByuK68Xc3g5jpby6YgbiTtQabu7kOgSGA@mail.gmail.com>
(this message looks like it was lost in my draft folder...)
On Tue, 26 May 2015, Richard Biener wrote:
> +(match zerop integer_zerop)
> +(match zerop real_zerop)
>
> Would it also include fixed_zerop?
Probably, yes. The main issue is that I know next to nothing about
fixed-point types, so I am always unsure how to handle them (when I don't
forget them completely). For instance, in the recently added -A CMP -B, we
could probably replace
(if (FLOAT_TYPE_P (TREE_TYPE (@0))
|| (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
&& TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))))
with
(if (FLOAT_TYPE_P (TREE_TYPE (@0))
|| TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))
> 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.
Ah... I actually thought we might end up moving things like integer_zerop
from tree.c to match.pd, especially since predicates are not declared
'static'... Ok, reverse gear.
Note that inlining does not seem necessary to implement more advanced
predicates like negated_value_for_comparison in the parent message.
> + (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?
Hmm. How do I test if I am currently in the original or commuted version
of the simplification? I could add a "with" block that defines truecmp as
either cmp or invert_tree_comparison (cmp) and test that. Otherwise, I
would need a test before each "return" as swapped versions don't return
the same thing. It might make a slight difference on the handling of
flag_trapping_math, but that handling already seems strange to me...
> The fold-const.c code doesn't seem to handle as many variants (esp.
> the swapping?),
The fold-const.c function is called twice, once on regular operands, once
with inverted comparison and swapped operands. I really don't think I am
handling more cases (except maybe the silly a?a:0 is extended to
unsigned).
> so maybe you can add a testcase that exercises some of the above on GIMPLE?
So mostly the VEC_COND_EXPR version? We don't seem to have that much
COND_EXPR left in gimple.
--
Marc Glisse
next prev parent reply other threads:[~2015-06-28 18:34 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
2015-06-28 19:43 ` Marc Glisse [this message]
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=alpine.DEB.2.11.1505261318470.15445@stedding.saclay.inria.fr \
--to=marc.glisse@inria.fr \
--cc=bilbotheelffriend@gmail.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).