public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pilarlatiesa at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13 Date: Tue, 27 Feb 2024 16:02:16 +0000 [thread overview] Message-ID: <bug-114134-4@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2024-02-27 16:02 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-27 16:02 pilarlatiesa at gmail dot com [this message] 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
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-114134-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: linkBe 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).