public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13
@ 2024-02-27 16:02 pilarlatiesa at gmail dot com
  2024-02-28  3:55 ` [Bug target/114134] [14 Regression] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: pilarlatiesa at gmail dot com @ 2024-02-27 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114134
           Summary: Extra mov instructions for simple function compared
                    with GCC13
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pilarlatiesa at gmail dot com
  Target Milestone: ---

In the example below, the function `Key` has some extra (useless?) mov
instructions that are not generated with GCC 13.

$ cat borrar.cpp 

#include <cmath>

struct TVec3D { double x, y, z; };

struct TKey { int i, j, k; };

extern double const BinSize;

inline int Index(double const x)
  { return static_cast<int>(std::floor(static_cast<float>(x / BinSize + 1.0) -
1.0f)); };

TKey Key(TVec3D const &r)
  { return {Index(r.x), Index(r.y), Index(r.z)}; }


$ ./gcc-13/bin/g++ -O3 -march=skylake -fno-trapping-math -S borrar.cpp -o-
        .file   "borrar.cpp"
        .text
        .p2align 4
        .globl  _Z3KeyRK6TVec3D
        .type   _Z3KeyRK6TVec3D, @function
_Z3KeyRK6TVec3D:
.LFB993:
        .cfi_startproc
        vmovsd  BinSize(%rip), %xmm1
        vmovupd (%rdi), %xmm3
        vmovddup        .LC1(%rip), %xmm2
        vmovddup        %xmm1, %xmm0
        vdivpd  %xmm0, %xmm3, %xmm0
        vaddpd  %xmm2, %xmm0, %xmm0
        vmovq   .LC2(%rip), %xmm2
        vcvtpd2psx      %xmm0, %xmm0
        vaddps  %xmm2, %xmm0, %xmm0
        vroundps        $9, %xmm0, %xmm0
        vcvttps2dq      %xmm0, %xmm4
        vmovsd  16(%rdi), %xmm0
        vmovq   %xmm4, %rax
        vdivsd  %xmm1, %xmm0, %xmm0
        vaddsd  .LC1(%rip), %xmm0, %xmm0
        vcvtsd2ss       %xmm0, %xmm0, %xmm0
        vsubss  .LC3(%rip), %xmm0, %xmm0
        vroundss        $9, %xmm0, %xmm0, %xmm0
        vcvttss2sil     %xmm0, %edx
        movl    %edx, %edx
        ret
        .cfi_endproc
.LFE993:
        .size   _Z3KeyRK6TVec3D, .-_Z3KeyRK6TVec3D
        .section        .rodata.cst8,"aM",@progbits,8
        .align 8
.LC1:
        .long   0
        .long   1072693248
        .align 8
.LC2:
        .long   -1082130432
        .long   -1082130432
        .section        .rodata.cst4,"aM",@progbits,4
        .align 4
.LC3:
        .long   1065353216
        .ident  "GCC: (GNU) 13.1.0"
        .section        .note.GNU-stack,"",@progbits


$ ./gcc-14/bin/g++ -O3 -march=skylake -fno-trapping-math -S borrar.cpp -o-
        .file   "borrar.cpp"
        .text
        .p2align 4
        .globl  _Z3KeyRK6TVec3D
        .type   _Z3KeyRK6TVec3D, @function
_Z3KeyRK6TVec3D:
.LFB1032:
        .cfi_startproc
        vmovsd  BinSize(%rip), %xmm2
        vmovupd (%rdi), %xmm0
        vmovddup        %xmm2, %xmm1
        vdivpd  %xmm1, %xmm0, %xmm0
        vmovddup        .LC1(%rip), %xmm1
        vaddpd  %xmm1, %xmm0, %xmm0
        vmovq   .LC2(%rip), %xmm1
        vcvtpd2psx      %xmm0, %xmm0
        vaddps  %xmm1, %xmm0, %xmm0
        vroundps        $9, %xmm0, %xmm0
        vcvttps2dq      %xmm0, %xmm0
        vmovq   %xmm0, %rdx
        vmovsd  16(%rdi), %xmm0
        vdivsd  %xmm2, %xmm0, %xmm0
        vaddsd  .LC1(%rip), %xmm0, %xmm0
        vcvtsd2ss       %xmm0, %xmm0, %xmm0
        vsubss  .LC3(%rip), %xmm0, %xmm0
        vroundss        $9, %xmm0, %xmm0, %xmm0
        vcvttss2sil     %xmm0, %eax
        movl    %eax, %eax
        movq    %rax, %rdi
        movq    %rdx, %rax
        movq    %rdi, %rdx
        ret
        .cfi_endproc
.LFE1032:
        .size   _Z3KeyRK6TVec3D, .-_Z3KeyRK6TVec3D
        .section        .rodata.cst8,"aM",@progbits,8
        .align 8
.LC1:
        .long   0
        .long   1072693248
        .align 8
.LC2:
        .long   -1082130432
        .long   -1082130432
        .section        .rodata.cst4,"aM",@progbits,4
        .align 4
.LC3:
        .long   1065353216
        .ident  "GCC: (GNU) 14.0.0 20240112 (experimental)"
        .section        .note.GNU-stack,"",@progbits

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

end of thread, other threads:[~2024-05-07  7:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 16:02 [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13 pilarlatiesa at gmail dot com
2024-02-28  3:55 ` [Bug target/114134] [14 Regression] " pinskia at gcc dot gnu.org
2024-02-28  4:01 ` pinskia at gcc dot gnu.org
2024-02-28  8:05 ` rguenth at gcc dot gnu.org
2024-02-28  9:44 ` pilarlatiesa at gmail dot com
2024-02-28 11:42 ` [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13 since r14-2386 jakub at gcc dot gnu.org
2024-02-28 12:13 ` pilarlatiesa at gmail dot com
2024-03-07 20:38 ` law at gcc dot gnu.org
2024-05-07  7:45 ` [Bug target/114134] [14/15 " rguenth at gcc dot gnu.org

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