<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 - Codegen being moved outside of volatile block"
   href="https://bugs.llvm.org/show_bug.cgi?id=45149">45149</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Codegen being moved outside of volatile block
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>andrea.dibiagio@gmail.com, craig.topper@gmail.com, greg.bedwell@sony.com, llvm-bugs@lists.llvm.org, matze@braunis.de, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://godbolt.org/z/bo6w2F">https://godbolt.org/z/bo6w2F</a>

#include <x86intrin.h>

__v16qi foo(__v16qi a, __v16qi b) {
  __asm volatile("# LLVM-MCA-BEGIN foo");
  __v16qi result = a + b;
  __asm volatile("# LLVM-MCA-END foo");
  return result;
}

I'm seeing an issue where depending on the target cpu the generated asm is
getting moved out of the volatile comment block.

clang -g0 -O3:

# %bb.0:
        #APP
        # LLVM-MCA-BEGIN foo
        #NO_APP
        paddb   %xmm1, %xmm0
        #APP
        # LLVM-MCA-END foo
        #NO_APP
        retq


clang -g0 -O3 -march=sandybridge:

# %bb.0:
        #APP
        # LLVM-MCA-BEGIN foo
        #NO_APP
        vpaddb  %xmm0, %xmm1, %xmm0
        #APP
        # LLVM-MCA-END foo
        #NO_APP
        retq


clang -g0 -O3 -march=btver2:

# %bb.0:
        vpaddb  %xmm0, %xmm1, %xmm0
        #APP
        # LLVM-MCA-BEGIN foo
        #NO_APP
        #APP
        # LLVM-MCA-END foo
        #NO_APP
        retq

which prevents llvm-mca from reporting on the code snippet.</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>