public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Jeff Law <jeffreyalaw@gmail.com>
Cc: Andrew Pinski <apinski@marvell.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] tree-optimization: [PR101540] Simplify CONSTRUCTOR for vector(1) to be VCE
Date: Sun, 28 Nov 2021 16:56:45 -0800	[thread overview]
Message-ID: <CA+=Sn1=RJvuWhsuj08yQ8VgLrXUbWikwz82nyjsqhgaBdVg5HA@mail.gmail.com> (raw)
In-Reply-To: <1262fd0b-e68f-71f6-5365-05fafe4f289c@gmail.com>

On Sun, Nov 28, 2021 at 12:25 PM Jeff Law via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
>
> On 11/28/2021 10:56 AM, apinski--- via Gcc-patches wrote:
> > From: Andrew Pinski <apinski@marvell.com>
> >
> > This just adds a simplification to simplify_vector_constructor for
> > vector of 1 element to be VCE which should reduce memory usage in
> > the compiler and maybe allow for some more optimizations.
> >
> > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
> >
> >       PR tree-optimization/101540
> >
> > gcc/ChangeLog:
> >
> >       * tree-ssa-forwprop.c (simplify_vector_constructor):
> >       Simplify constructor of vector of 1 element to just
> >       be a VIEW_CONVERT_EXPR.
> >
> > gcc/testsuite/ChangeLog:
> >
> >       * gcc.dg/tree-ssa/pr101540-1.c: New test.
> So why generate a VCE here if the type conversion is useless?  Why not
> just a NOP_EXPR?  Is there something special about converting between
> the element type and the outer vector type that requires VCE rather than
> NOP_EXR?  Neither an ACK or NAK, just trying to understand it a bit better.


Because right now tree-cfg.c has this check for vector types for NOP_EXPR:
        /* Allow conversions between vectors with the same number of elements,
           provided that the conversion is OK for the element types too.  */
        if (VECTOR_TYPE_P (lhs_type)
            && VECTOR_TYPE_P (rhs1_type)
            && known_eq (TYPE_VECTOR_SUBPARTS (lhs_type),
                         TYPE_VECTOR_SUBPARTS (rhs1_type)))
          {
            lhs_type = TREE_TYPE (lhs_type);
            rhs1_type = TREE_TYPE (rhs1_type);
          }
        else if (VECTOR_TYPE_P (lhs_type) || VECTOR_TYPE_P (rhs1_type))
          {
            error ("invalid vector types in nop conversion");
            debug_generic_expr (lhs_type);
            debug_generic_expr (rhs1_type);
            return true;
          }

We can change this check here for NOP_EXPR and vector types but VCE is
still a nop in most cases and handled as such really. But I wonder if
the rest of the compiler is ready for it though.

Thanks,
Andrew Pinski

>
> Jeff
>
>

  reply	other threads:[~2021-11-29  0:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28 17:56 apinski
2021-11-28 20:25 ` Jeff Law
2021-11-29  0:56   ` Andrew Pinski [this message]
2021-11-29  8:59     ` 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='CA+=Sn1=RJvuWhsuj08yQ8VgLrXUbWikwz82nyjsqhgaBdVg5HA@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=apinski@marvell.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.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).