public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Robin Dapp <rdapp.gcc@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>,
	Richard Sandiford <richard.sandiford@arm.com>
Cc: rdapp.gcc@gmail.com, gcc-patches <gcc-patches@gcc.gnu.org>,
	Tamar Christina <Tamar.Christina@arm.com>
Subject: Re: [PATCH] vect: Use statement vectype for conditional mask.
Date: Fri, 17 Nov 2023 09:45:53 +0100	[thread overview]
Message-ID: <0424a09b-6867-4be9-8207-9d92a6187191@gmail.com> (raw)
In-Reply-To: <CAFiYyc3ei_OUTFt47peUbbjWPA35JZ52fSXWLT14_o_DTD+edQ@mail.gmail.com>

> But note you can explicitly specify a vector type as well, there's an
> overload for it, so we can fix the "invariant" case with the following
> (OK if you can test this on relevant targets)
> 
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 3f59139cb01..936a3de9534 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -8450,12 +8450,14 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
>       value. */
>    bool cond_fn_p = code.is_internal_fn ()
>      && conditional_internal_fn_code (internal_fn (code)) != ERROR_MARK;
> +  int cond_index = -1;
>    if (cond_fn_p)
>      {
>        gcc_assert (code == IFN_COND_ADD || code == IFN_COND_SUB
>                   || code == IFN_COND_MUL || code == IFN_COND_AND
>                   || code == IFN_COND_IOR || code == IFN_COND_XOR);
>        gcc_assert (op.num_ops == 4 && (op.ops[1] == op.ops[3]));
> +      cond_index = 0;
>      }
> 
>    bool masked_loop_p = LOOP_VINFO_FULLY_MASKED_P (loop_vinfo);
> @@ -8486,12 +8488,13 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
>    vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies,
>                      single_defuse_cycle && reduc_index == 0
>                      ? NULL_TREE : op.ops[0], &vec_oprnds0,
> +                    cond_index == 0 ? truth_type_for (vectype_in) : NULL_TREE,
>                      single_defuse_cycle && reduc_index == 1
> -                    ? NULL_TREE : op.ops[1], &vec_oprnds1,
> +                    ? NULL_TREE : op.ops[1], &vec_oprnds1, NULL_TREE,
>                      op.num_ops == 4
>                      || (op.num_ops == 3
>                          && !(single_defuse_cycle && reduc_index == 2))
> -                    ? op.ops[2] : NULL_TREE, &vec_oprnds2);
> +                    ? op.ops[2] : NULL_TREE, &vec_oprnds2, NULL_TREE);

Ah, yes that's what I meant.  I had something along those lines:

+  if (!cond_fn_p)
+    {
+      vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies,
+                        single_defuse_cycle && reduc_index == 0
+                        ? NULL_TREE : op.ops[0], &vec_oprnds0,
+                        single_defuse_cycle && reduc_index == 1
+                        ? NULL_TREE : op.ops[1], &vec_oprnds1,
+                        op.num_ops == 3
+                        && !(single_defuse_cycle && reduc_index == 2)
+                        ? op.ops[2] : NULL_TREE, &vec_oprnds2);
+    }
+  else
+    {
+      /* For a conditional operation, pass the truth type as vectype for the
+        mask.  */
+      gcc_assert (single_defuse_cycle && reduc_index == 1);
+      vect_get_vec_defs (loop_vinfo, stmt_info, slp_node, ncopies,
+                        op.ops[0], &vec_oprnds0,
+                        truth_type_for (vectype_in),
+                        NULL_TREE, &vec_oprnds1, NULL_TREE,
+                        op.ops[2], &vec_oprnds2, NULL_TREE);
+    }

Even though this has a bit of duplication now I prefer it slightly
because of the.  I'd hope, once fully tested (it's already running
but I'm having connection problems so don't know about the results
yet), this could go in independently of the pattern fix?

Regards
 Robin


  reply	other threads:[~2023-11-17  8:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08 16:18 Robin Dapp
2023-11-10  9:33 ` Richard Biener
2023-11-16 22:30   ` Robin Dapp
2023-11-17  8:24     ` Richard Biener
2023-11-17  8:45       ` Robin Dapp [this message]
2023-11-17  8:47         ` Richard Biener
2023-11-17 13:04           ` Robin Dapp
2023-12-03 18:32             ` [PATCH] testsuite: Fix up gcc.target/aarch64/pr112406.c for modern C [PR112406] Jakub Jelinek
2023-12-03 18:32               ` Jakub Jelinek
2023-12-03 18:59               ` Richard Biener
2023-11-17 19:20       ` [PATCH] vect: Use statement vectype for conditional mask Robin Dapp
2023-11-20  8:03         ` 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=0424a09b-6867-4be9-8207-9d92a6187191@gmail.com \
    --to=rdapp.gcc@gmail.com \
    --cc=Tamar.Christina@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=richard.sandiford@arm.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).