public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/103554] New: -mavx generates worse code on scalar code
@ 2021-12-04 15:37 avi at scylladb dot com
  2021-12-04 22:08 ` [Bug target/103554] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: avi at scylladb dot com @ 2021-12-04 15:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103554
           Summary: -mavx generates worse code on scalar code
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avi at scylladb dot com
  Target Milestone: ---

Test case:

struct s1 {
    long a, b, c, d, e, f, g, h;
};

s1 move(s1 in) {
    s1 ret;

    ret.a = in.d;
    ret.b = in.e;
    ret.c = in.a;
    ret.d = in.b;
    return ret;
}


-O3 generates:

move(s1):
  movq 8(%rsp), %xmm0
  movq 32(%rsp), %xmm1
  movq %rdi, %rax
  movhps 16(%rsp), %xmm0
  movhps 40(%rsp), %xmm1
  movups %xmm1, (%rdi)
  movups %xmm0, 16(%rdi)
  ret


-O3 -mavx generates:

move(s1):
        pushq   %rbp
        movq    %rdi, %rax
        movq    %rsp, %rbp
        vmovq   16(%rbp), %xmm2
        vmovq   40(%rbp), %xmm3
        vpinsrq $1, 24(%rbp), %xmm2, %xmm1
        vpinsrq $1, 48(%rbp), %xmm3, %xmm0
        vinsertf128     $0x1, %xmm1, %ymm0, %ymm0
        vmovdqu %ymm0, (%rdi)
        vzeroupper
        popq    %rbp
        ret

Clang -O3 generates this simple code, with or without -mavx (-mavx does use VEX
instructions):

move(s1): # @move(s1)
  movq %rdi, %rax
  movups 32(%rsp), %xmm0
  movups %xmm0, (%rdi)
  movaps 8(%rsp), %xmm0
  movups %xmm0, 16(%rdi)
  retq

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

end of thread, other threads:[~2021-12-09  3:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-04 15:37 [Bug target/103554] New: -mavx generates worse code on scalar code avi at scylladb dot com
2021-12-04 22:08 ` [Bug target/103554] " pinskia at gcc dot gnu.org
2021-12-06  8:36 ` rguenth at gcc dot gnu.org
2021-12-06  9:00 ` avi at scylladb dot com
2021-12-06 11:00 ` rguenther at suse dot de
2021-12-06 11:23 ` avi at scylladb dot com
2021-12-06 11:52 ` rguenther at suse dot de
2021-12-06 11:59 ` avi at scylladb dot com
2021-12-07  2:26 ` crazylht at gmail dot com
2021-12-07  8:36 ` rguenth at gcc dot gnu.org
2021-12-07  9:51 ` crazylht at gmail dot com
2021-12-07 10:28 ` rguenther at suse dot de
2021-12-09  3:07 ` 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).