public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/116751] New: GCC trunk (-O3) doesn't optimize a loop that can be folded into a constant
@ 2024-09-17 16:45 dccitaliano at gmail dot com
2024-09-18 6:34 ` [Bug tree-optimization/116751] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: dccitaliano at gmail dot com @ 2024-09-17 16:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116751
Bug ID: 116751
Summary: GCC trunk (-O3) doesn't optimize a loop that can be
folded into a constant
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: dccitaliano at gmail dot com
Target Milestone: ---
https://godbolt.org/z/qq1bbdMKn
```
#include <stdint.h>
int64_t patatino() {
int64_t result = 0;
for (int r = 0; r < 7; r++) {
for (int s = 0; s < 10; s++) {
for (int t = 0; t < 10; t++) {
if (t + s + r == 10) {
result += 1;
}
}
}
}
return result;
}
```
Changing the condition from `t + s + r == 10` to `t + s == 10` changes the
generated code into:
```
patatino():
mov eax, 63
ret
```
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/116751] GCC trunk (-O3) doesn't optimize a loop that can be folded into a constant
2024-09-17 16:45 [Bug middle-end/116751] New: GCC trunk (-O3) doesn't optimize a loop that can be folded into a constant dccitaliano at gmail dot com
@ 2024-09-18 6:34 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-09-18 6:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116751
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|unknown |15.0
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Component|middle-end |tree-optimization
Last reconfirmed| |2024-09-18
Keywords| |missed-optimization
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Unroll heuristic is (too) easily confused here I guess. Note we need to unroll
all loops completely to be able to optimize this.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-18 6:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-17 16:45 [Bug middle-end/116751] New: GCC trunk (-O3) doesn't optimize a loop that can be folded into a constant dccitaliano at gmail dot com
2024-09-18 6:34 ` [Bug tree-optimization/116751] " 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).