public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: "Andre Vieira (lists)" <andre.simoesdiasvieira@arm.com>
Cc: Richard Biener <rguenther@suse.de>,
	Richard Sandiford <Richard.Sandiford@arm.com>,
	 "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [ping][vect-patterns] Refactor widen_plus/widen_minus as internal_fns
Date: Mon, 24 Apr 2023 13:57:33 +0200	[thread overview]
Message-ID: <CAFiYyc3ULC=1P7Mr8m9ObJhpywSC0q6vb_GtqHeQr-h-UvB_nQ@mail.gmail.com> (raw)
In-Reply-To: <ff69685d-059b-15a6-c2fe-80d9f09c87e3@arm.com>

On Thu, Apr 20, 2023 at 3:24 PM Andre Vieira (lists) via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Rebased all three patches and made some small changes to the second one:
> - removed sub and abd optabs from commutative_optab_p, I suspect this
> was a copy paste mistake,
> - removed what I believe to be a superfluous switch case in vectorizable
> conversion, the one that was here:
> +  if (code.is_fn_code ())
> +     {
> +      internal_fn ifn = as_internal_fn (code.as_fn_code ());
> +      int ecf_flags = internal_fn_flags (ifn);
> +      gcc_assert (ecf_flags & ECF_MULTI);
> +
> +      switch (code.as_fn_code ())
> +       {
> +       case CFN_VEC_WIDEN_PLUS:
> +         break;
> +       case CFN_VEC_WIDEN_MINUS:
> +         break;
> +       case CFN_LAST:
> +       default:
> +         return false;
> +       }
> +
> +      internal_fn lo, hi;
> +      lookup_multi_internal_fn (ifn, &lo, &hi);
> +      *code1 = as_combined_fn (lo);
> +      *code2 = as_combined_fn (hi);
> +      optab1 = lookup_multi_ifn_optab (lo, !TYPE_UNSIGNED (vectype));
> +      optab2 = lookup_multi_ifn_optab (hi, !TYPE_UNSIGNED (vectype));
>       }
>
> I don't think we need to check they are a specfic fn code, as we look-up
> optabs and if they succeed then surely we can vectorize?
>
> OK for trunk?

In the first patch I see some uses of safe_as_tree_code like

+  if (ch.is_tree_code ())
+    return op1 == NULL_TREE ? gimple_build_assign (lhs,
ch.safe_as_tree_code (),
+                                                  op0) :
+                             gimple_build_assign (lhs, ch.safe_as_tree_code (),
+                                                  op0, op1);
+  else
+  {
+    internal_fn fn = as_internal_fn (ch.safe_as_fn_code ());
+    gimple* stmt;

where the context actually requires a valid tree code.  Please change those
to force to tree code / ifn code.  Just use explicit casts here and the other
places that are similar.  Before the as_internal_fn just put a
gcc_assert (ch.is_internal_fn ()).

Maybe the need for the (ugly) safe_as_tree_code/fn_code goes away then.

Otherwise patch1 looks OK.

Unfortunately there are no ChangeLog / patch descriptions on the changes.
patch2 has

-  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);
+      if (rhs_code.safe_as_tree_code () != code
+         && rhs_code.get_rep () != widened_code.get_rep ())
+       return 0;
+    }
+  else if (is_gimple_call (stmt))
+    {
+      rhs_code = gimple_call_combined_fn (stmt);
+      if (rhs_code.get_rep () != widened_code.get_rep ())
+       return 0;
+    }

that looks mightly complicated - esp. the use of get_rep ()
looks dangerous?  What's the intent of this?  Not that I
understand the existing code much.  A comment would
clearly help (also indicating test coverage).



> Kind regards,
> Andre

  reply	other threads:[~2023-04-24 11:59 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
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 [this message]
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='CAFiYyc3ULC=1P7Mr8m9ObJhpywSC0q6vb_GtqHeQr-h-UvB_nQ@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=Richard.Sandiford@arm.com \
    --cc=andre.simoesdiasvieira@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /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).