public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103072] New: Folding common switch code
@ 2021-11-04  0:01 llvm at rifkin dot dev
  2021-11-04  8:15 ` [Bug tree-optimization/103072] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: llvm at rifkin dot dev @ 2021-11-04  0:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103072
           Summary: Folding common switch code
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: llvm at rifkin dot dev
  Target Milestone: ---

In the following code, GCC can optimize foo but not bar:

void foo(int x) {
    switch(x) {
        case 1: func1(); break;
        case 2: func1(); break;
        case 3: func1(); break;
        case 4: func1(); break;
        case 5: func1(); break;
        default: __builtin_unreachable();
    }
}

void bar(int x) {
    switch(x) {
        case 1: func2(x); break;
        case 2: func2(x); break;
        case 3: func2(x); break;
        case 4: func2(x); break;
        case 5: func2(x); break;
        default: __builtin_unreachable();
    }
}

https://godbolt.org/z/3eqnG71f5 (LLVM optimizes both)

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

end of thread, other threads:[~2021-11-29 20:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04  0:01 [Bug tree-optimization/103072] New: Folding common switch code llvm at rifkin dot dev
2021-11-04  8:15 ` [Bug tree-optimization/103072] " jakub at gcc dot gnu.org
2021-11-04  9:12 ` rguenth at gcc dot gnu.org
2021-11-04 12:46 ` marxin at gcc dot gnu.org
2021-11-04 14:43 ` llvm at rifkin dot dev
2021-11-29 20:35 ` 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).