From: Jakub Jelinek <jakub@redhat.com>
To: Andrew Stubbs <ams@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] openmp-simd-clone: Match shift type
Date: Fri, 29 Jul 2022 17:59:58 +0200 [thread overview]
Message-ID: <YuQD/ia4NBeHLzcm@tucnak> (raw)
In-Reply-To: <02ee1acd-1951-8cf9-345b-ca230ae432bb@codesourcery.com>
On Fri, Jul 29, 2022 at 04:53:51PM +0100, Andrew Stubbs wrote:
> This patch adjusts the generation of SIMD "inbranch" clones that use integer
> masks to ensure that it vectorizes on amdgcn.
>
> The problem was only that an amdgcn mask is DImode and the shift amount was
> SImode, and the difference causes vectorization to fail.
>
> OK for mainline?
>
> Andrew
> openmp-simd-clone: Match shift types
>
> Ensure that both parameters to vector shifts use the same mode. This is most
> important for amdgcn where the masks are DImode.
>
> gcc/ChangeLog:
>
> * omp-simd-clone.cc (simd_clone_adjust): Convert shift_cnt to match
> the mask type.
>
> diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
> index 32649bc3f9a..5d3a90730e7 100644
> --- a/gcc/omp-simd-clone.cc
> +++ b/gcc/omp-simd-clone.cc
> @@ -1305,8 +1305,12 @@ simd_clone_adjust (struct cgraph_node *node)
> build_int_cst (TREE_TYPE (iter1), c));
> gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
> }
> + tree shift_cnt_conv = make_ssa_name (TREE_TYPE (mask));
> + g = gimple_build_assign (shift_cnt_conv,
> + fold_convert (TREE_TYPE (mask), shift_cnt));
> + gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
Doing the fold_convert seems to be a wasted effort to me.
Can't this be done conditional on whether some change is needed at all
and just using gimple_build_assign with NOP_EXPR, so something like:
tree shift_cvt_conv = shift_cnt;
if (!useless_type_conversion_p (TREE_TYPE (mask),
TREE_TYPE (shift_cnt)))
{
shift_cnt_conv = make_ssa_name (TREE_TYPE (mask));
g = gimple_build_assign (shift_cnt_conv, NOP_EXPR, shift_cnt);
gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
}
> g = gimple_build_assign (make_ssa_name (TREE_TYPE (mask)),
> - RSHIFT_EXPR, mask, shift_cnt);
> + RSHIFT_EXPR, mask, shift_cnt_conv);
> gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
> mask = gimple_assign_lhs (g);
> g = gimple_build_assign (make_ssa_name (TREE_TYPE (mask)),
?
Jakub
next prev parent reply other threads:[~2022-07-29 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 15:53 Andrew Stubbs
2022-07-29 15:59 ` Jakub Jelinek [this message]
2022-07-29 17:03 ` Andrew Stubbs
2022-07-29 20:09 ` Jakub Jelinek
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=YuQD/ia4NBeHLzcm@tucnak \
--to=jakub@redhat.com \
--cc=ams@codesourcery.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).