public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/95208] New: missed switch optimization as bit test
@ 2020-05-19 13:42 nathan at gcc dot gnu.org
  2020-05-20 11:02 ` [Bug middle-end/95208] " marxin at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-05-19 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95208
           Summary: missed switch optimization as bit test
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nathan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 48565
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48565&action=edit
The if case is optimized better

This comes from libcpp/lex.c's raw string lexer.  We're testing whether a
character falls into a particular set of values.  The switch is emitted as the
usual dispatch table.  The if case, after range checking, turns into
'if ((1ul << (c - BASE)) & MAGIC_VALUE)'  Which is somewhat better.  Why
doesn't the switch form do that?

_Z3bazc:
.LFB1:
        .cfi_startproc
        leal    -97(%rdi), %eax
        cmpb    $29, %al
        jbe     .L7
        subl    $33, %edi
        cmpb    $62, %dil
        ja      .L6
        movabsq $8646911282403868279, %rax
        btq     %rdi, %rax
        jc      .L7
.L6:
        ret
        .p2align 4,,10
        .p2align 3
.L7:
        jmp     _Z3barv
        .cfi_endproc

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

end of thread, other threads:[~2021-12-07  8:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19 13:42 [Bug middle-end/95208] New: missed switch optimization as bit test nathan at gcc dot gnu.org
2020-05-20 11:02 ` [Bug middle-end/95208] " marxin at gcc dot gnu.org
2021-07-21  0:14 ` pinskia at gcc dot gnu.org
2021-12-07  8:15 ` marxin 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).