public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, Li Jia He <helijia@linux.ibm.com>,
	Andrew Pinski <pinskia@gmail.com>, Jeff Law <law@redhat.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	wschmidt@linux.ibm.com, Martin Liska <mliska@suse.de>
Subject: Re: [PATCH 3/5] Rewrite part of and_comparisons_1 into match.pd.
Date: Wed, 11 Sep 2019 13:19:00 -0000	[thread overview]
Message-ID: <55116893-fd3b-1da4-ece2-952d97a49ce7@suse.cz> (raw)
In-Reply-To: <nycvar.YFH.7.76.1909111428060.5566@zhemvz.fhfr.qr>

On 9/11/19 2:43 PM, Richard Biener wrote:
> On Wed, 11 Sep 2019, Martin Liška wrote:
> 
>> I'm sending updated version of the patch where I changed
>> from previous version:
>> - more compact matching is used (note @3 and @4):
>>   (and (code1:c@3 @0 INTEGER_CST@1) (code2:c@4 @0 INTEGER_CST@2))
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed?
> 
> --- a/gcc/genmatch.c
> +++ b/gcc/genmatch.c
> @@ -1894,9 +1894,11 @@ dt_node *
>  dt_node::append_simplify (simplify *s, unsigned pattern_no,
>                           dt_operand **indexes)
>  {
> +  dt_simplify *s2;
>    dt_simplify *n = new dt_simplify (s, pattern_no, indexes);
>    for (unsigned i = 0; i < kids.length (); ++i)
> -    if (dt_simplify *s2 = dyn_cast <dt_simplify *> (kids[i]))
> +    if ((s2 = dyn_cast <dt_simplify *> (kids[i]))
> +       && s->match->location != s2->s->match->location)
>        {
> 
> can you retain the warning for verbose >= 1 please?  And put in
> a comment that duplicates are sometimes hard to avoid with
> nested for so this keeps match.pd sources small.

Sure.

> 
> +  /* Function maybe_fold_comparisons_from_match_pd creates temporary
> +     SSA_NAMEs.  */
> +  if (TREE_CODE (op1) == SSA_NAME && TREE_CODE (op2) == SSA_NAME)
> +    {
> +      gimple *s = SSA_NAME_DEF_STMT (op2);
> +      if (is_gimple_assign (s))
> +       return same_bool_comparison_p (op1, gimple_assign_rhs_code (s),
> +                                      gimple_assign_rhs1 (s),
> +                                      gimple_assign_rhs2 (s));
> +      else
> +       return false;
> +    }
> 
> when do you actually run into the need to add this?  The whole
> same_bool_result_p/same_bool_comparison_p helpers look a bit
> odd to me.  It shouldn't be special to the new temporaries
> either so at least the comment looks out-of place.

At some point it was needed to handle gcc/testsuite/gcc.dg/pr46909.c
test-case. Apparently, now the test-case is fine with the hunk. I will it
removal of the hunk.

> 
> +      else if (op.code.is_tree_code ()
> +              && TREE_CODE_CLASS ((tree_code)op.code) == tcc_comparison)
> +       {
> 
> COMPARISON_CLASS_P ((tree_code)op.code)
> 
> as was noted.

Won't work here:

/home/marxin/Programming/gcc/gcc/gimple-fold.c: In function ‘tree_node* maybe_fold_comparisons_from_match_pd(tree, tree_code, tree_code, tree, tree, tree_code, tree, tree)’:
/home/marxin/Programming/gcc/gcc/tree.h:239:49: error: base operand of ‘->’ is not a pointer
  239 | #define TREE_CODE(NODE) ((enum tree_code) (NODE)->base.code)
      |                                                 ^~

> 
> Any particular reason you needed to swap the calls in
> maybe_fold_and/or_comparisons?
> 
> +(for code1 (eq ne)
> + (for code2 (eq ne lt gt le ge)
> +  (for and (truth_and bit_and)
> +   (simplify
> 
> You could save some code-bloat with writing
> 
>   (for and (
> #if GENERIC
>   truth_and
> #endif
>   bit_and)
> 
> but since you are moving the patterns from GIMPLE code I'd say
> simply remove truth_and and that innermost for?

I'm gonna drop the generic tree codes support.

Martin

> 
> Otherwise OK.
> 
> Thanks,
> Richard.
> 
> 
> 
> 
>> Thanks,
>> Martin
>>
> 

  reply	other threads:[~2019-09-11 13:19 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-27  6:12 [PATCH][middle-end/88784] Middle end is missing some optimizations about unsigned Li Jia He
2019-06-27 15:48 ` Jeff Law
2019-06-28  4:55   ` Li Jia He
2019-06-28 17:02     ` Andrew Pinski
2019-07-01  7:31       ` Richard Biener
2019-07-02  7:41         ` Li Jia He
2019-07-02  8:09           ` Richard Biener
2019-07-02  8:51             ` Richard Biener
2019-07-16  6:54               ` Li Jia He
2019-08-30 11:16                 ` Martin Liška
2019-09-05 13:01                 ` Richard Biener
2019-09-05 18:47                   ` Martin Liška
2019-09-06  8:01                     ` Richard Biener
2019-09-06  8:04                       ` Martin Liška
2019-09-06 10:13                   ` [PATCH 1/2] Auto-generate maybe_fold_and/or_comparisons from match.pd Martin Liška
2019-09-09 12:23                     ` Martin Liška
2019-09-09 13:10                       ` Marc Glisse
2019-09-09 13:30                         ` Martin Liška
2019-09-09 13:39                           ` Richard Biener
2019-09-09 13:10                       ` Richard Biener
2019-09-09 13:40                         ` Martin Liška
2019-09-09 13:42                           ` Richard Biener
2019-09-09 13:45                             ` Martin Liška
2019-09-09 13:55                               ` Richard Biener
2019-09-10  7:40                                 ` Martin Liška
     [not found]                                   ` <ba4ec7b3-0d0d-ca7b-b2d9-2f34478a23f4@linux.ibm.com>
2019-09-11  8:51                                     ` Martin Liška
2019-09-11 11:16                                   ` Martin Liška
2019-09-11 12:23                                     ` Richard Biener
2019-09-11 13:55                                       ` Martin Liška
2019-09-09 12:24                     ` [PATCH 4/5] Rewrite first part of or_comparisons_1 into match.pd Martin Liška
2019-09-11 11:19                       ` Martin Liška
2019-09-11 13:57                         ` Martin Liška
2019-09-16  9:05                           ` Richard Biener
2019-09-09 12:24                     ` [PATCH 3/5] Rewrite part of and_comparisons_1 " Martin Liška
2019-09-09 13:41                       ` Martin Liška
2019-09-10  7:41                         ` Martin Liška
2019-09-10 11:19                           ` Marc Glisse
2019-09-11  8:27                             ` Martin Liška
2019-09-11 11:18                               ` Martin Liška
2019-09-11 12:44                                 ` Richard Biener
2019-09-11 13:19                                   ` Martin Liška [this message]
2019-09-11 13:57                                     ` Martin Liška
2019-09-16  9:04                                       ` Richard Biener
2019-09-16 13:47                                         ` Martin Liška
2019-09-10  8:52                         ` Bernhard Reutner-Fischer
2019-09-11  8:11                           ` Martin Liška
2019-09-09 12:25                     ` [PATCH 5/5] Rewrite second part of or_comparisons_1 " Martin Liška
2019-09-11 11:19                       ` Martin Liška
2019-09-11 13:57                         ` Martin Liška
2019-09-16  9:07                           ` Richard Biener
2019-09-16 14:23                             ` Martin Liška
2019-09-05 13:17                 ` [PATCH][middle-end/88784] Middle end is missing some optimizations about unsigned Richard Biener
2019-09-05 18:47                   ` Martin Liška
2019-09-06 10:14                   ` [PATCH 2/2] Fix PR88784, middle " Martin Liška
2019-09-11 13:08                     ` Richard Biener
2019-09-11 13:56                       ` Martin Liška

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=55116893-fd3b-1da4-ece2-952d97a49ce7@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=helijia@linux.ibm.com \
    --cc=law@redhat.com \
    --cc=mliska@suse.de \
    --cc=pinskia@gmail.com \
    --cc=rguenther@suse.de \
    --cc=segher@kernel.crashing.org \
    --cc=wschmidt@linux.ibm.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).