<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Optimizing switch to jumps"
   href="https://bugs.llvm.org/show_bug.cgi?id=42313">42313</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Optimizing switch to jumps
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>denis.yaroshevskij@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi!

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

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: <a href="https://gcc.godbolt.org/z/8wq6O3">https://gcc.godbolt.org/z/8wq6O3</a>

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: <a href="https://gcc.godbolt.org/z/HzZHSb">https://gcc.godbolt.org/z/HzZHSb</a> (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)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>