public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114318] New: Missing Optimization after multiple function calls
@ 2024-03-12 14:16 carnet at student dot ethz.ch
2024-03-12 14:19 ` [Bug tree-optimization/114318] " rguenth at gcc dot gnu.org
2024-03-12 15:34 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: carnet at student dot ethz.ch @ 2024-03-12 14:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114318
Bug ID: 114318
Summary: Missing Optimization after multiple function calls
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: carnet at student dot ethz.ch
Target Milestone: ---
GCC -O3 does not inline the function if there are more than two calls. This
also only happens in the main function. Changing the name of the main function
and/or reducing the number of function calls, enables the optimization.
https://godbolt.org/z/KM71WrYac
Source
int a, c, d;
int *b, *e;
static int *f() {
int *g = &d;
int **h = &b;
*g = 1;
*h = &c;
if (*b)
for (; d; d = d + 8)
;
return &d;
}
int main() {
f();
f();
f();
}
x86 -O3 Assembly:
f.part.0:
movl d(%rip), %eax
testl %eax, %eax
je .L1
movl $0, d(%rip)
.L1:
ret
main:
movl $1, d(%rip)
movl c(%rip), %ecx
testl %ecx, %ecx
je .L5
xorl %eax, %eax
call f.part.0
.L5:
movl $1, d(%rip)
movl c(%rip), %edx
testl %edx, %edx
je .L6
xorl %eax, %eax
call f.part.0
.L6:
movl $1, d(%rip)
movl c(%rip), %eax
movq $c, b(%rip)
testl %eax, %eax
je .L7
xorl %eax, %eax
call f.part.0
.L7:
xorl %eax, %eax
ret
e:
.zero 8
b:
.zero 8
d:
.zero 4
c:
.zero 4
a:
.zero 4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/114318] Missing Optimization after multiple function calls
2024-03-12 14:16 [Bug tree-optimization/114318] New: Missing Optimization after multiple function calls carnet at student dot ethz.ch
@ 2024-03-12 14:19 ` rguenth at gcc dot gnu.org
2024-03-12 15:34 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-12 14:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114318
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |WONTFIX
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
That's because main is cold.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/114318] Missing Optimization after multiple function calls
2024-03-12 14:16 [Bug tree-optimization/114318] New: Missing Optimization after multiple function calls carnet at student dot ethz.ch
2024-03-12 14:19 ` [Bug tree-optimization/114318] " rguenth at gcc dot gnu.org
@ 2024-03-12 15:34 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-12 15:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114318
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> That's because main is cold.
Or rather known to be called once which causes the path to be considered cold
unless there is a loop.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-12 15:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12 14:16 [Bug tree-optimization/114318] New: Missing Optimization after multiple function calls carnet at student dot ethz.ch
2024-03-12 14:19 ` [Bug tree-optimization/114318] " rguenth at gcc dot gnu.org
2024-03-12 15:34 ` 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).