public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113422] New: Missed optimizations in the presence of pointer chains
@ 2024-01-16 13:21 carnet at student dot ethz.ch
2024-01-16 14:36 ` [Bug ipa/113422] " pinskia at gcc dot gnu.org
2024-01-25 12:58 ` hubicka at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: carnet at student dot ethz.ch @ 2024-01-16 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113422
Bug ID: 113422
Summary: Missed optimizations in the presence of pointer chains
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: ---
https://godbolt.org/z/hdWKn4bjc
All three functions write to the same variable (b). Clang is able to optimize
this. GCC -O3 cannot always do this.
Assembly for foo is writing to **d instead to directly write 1 to b. There is
similar behavior for bar and baz. Clang optimizes the code to directly write to
b.
Baz is fully optimized only if the foo and bar are removed.
int b = 0;
static int *c = &b;
static int **d = &c;
static int ***e = &d;
void foo() {***e = 1;}
void bar() {**d = 1;}
void baz() {*c = 1;}
Assembly code:
foo:
movq d(%rip), %rax
movq (%rax), %rax
movl $1, (%rax)
ret
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug ipa/113422] Missed optimizations in the presence of pointer chains
2024-01-16 13:21 [Bug tree-optimization/113422] New: Missed optimizations in the presence of pointer chains carnet at student dot ethz.ch
@ 2024-01-16 14:36 ` pinskia at gcc dot gnu.org
2024-01-25 12:58 ` hubicka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-16 14:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113422
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|tree-optimization |ipa
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2024-01-16
Severity|normal |enhancement
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes gcc static read only pass does not cycle . So it only able to remove
currently one level of indirection.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug ipa/113422] Missed optimizations in the presence of pointer chains
2024-01-16 13:21 [Bug tree-optimization/113422] New: Missed optimizations in the presence of pointer chains carnet at student dot ethz.ch
2024-01-16 14:36 ` [Bug ipa/113422] " pinskia at gcc dot gnu.org
@ 2024-01-25 12:58 ` hubicka at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-01-25 12:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113422
--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Cycling read-only var discovery would be quite expensive, since you need to
interleave it with early opts each round. I wonder how llvm handles this?
I think there is more hope with IPA-PTA getting scalable version at -O2 and
possibly being able to solve this.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-25 12:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 13:21 [Bug tree-optimization/113422] New: Missed optimizations in the presence of pointer chains carnet at student dot ethz.ch
2024-01-16 14:36 ` [Bug ipa/113422] " pinskia at gcc dot gnu.org
2024-01-25 12:58 ` hubicka 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).