public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/105033] New: Suboptimal for vec_concat lower halves of two vectors.
@ 2022-03-23  5:51 crazylht at gmail dot com
  2022-04-11  4:54 ` [Bug target/105033] " crazylht at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: crazylht at gmail dot com @ 2022-03-23  5:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105033
           Summary: Suboptimal for vec_concat lower halves of two vectors.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

typedef _Float16 v8hf __attribute__((vector_size (16)));
 typedef _Float16 v4hf __attribute__((vector_size (8)));

 v8hf foov (v4hf a, v4hf b)
 {
   return __builtin_shufflevector (a, b, 0, 1, 2, 3, 4, 5, 6, 7);
}

 typedef short v8hi __attribute__((vector_size (16)));
 typedef short v4hi __attribute__((vector_size (8)));

 v8hi foov (v4hi a, v4hi b)
 {
   return __builtin_shufflevector (a, b, 0, 1, 2, 3, 4, 5, 6, 7);
}

with -march=skylake-avx512 -O2

_Z4foovDv4_DF16_S_:
        vmovq   xmm2, xmm0
        vmovdqa xmm0, XMMWORD PTR .LC0[rip]
        vmovq   xmm1, xmm1
        vpermi2w        xmm0, xmm2, xmm1
        ret
foov(short __vector(4), short __vector(4)):
        vmovq   xmm2, xmm0
        vmovdqa xmm0, XMMWORD PTR .LC0[rip]
        vmovq   xmm1, xmm1
        vpermi2w        xmm0, xmm2, xmm1
        ret
.LC0:
        .value  0
        .value  1
        .value  2
        .value  3
        .value  8
        .value  9
        .value  10
        .value  11

But with -march=skylake -O2

It can be optimized to

_Z4foovDv4_DF16_S_:
        vmovq   xmm1, xmm1
        vmovq   xmm0, xmm0
        vpunpcklqdq     xmm0, xmm0, xmm1
        ret
foov(short __vector(4), short __vector(4)):
        vmovq   xmm1, xmm1
        vmovq   xmm0, xmm0
        vpunpcklqdq     xmm0, xmm0, xmm1
        ret

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/105033] Suboptimal for vec_concat lower halves of two vectors.
  2022-03-23  5:51 [Bug target/105033] New: Suboptimal for vec_concat lower halves of two vectors crazylht at gmail dot com
@ 2022-04-11  4:54 ` crazylht at gmail dot com
  2022-05-17  1:31 ` cvs-commit at gcc dot gnu.org
  2022-05-17  1:35 ` crazylht at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: crazylht at gmail dot com @ 2022-04-11  4:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
Created attachment 52776
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52776&action=edit
Patch pending for GCC13

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/105033] Suboptimal for vec_concat lower halves of two vectors.
  2022-03-23  5:51 [Bug target/105033] New: Suboptimal for vec_concat lower halves of two vectors crazylht at gmail dot com
  2022-04-11  4:54 ` [Bug target/105033] " crazylht at gmail dot com
@ 2022-05-17  1:31 ` cvs-commit at gcc dot gnu.org
  2022-05-17  1:35 ` crazylht at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-17  1:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:105c56a8cfde6015b989ab22c20c915c1b4e69ec

commit r13-518-g105c56a8cfde6015b989ab22c20c915c1b4e69ec
Author: liuhongt <hongtao.liu@intel.com>
Date:   Fri May 13 09:59:13 2022 +0800

    Optimize vpermtiw/b to vpunpcklqdq for certain cases.

    Assembly Optimization like:
    -       vmovq   %xmm0, %xmm2
    -       vmovdqa .LC0(%rip), %xmm0
            vmovq   %xmm1, %xmm1
    -       vpermi2w        %xmm1, %xmm2, %xmm0
    +       vmovq   %xmm0, %xmm0
    +       vpunpcklqdq     %xmm1, %xmm0, %xmm0

    ...

    -.LC0:
    -       .value  0
    -       .value  1
    -       .value  2
    -       .value  3
    -       .value  8
    -       .value  9
    -       .value  10
    -       .value  11

    gcc/ChangeLog:

            PR target/105033
            * config/i386/sse.md (*vec_concatv4si): Extend to ..
            (*vec_concat<mode>): .. V16QI and V8HImode.
            (*vec_concatv16qi_permt2): New pre_reload define_insn_and_split.
            (*vec_concatv8hi_permt2): Ditto.

    gcc/testsuite/ChangeLog:

            * gcc.target/i386/pr105033.c: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/105033] Suboptimal for vec_concat lower halves of two vectors.
  2022-03-23  5:51 [Bug target/105033] New: Suboptimal for vec_concat lower halves of two vectors crazylht at gmail dot com
  2022-04-11  4:54 ` [Bug target/105033] " crazylht at gmail dot com
  2022-05-17  1:31 ` cvs-commit at gcc dot gnu.org
@ 2022-05-17  1:35 ` crazylht at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: crazylht at gmail dot com @ 2022-05-17  1:35 UTC (permalink / raw)
  To: gcc-bugs

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

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
Fixed in GCC13.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-17  1:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23  5:51 [Bug target/105033] New: Suboptimal for vec_concat lower halves of two vectors crazylht at gmail dot com
2022-04-11  4:54 ` [Bug target/105033] " crazylht at gmail dot com
2022-05-17  1:31 ` cvs-commit at gcc dot gnu.org
2022-05-17  1:35 ` crazylht at gmail dot com

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).