public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111577] New: -Os gives significantly bigger code than -O0
@ 2023-09-25 0:33 socketpair at gmail dot com
2023-09-25 0:50 ` [Bug middle-end/111577] " pinskia at gcc dot gnu.org
2023-09-25 0:53 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: socketpair at gmail dot com @ 2023-09-25 0:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111577
Bug ID: 111577
Summary: -Os gives significantly bigger code than -O0
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: socketpair at gmail dot com
Target Milestone: ---
Yes, I saw #35806, #41175 and others.
See https://godbolt.org/z/Pnh89Y3Yb
```
#include <string>
using namespace std;
int main(int argc, char* argv[]) {
if (argv[0] == nullptr || argv[1] == nullptr) return 0;
string zxc(argv[0]);
string qwe(argv[1]);
string asd(argv[2]);
zxc = qwe + asd;
return zxc.size();
}
```
-Os -std=c++2b -march=skylake -m64 (615 bytes)
compare size with the smae, but with options:
-O0 -std=c++2b -march=skylake -m64 (409 bytes)
-O0 - is much LESS (!) in bytes. I think it's a bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/111577] -Os gives significantly bigger code than -O0
2023-09-25 0:33 [Bug c++/111577] New: -Os gives significantly bigger code than -O0 socketpair at gmail dot com
@ 2023-09-25 0:50 ` pinskia at gcc dot gnu.org
2023-09-25 0:53 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-25 0:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111577
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |WORKSFORME
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
[apinski@xeond2 gcc]$ ~/upstream-gcc/bin/g++ -Os -std=c++2b -march=skylake
-m64 t.cc
[apinski@xeond2 gcc]$ size -A a.out
a.out :
section size addr
.interp 28 4195096
.note.gnu.property 32 4195128
.note.ABI-tag 32 4195160
.hash 76 4195192
.gnu.hash 52 4195272
.dynsym 336 4195328
.dynstr 494 4195664
.gnu.version 28 4196158
.gnu.version_r 144 4196192
.rela.dyn 48 4196336
.rela.plt 192 4196384
.init 27 4198400
.plt 144 4198432
.text 1341 4198576
.fini 13 4199920
.rodata 99 4202496
.eh_frame_hdr 92 4202596
.eh_frame 440 4202688
.gcc_except_table 29 4203128
.init_array 8 4210128
.fini_array 8 4210136
.dynamic 528 4210144
.got 16 4210672
.got.plt 88 4210688
.data 16 4210776
.bss 8 4210792
.comment 108 0
.gnu.build.attributes 7368 4218992
Total 11795
[apinski@xeond2 gcc]$ ~/upstream-gcc/bin/g++ -O0 -std=c++2b -march=skylake
-m64 t.cc
[apinski@xeond2 gcc]$ size -A a.out
a.out :
section size addr
.interp 28 4195096
.note.gnu.property 32 4195128
.note.ABI-tag 32 4195160
.hash 368 4195192
.gnu.hash 356 4195560
.dynsym 1272 4195920
.dynstr 3067 4197192
.gnu.version 106 4200260
.gnu.version_r 176 4200368
.rela.dyn 48 4200544
.rela.plt 264 4200592
.init 27 4202496
.plt 192 4202528
.text 6162 4202720
.fini 13 4208884
.rodata 106 4210688
.eh_frame_hdr 548 4210796
.eh_frame 2276 4211344
.gcc_except_table 85 4213620
.init_array 8 4218320
.fini_array 8 4218328
.dynamic 528 4218336
.got 16 4218864
.got.plt 112 4218880
.data 16 4218992
.bss 8 4219008
.comment 108 0
.gnu.build.attributes 7368 4227208
Total 23330
For me on the trunk with the correct output -Os is smaller. 1341 vs 6162 for
the text size.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/111577] -Os gives significantly bigger code than -O0
2023-09-25 0:33 [Bug c++/111577] New: -Os gives significantly bigger code than -O0 socketpair at gmail dot com
2023-09-25 0:50 ` [Bug middle-end/111577] " pinskia at gcc dot gnu.org
@ 2023-09-25 0:53 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-25 0:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111577
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect you forgot to count the other functions which get emitted here. And
you are just counting the size of main but that is wrong really.
Anyways the overall size of the executable's text section is smaller at -Os
which is the point.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-25 0:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-25 0:33 [Bug c++/111577] New: -Os gives significantly bigger code than -O0 socketpair at gmail dot com
2023-09-25 0:50 ` [Bug middle-end/111577] " pinskia at gcc dot gnu.org
2023-09-25 0:53 ` pinskia 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).