public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gabravier at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/102758] New: [x86] Failure to use registers optimally when swapping between (identically represented) vector types
Date: Fri, 15 Oct 2021 02:24:30 +0000	[thread overview]
Message-ID: <bug-102758-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102758

            Bug ID: 102758
           Summary: [x86] Failure to use registers optimally when swapping
                    between (identically represented) vector types
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

#include <stdint.h>

typedef int64_t v2i64 __attribute__((vector_size(16)));
typedef uint16_t v8u16 __attribute__((vector_size(16)));

v2i64 f(v8u16 make_b_xxm1, v2i64 b)
{
    return (v2i64)((v8u16)b + (v8u16){1});
}

With -O3, GCC outputs this:

f(unsigned short __vector(8), long __vector(2)):
        movdqa  xmm2, XMMWORD PTR .LC0[rip]
        paddw   xmm2, xmm1
        movdqa  xmm0, xmm2
        ret

LLVM outputs this:

f(unsigned short __vector(8), long __vector(2)):
        movdqa  xmm0, xmm1
        paddw   xmm0, xmmword ptr [rip + .LCPI0_0]
        ret

It should be possible to optimize out the last `movdqa`. This seems to be
directly related to the usage of differing types here (even though the
conversion is cost-free) as replacing all usage of `v2i64` with `v8u16` makes
this be better optimized.

             reply	other threads:[~2021-10-15  2:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  2:24 gabravier at gmail dot com [this message]
2021-10-15  2:30 ` [Bug target/102758] [12 Regression] Failure to use registers optimally with return values (2 operands related) pinskia at gcc dot gnu.org
2021-10-15  2:42 ` [Bug target/102758] [12 Regression] Failure to use registers optimally with return values (2 operands related and subreg) pinskia at gcc dot gnu.org
2021-10-15  6:28 ` rguenth at gcc dot gnu.org
2021-12-03 16:37 ` rsandifo at gcc dot gnu.org
2022-05-06  8:31 ` [Bug target/102758] [12/13 " jakub at gcc dot gnu.org
2022-10-19  9:40 ` rguenth at gcc dot gnu.org
2023-05-08 12:22 ` [Bug target/102758] [12/13/14 " rguenth at gcc dot gnu.org
2024-06-20  8:58 ` [Bug target/102758] [12/13/14/15 " rguenth at gcc dot gnu.org

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=bug-102758-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).