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
* [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13
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 ` pinskia at gcc dot gnu.org
2024-02-28 4:01 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-28 3:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
Summary|Extra mov instructions for |[14 Regression] Extra mov
|simple function compared |instructions for simple
|with GCC13 |function compared with
| |GCC13
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13
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
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-28 4:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-02-28
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks like the biggest issue is when expanding:
;; return D.26244;
Before:
(insn 34 33 35 (set (subreg:DI (reg:TI 107) 8)
(reg:DI 108)) "/app/example.cpp":14:47 discrim 1 -1
(nil))
(insn 35 34 36 (set (reg:TI 98 [ <retval> ])
(reg:TI 107)) "/app/example.cpp":14:47 discrim 1 -1
(nil))
After:
(insn 41 40 42 (set (reg:TI 130)
(ior:TI (and:TI (reg:TI 130)
(const_wide_int 0x0ffffffffffffffff))
(ashift:TI (zero_extend:TI (reg:DI 131))
(const_int 64 [0x40])))) "/app/example.cpp":14:47 discrim 1 -1
(nil))
(insn 42 41 43 (set (reg:TI 114 [ <retval> ])
(reg:TI 130)) "/app/example.cpp":14:47 discrim 1 -1
(nil))
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13
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
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-28 8:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sayle at gcc dot gnu.org
Target|X86_64 |x86_64-*-*
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I guess the testcase can be simplified to just show the return value handling
issue.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13
2024-02-27 16:02 [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13 pilarlatiesa at gmail dot com
` (2 preceding siblings ...)
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
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pilarlatiesa at gmail dot com @ 2024-02-28 9:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
--- Comment #3 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
(In reply to Richard Biener from comment #2)
> I guess the testcase can be simplified to just show the return value
> handling issue.
I think this suffices:
struct TVec3D { double x, y, z; };
struct TKey { int i, j, k; };
TKey Key(TVec3D const &r)
{ return {int(r.x), int(r.y), int(r.z)}; }
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13 since r14-2386
2024-02-27 16:02 [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13 pilarlatiesa at gmail dot com
` (3 preceding siblings ...)
2024-02-28 9:44 ` pilarlatiesa at gmail dot com
@ 2024-02-28 11:42 ` jakub at gcc dot gnu.org
2024-02-28 12:13 ` pilarlatiesa at gmail dot com
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-28 11:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[14 Regression] Extra mov |[14 Regression] Extra mov
|instructions for simple |instructions for simple
|function compared with |function compared with
|GCC13 |GCC13 since r14-2386
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r14-2386-gbdf2737cda53a83332db1a1a021653447b05a7e7
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13 since r14-2386
2024-02-27 16:02 [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13 pilarlatiesa at gmail dot com
` (4 preceding siblings ...)
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
7 siblings, 0 replies; 9+ messages in thread
From: pilarlatiesa at gmail dot com @ 2024-02-28 12:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
--- Comment #5 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
Another testcase:
struct TKey { int i, j, k, w; };
TKey Key(int x)
{ return {x, 0, x, 0}; }
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/114134] [14 Regression] Extra mov instructions for simple function compared with GCC13 since r14-2386
2024-02-27 16:02 [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13 pilarlatiesa at gmail dot com
` (5 preceding siblings ...)
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
7 siblings, 0 replies; 9+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 20:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
CC| |law at gcc dot gnu.org
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug target/114134] [14/15 Regression] Extra mov instructions for simple function compared with GCC13 since r14-2386
2024-02-27 16:02 [Bug c++/114134] New: Extra mov instructions for simple function compared with GCC13 pilarlatiesa at gmail dot com
` (6 preceding siblings ...)
2024-03-07 20:38 ` law at gcc dot gnu.org
@ 2024-05-07 7:45 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07 7:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114134
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|14.0 |14.2
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.
^ 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).