public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Joel Hutton <Joel.Hutton@arm.com>
Cc: Richard Sandiford <Richard.Sandiford@arm.com>,
	 "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 Andre Simoes Dias Vieira <Andre.SimoesDiasVieira@arm.com>
Subject: RE: [ping][vect-patterns] Refactor widen_plus/widen_minus as internal_fns
Date: Tue, 12 Jul 2022 12:32:06 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2207121045100.14950@jbgna.fhfr.qr> (raw)
In-Reply-To: <DB9PR08MB6603D656FD05B9D562033809F5BA9@DB9PR08MB6603.eurprd08.prod.outlook.com>

On Thu, 30 Jun 2022, Joel Hutton wrote:

> > We can go with a private vect_gimple_build function until we sort out the API
> > issue to unblock Tamar (I'll reply to Richards reply with further thoughts on
> > this)
> > 
> 
> Done.
> 
> > > Similarly are you ok with the use of gimple_extract_op? I would lean
> > towards using it as it is cleaner, but I don't have strong feelings.
> > 
> > I don't like using gimple_extract_op here, I think I outlined a variant that is
> > even shorter.
> > 
> 
> Done.
> 
> Updated patches attached, bootstrapped and regression tested on aarch64.
> 
> Tomorrow is my last working day at Arm, so it will likely be Andre that commits this/addresses any further comments.

First sorry for the (repeated) delays.

In the first patch I still see ECF_WIDEN, I don't like that, we
use things like associative_binary_fn_p so for widening internal
functions similar predicates should be used.

In the second patch you add vec_widen_{add,sub} optabs

+OPTAB_CD(vec_widen_add_optab, "add$a$b3")
+OPTAB_CD(vec_widen_sub_optab, "sub$a$b3")

but a) the names are that of regular adds which is at least confusing
(if not wrong), b) there's no documentation for them in md.texi which,
c) doesn't explain why they are necessary when we have 
vec_widen_[su]{add,sub}l_optab

+      internal_fn ifn = as_internal_fn (code.safe_as_fn_code ());

asks for safe_as_internal_fn () (just complete the API, also with
safe_as_builtin_fn)

+      internal_fn lo, hi;
+      lookup_multi_internal_fn (ifn, &lo, &hi);
+      *code1 = as_combined_fn (lo);
+      *code2 = as_combined_fn (hi);

in fact this probably shows that the guarding condition should
be if (code.is_internal_fn ()) instead of if (code.is_fn_code ()).

+      optab1 = lookup_multi_ifn_optab (lo, !TYPE_UNSIGNED (vectype));
+      optab2 = lookup_multi_ifn_optab (hi, !TYPE_UNSIGNED (vectype));

this shows the two lookup_ APIs are inconsistent in having two vs. one
output, please make them consistent.  I'd say give
lookup_multi_internal_fn a enum { LO, HI } argument, returning the
result.  Given VEC_WIDEN_MULT has HI, LO, EVEN and ODD variants
that sounds more future proof.

The internal_fn stuff could probably get a 2nd eye from Richard.

In the third patch I see unrelated and wrong changes like

          /* Check that the DR_INITs are compile-time constants.  */
-         if (!tree_fits_shwi_p (DR_INIT (dra))
-             || !tree_fits_shwi_p (DR_INIT (drb)))
+         if (TREE_CODE (DR_INIT (dra)) != INTEGER_CST
+             || TREE_CODE (DR_INIT (drb)) != INTEGER_CST)
            break;

please strip the patch down to relevant changes.

-      tree op = gimple_op (assign, i + 1);
+      tree op;
+      if (is_gimple_assign (stmt))
+       op = gimple_op (stmt, i + 1);
+      else
+       op = gimple_call_arg (stmt, i);

somebody added gimple_arg which can be used here doing

       op = gimple_arg (stmt, i);

+  tree lhs = is_gimple_assign (stmt) ? gimple_assign_lhs (stmt):
+                                     gimple_call_lhs (stmt);

  tree lhs = gimple_get_lhs (stmt);

   /* Check for an integer operation with the right code.  */
-  gassign *assign = dyn_cast <gassign *> (stmt_info->stmt);
-  if (!assign)
+  gimple* stmt = stmt_info->stmt;
+  if (!(is_gimple_assign (stmt) || is_gimple_call (stmt)))
     return 0;

-  tree_code rhs_code = gimple_assign_rhs_code (assign);
-  if (rhs_code != code && rhs_code != widened_code)
+  code_helper rhs_code;
+  if (is_gimple_assign (stmt))
+    rhs_code = gimple_assign_rhs_code (stmt);
+  else
+    rhs_code = gimple_call_combined_fn (stmt);
+
+  if (rhs_code.safe_as_tree_code () != code
+      && rhs_code.get_rep () != widened_code.get_rep ())
     return 0;

that's probably better refactored as

 if (is_gimple_assign (stmt))
   {
     if (code check)
       return 0;
   }
 else if (is_gimple_call (..))
  {
  ..
  }
 else
   return 0;

otherwise the last patch looks reasonable.

Richard.

  reply	other threads:[~2022-07-12 12:32 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25  9:11 Joel Hutton
2022-05-27 13:23 ` Richard Biener
2022-05-31 10:07   ` Joel Hutton
2022-05-31 16:46     ` Tamar Christina
2022-06-01 10:11     ` Richard Biener
2022-06-06 17:20       ` Joel Hutton
2022-06-07  8:18         ` Richard Sandiford
2022-06-07  9:01           ` Joel Hutton
2022-06-09 14:03             ` Joel Hutton
2022-06-13  9:02             ` Richard Biener
2022-06-30 13:20               ` Joel Hutton
2022-07-12 12:32                 ` Richard Biener [this message]
2023-03-17 10:14                   ` Andre Vieira (lists)
2023-03-17 11:52                     ` Richard Biener
2023-04-20 13:23                       ` Andre Vieira (lists)
2023-04-24 11:57                         ` Richard Biener
2023-04-24 13:01                           ` Richard Sandiford
2023-04-25 12:30                             ` Richard Biener
2023-04-28 16:06                               ` Andre Vieira (lists)
2023-04-25  9:55                           ` Andre Vieira (lists)
2023-04-28 12:36                             ` [PATCH 1/3] Refactor to allow internal_fn's Andre Vieira (lists)
2023-05-03 11:55                               ` Richard Biener
2023-05-04 15:20                                 ` Andre Vieira (lists)
2023-05-05  6:09                                   ` Richard Biener
2023-05-12 12:14                                     ` Andre Vieira (lists)
2023-05-12 13:18                                       ` Richard Biener
2023-04-28 12:37                             ` [PATCH 2/3] Refactor widen_plus as internal_fn Andre Vieira (lists)
2023-05-03 12:11                               ` Richard Biener
2023-05-03 19:07                                 ` Richard Sandiford
2023-05-12 12:16                                   ` Andre Vieira (lists)
2023-05-12 13:28                                     ` Richard Biener
2023-05-12 13:55                                       ` Andre Vieira (lists)
2023-05-12 14:01                                       ` Richard Sandiford
2023-05-15 10:20                                         ` Richard Biener
2023-05-15 10:47                                           ` Richard Sandiford
2023-05-15 11:01                                             ` Richard Biener
2023-05-15 11:10                                               ` Richard Sandiford
2023-05-15 11:53                                               ` Andre Vieira (lists)
2023-05-15 12:21                                                 ` Richard Biener
2023-05-18 17:15                                                   ` Andre Vieira (lists)
2023-05-22 13:06                                                     ` Richard Biener
2023-06-01 16:27                                                       ` Andre Vieira (lists)
2023-06-02 12:00                                                         ` Richard Sandiford
2023-06-06 19:00                                                         ` Jakub Jelinek
2023-06-06 21:28                                                           ` [PATCH] modula2: Fix bootstrap Jakub Jelinek
2023-06-06 22:18                                                             ` Gaius Mulley
2023-06-07  8:42                                                             ` Andre Vieira (lists)
2023-06-13 14:48                                                               ` Jakub Jelinek
2023-04-28 12:37                             ` [PATCH 3/3] Remove widen_plus/minus_expr tree codes Andre Vieira (lists)
2023-05-03 12:29                               ` Richard Biener
2023-05-10  9:15                                 ` Andre Vieira (lists)
2023-05-12 12:18                                   ` Andre Vieira (lists)
2022-06-13  9:18           ` [ping][vect-patterns] Refactor widen_plus/widen_minus as internal_fns Richard Biener
  -- strict thread matches above, loose matches on Subject: below --
2021-11-25 10:08 Joel Hutton

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=nycvar.YFH.7.77.849.2207121045100.14950@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=Andre.SimoesDiasVieira@arm.com \
    --cc=Joel.Hutton@arm.com \
    --cc=Richard.Sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).