public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98960] New: Failure to optimize accumulate loop to mul
@ 2021-02-03 20:12 gabravier at gmail dot com
2021-02-04 7:55 ` [Bug tree-optimization/98960] " rguenth at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2021-02-03 20:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98960
Bug ID: 98960
Summary: Failure to optimize accumulate loop to mul
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
int f(uint8_t max_value) {
int sum = 0;
for (int i = 0; i < max_value; i++) {
sum += i;
}
return sum;
}
This can be optimized to `return (uint64_t)max_value * (max_value - 1) >> 1;`.
This transformation is done by LLVM, but not by GCC.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/98960] Failure to optimize accumulate loop to mul
2021-02-03 20:12 [Bug tree-optimization/98960] New: Failure to optimize accumulate loop to mul gabravier at gmail dot com
@ 2021-02-04 7:55 ` rguenth at gcc dot gnu.org
2023-06-10 15:57 ` pinskia at gcc dot gnu.org
2023-06-10 16:02 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-04 7:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98960
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2021-02-04
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Final value replacement has
(set_scalar_evolution
instantiated_below = 5
(scalar = sum_7)
(scalar_evolution = {0, +, {1, +, 1}_1}_1))
)
(chrec_apply
(varying_loop = 1
)
(chrec = {0, +, {1, +, 1}_1}_1)
(x = (unsigned int) max_value_4(D) + 4294967295)
(res = scev_not_known))
not replacing:
sum_1 = PHI <sum_7(3)>
because it doesn't know this (IIRC there's a duplicate bug where I tried some
things to handle this).
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/98960] Failure to optimize accumulate loop to mul
2021-02-03 20:12 [Bug tree-optimization/98960] New: Failure to optimize accumulate loop to mul gabravier at gmail dot com
2021-02-04 7:55 ` [Bug tree-optimization/98960] " rguenth at gcc dot gnu.org
@ 2023-06-10 15:57 ` pinskia at gcc dot gnu.org
2023-06-10 16:02 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-10 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98960
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |llvm at rifkin dot dev
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 110203 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/98960] Failure to optimize accumulate loop to mul
2021-02-03 20:12 [Bug tree-optimization/98960] New: Failure to optimize accumulate loop to mul gabravier at gmail dot com
2021-02-04 7:55 ` [Bug tree-optimization/98960] " rguenth at gcc dot gnu.org
2023-06-10 15:57 ` pinskia at gcc dot gnu.org
@ 2023-06-10 16:02 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-10 16:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98960
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 65855.
*** This bug has been marked as a duplicate of bug 65855 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-10 16:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 20:12 [Bug tree-optimization/98960] New: Failure to optimize accumulate loop to mul gabravier at gmail dot com
2021-02-04 7:55 ` [Bug tree-optimization/98960] " rguenth at gcc dot gnu.org
2023-06-10 15:57 ` pinskia at gcc dot gnu.org
2023-06-10 16:02 ` 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).