public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113741] New: missed / wrong optimization switch transformation to same function call
@ 2024-02-03 11:04 b.buschinski at googlemail dot com
  2024-02-03 11:06 ` [Bug tree-optimization/113741] " sjames at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: b.buschinski at googlemail dot com @ 2024-02-03 11:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113741

            Bug ID: 113741
           Summary: missed / wrong optimization switch transformation to
                    same function call
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: b.buschinski at googlemail dot com
  Target Milestone: ---

Created attachment 57308
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57308&action=edit
Attached code + asm from the compiler explorer link

Compiler Explorer Link: https://godbolt.org/z/KozK9M5YY

The code is reduced from a "hot" path with huge macros.

I actually improved the macros with adding the "else" in the code, but I
noticed it suddenly created even more instructions and got slower.

The GCC version has 52 ASM lines.
The clang version only 9 ASM lines.

Clang is doing a better job here.

As far as I understand the ASM code, GCC generates a switch statement, but
after the:

cmp     edi, 5
ja      .L11

it should not be needed at all anymore.

Additionally, GCC "reloads" the static values again

(for every .L*: label)
mov     edi, 4

, which are already stored in "i" (C code).

Tested with GCC-13.2 and compiler explorer gcc "trunk".
On x86_64 Linux.


Please let me know if you need any additional details or if this report was
useful at all.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/113741] missed / wrong optimization switch transformation to same function call
  2024-02-03 11:04 [Bug tree-optimization/113741] New: missed / wrong optimization switch transformation to same function call b.buschinski at googlemail dot com
@ 2024-02-03 11:06 ` sjames at gcc dot gnu.org
  2024-02-03 11:10 ` b.buschinski at googlemail dot com
  2024-02-03 19:54 ` [Bug tree-optimization/113741] missed " pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-02-03 11:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113741

Sam James <sjames at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sjames at gcc dot gnu.org

--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
Note that we reserve the term "wrong" for invalid results or otherwise unsound
transformations.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/113741] missed / wrong optimization switch transformation to same function call
  2024-02-03 11:04 [Bug tree-optimization/113741] New: missed / wrong optimization switch transformation to same function call b.buschinski at googlemail dot com
  2024-02-03 11:06 ` [Bug tree-optimization/113741] " sjames at gcc dot gnu.org
@ 2024-02-03 11:10 ` b.buschinski at googlemail dot com
  2024-02-03 19:54 ` [Bug tree-optimization/113741] missed " pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: b.buschinski at googlemail dot com @ 2024-02-03 11:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113741

--- Comment #2 from Bernd Buschinski <b.buschinski at googlemail dot com> ---
Ah sorry, I did not know that. Please rephrase the topic to better match the
actual problem :)

(Or tell me what it should be rephrased to)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug tree-optimization/113741] missed optimization switch transformation to same function call
  2024-02-03 11:04 [Bug tree-optimization/113741] New: missed / wrong optimization switch transformation to same function call b.buschinski at googlemail dot com
  2024-02-03 11:06 ` [Bug tree-optimization/113741] " sjames at gcc dot gnu.org
  2024-02-03 11:10 ` b.buschinski at googlemail dot com
@ 2024-02-03 19:54 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-03 19:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113741

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 96245.

*** This bug has been marked as a duplicate of bug 96245 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-03 19:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-03 11:04 [Bug tree-optimization/113741] New: missed / wrong optimization switch transformation to same function call b.buschinski at googlemail dot com
2024-02-03 11:06 ` [Bug tree-optimization/113741] " sjames at gcc dot gnu.org
2024-02-03 11:10 ` b.buschinski at googlemail dot com
2024-02-03 19:54 ` [Bug tree-optimization/113741] missed " 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).