public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Roger Sayle <roger@nextmovesoftware.com>,
	Marc Glisse <marc.glisse@inria.fr>
Subject: Re: [PATCH] PR tree-optimization/101895: Fold VEC_PERM to help recognize FMA.
Date: Mon, 14 Mar 2022 08:37:48 +0100	[thread overview]
Message-ID: <CAFiYyc0mSN8QTk+S29RsuOHj_SPBcR3pE8aKS1Wpcc5+wf0MMw@mail.gmail.com> (raw)
In-Reply-To: <6ee61d3-ffac-7667-9dc0-692699e9e12f@hippo.saclay.inria.fr>

On Sun, Mar 13, 2022 at 12:39 AM Marc Glisse via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Fri, 11 Mar 2022, Roger Sayle wrote:
>
> +(match vec_same_elem_p
> +  CONSTRUCTOR@0
> +  (if (uniform_vector_p (TREE_CODE (@0) == SSA_NAME
> +                        ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0))))
>
> Ah, I didn't remember we needed that, we don't seem to be very consistent
> about it. Probably for this reason, the transformation "Prefer vector1 <<
> scalar to vector1 << vector2" does not match
>
> typedef int vec __attribute__((vector_size(16)));
> vec f(vec a, int b){
>    vec bb = { b, b, b, b };
>    return a << bb;
> }
>
> which is only optimized at vector lowering time.

Few more comments - since match.pd is matching in match.pd order the

(match vec_same_elem_p
  @0
  (...))

should come last.  Please use

+(match vec_same_elem_p
+  CONSTRUCTOR@0
    (if (TREE_CODE (@0) == SSA_NAME
         && uniform_vector_p (...

since otherwise we'll try uniform_vector_p twice on all CTORs (that
are not uniform).

> +/* Push VEC_PERM earlier if that may help FMA perception (PR101895).  */
> +(for plusminus (plus minus)
> +  (simplify
> +    (plusminus (vec_perm (mult@0 @1 vec_same_elem_p@2) @0 @3) @4)
> +    (plusminus (mult (vec_perm @1 @1 @3) @2) @4)))
>
> Don't you want :s on mult and vec_perm?

Yes.  Also for plus you want :c on it , likewise you want :c on the
mult.  The :c
on the plus will require splitting the plus and minus case :/

Otherwise looks reasonable.

Richard.

>
> --
> Marc Glisse

  reply	other threads:[~2022-03-14  7:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 23:48 Roger Sayle
2022-03-12 23:39 ` Marc Glisse
2022-03-14  7:37   ` Richard Biener [this message]
2022-03-15  7:25     ` Roger Sayle
2022-03-15  7:43       ` 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=CAFiYyc0mSN8QTk+S29RsuOHj_SPBcR3pE8aKS1Wpcc5+wf0MMw@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=marc.glisse@inria.fr \
    --cc=roger@nextmovesoftware.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).