[llvm-bugs] [Bug 42313] New: Optimizing switch to jumps

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 18 16:38:09 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42313

            Bug ID: 42313
           Summary: Optimizing switch to jumps
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: denis.yaroshevskij at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hi!

There is a nice optimisation for std::merge that I cannot do because std::merge
would soon be required to be constexpr (https://reviews.llvm.org/D63063).

I could have replaced my gotos with a switch and write my state machine on it
but unfortunately switch does not get optimised away into jumps.

Here is the code comparison: https://gcc.godbolt.org/z/8wq6O3

Could it maybe be possible to optimise the switch away?
I looked at gcc and it seems to produce identical code for both switch and goto
implementation: https://gcc.godbolt.org/z/HzZHSb (to be fare - clang manages to
collapse two memmoves into one for the goto implementation, which gcc does not
but gcc's result is identical)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190618/fae40440/attachment.html>


More information about the llvm-bugs mailing list