public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105740] New: missed optimization switch transformation for conditions with duplicate conditions
@ 2022-05-26 11:26 b.buschinski at googlemail dot com
  2022-05-30  9:57 ` [Bug tree-optimization/105740] " marxin at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: b.buschinski at googlemail dot com @ 2022-05-26 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105740
           Summary: missed optimization switch transformation for
                    conditions with duplicate conditions
           Product: gcc
           Version: 12.1.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 53037
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53037&action=edit
Attached code + asm from the compiler explorer link

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

The code on the left does not generate a switch statement.
The code on the right does generate a switch statement.

The code works similar, the only difference is that the duplicate "f->len > 3"
check is moved to the top for the "right" version.

The compiler explorer code is actually a minimized version of the code I work
on (with way more conditions in a hot code path), where I can not easily move
the length check to the top, because the "f-> len > 3 && ..." is done in a very
complicated macro, but that's just details.

I expected both code versions to generate the same assembler.

Tested with GCC-12.1 and 11.3. 10.3 does not generate a switch version for both
versions, as only 11 got this nice feature.
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] 13+ messages in thread

end of thread, other threads:[~2023-06-26  6:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 11:26 [Bug tree-optimization/105740] New: missed optimization switch transformation for conditions with duplicate conditions b.buschinski at googlemail dot com
2022-05-30  9:57 ` [Bug tree-optimization/105740] " marxin at gcc dot gnu.org
2022-06-21  2:45 ` luoxhu at gcc dot gnu.org
2022-06-21  7:30 ` marxin at gcc dot gnu.org
2022-06-21  9:02 ` rguenth at gcc dot gnu.org
2022-06-21  9:12 ` jakub at gcc dot gnu.org
2022-06-21  9:26 ` rguenther at suse dot de
2022-06-21  9:29 ` cvs-commit at gcc dot gnu.org
2022-06-22  6:19 ` luoxhu at gcc dot gnu.org
2022-06-27 13:58 ` marxin at gcc dot gnu.org
2022-07-01  2:06 ` luoxhu at gcc dot gnu.org
2022-07-08 10:46 ` marxin at gcc dot gnu.org
2023-06-26  6:43 ` b.buschinski at googlemail dot com

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).