<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 - aarch64: -march=armv8-a produces armv8.2 'bfc' instruction"
   href="https://bugs.llvm.org/show_bug.cgi?id=42576">42576</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>aarch64: -march=armv8-a produces armv8.2 'bfc' instruction
          </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>Linux
          </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>arnd@linaro.org
          </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>Building arm64 linux randconfig kernels, I came across this assembler error:

/tmp/sdma_v4_0-f95fd3.s: Assembler messages:
/tmp/sdma_v4_0-f95fd3.s:44: Error: selected processor does not support `bfc
w0,#1,#5'

I reduced the test case to

int a, b, c;
int __order_base_2() { return a > 1 ? __builtin_constant_p(a) ?: b : 0; }
int sdma_v4_0_rb_cntl(int p1) {
  int d = c ?: __order_base_2();
  p1 = (p1 & ~0x0000003EL) | (62 & (d << 1));
  return p1;
}
$ clang-8  --prefix=/home/arnd/cross/x86_64/gcc-8.1.0-nolibc/aarch64-linux/bin/
-no-integrated-as -O2 sdma_v4_0.i --target=aarch64-linux -S -o-
-march=armv8.1-a

<a href="https://godbolt.org/z/8Gcjl9">https://godbolt.org/z/8Gcjl9</a> shows the 'bfc' instruction being generated, but
not the error message as it is unable to call the external assembler correctly.

According to <a href="https://sourceware.org/ml/binutils/2015-11/msg00221.html">https://sourceware.org/ml/binutils/2015-11/msg00221.html</a>, the
'bfc' instruction is only valid in armv8.2 or higher but llvm uses it for any
armv8 version.</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>