public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/97856] New: Missed optimization: repeated call @ 2020-11-16 17:40 miguel.ojeda.sandonis at gmail dot com 2020-11-17 7:12 ` [Bug rtl-optimization/97856] " rguenth at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: miguel.ojeda.sandonis at gmail dot com @ 2020-11-16 17:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97856 Bug ID: 97856 Summary: Missed optimization: repeated call Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: miguel.ojeda.sandonis at gmail dot com Target Milestone: --- For code such as: void f(int); void g(int v) { switch (v) { case 1: f(1); case 2: f(2); case 3: f(3); default: f(4); } } GCC generates for e.g. x86_64: g(int): subq $8, %rsp cmpl $2, %edi je .L2 cmpl $3, %edi je .L3 cmpl $1, %edi je .L13 movl $4, %edi addq $8, %rsp jmp f(int) .L13: call f(int) .L2: movl $2, %edi call f(int) .L3: movl $3, %edi call f(int) movl $4, %edi addq $8, %rsp jmp f(int) Repeating the `f(4);` call can be avoided by reordering the cases, reducing code size. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug rtl-optimization/97856] Missed optimization: repeated call 2020-11-16 17:40 [Bug tree-optimization/97856] New: Missed optimization: repeated call miguel.ojeda.sandonis at gmail dot com @ 2020-11-17 7:12 ` rguenth at gcc dot gnu.org 2021-09-01 4:41 ` pinskia at gcc dot gnu.org 2021-09-01 4:41 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2020-11-17 7:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97856 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Version|unknown |11.0 Component|tree-optimization |rtl-optimization Ever confirmed|0 |1 CC| |hubicka at gcc dot gnu.org Status|UNCONFIRMED |NEW Last reconfirmed| |2020-11-17 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. basic-block reordering decides to duplicate the block: Redirecting fallthru edge 7->8 to 9 Duplicated bb 8 (created bb 9) Final order: 2 3 4 8 5 6 7 9 Reordered sequence: 2 bb 2 3 bb 3 4 bb 4 5 bb 8 6 bb 5 7 bb 6 8 bb 7 9 duplicate of 8 since we decide to put the default: handling on the fallthru edge of the condition chain we duplicate it to the tail as well. IIRC expansion always does it this way and BB reorder simply avoids one jump. With -Os we flip the last jump and avoid the duplication. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug rtl-optimization/97856] Missed optimization: repeated call 2020-11-16 17:40 [Bug tree-optimization/97856] New: Missed optimization: repeated call miguel.ojeda.sandonis at gmail dot com 2020-11-17 7:12 ` [Bug rtl-optimization/97856] " rguenth at gcc dot gnu.org @ 2021-09-01 4:41 ` pinskia at gcc dot gnu.org 2021-09-01 4:41 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-09-01 4:41 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97856 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Richard Biener from comment #1) > Confirmed. basic-block reordering decides to duplicate the block: Yes there are a few other bugs where we like to duplicate the return block I have seen too. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug rtl-optimization/97856] Missed optimization: repeated call 2020-11-16 17:40 [Bug tree-optimization/97856] New: Missed optimization: repeated call miguel.ojeda.sandonis at gmail dot com 2020-11-17 7:12 ` [Bug rtl-optimization/97856] " rguenth at gcc dot gnu.org 2021-09-01 4:41 ` pinskia at gcc dot gnu.org @ 2021-09-01 4:41 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-09-01 4:41 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97856 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-01 4:41 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-11-16 17:40 [Bug tree-optimization/97856] New: Missed optimization: repeated call miguel.ojeda.sandonis at gmail dot com 2020-11-17 7:12 ` [Bug rtl-optimization/97856] " rguenth at gcc dot gnu.org 2021-09-01 4:41 ` pinskia at gcc dot gnu.org 2021-09-01 4:41 ` 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).