<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] Incorrect optimization to sqrdmlah"
   href="https://bugs.llvm.org/show_bug.cgi?id=52419">52419</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AArch64] Incorrect optimization to sqrdmlah
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: AArch64
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jamie.cunliffe@arm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>arnaud.degrandmaison@arm.com, llvm-bugs@lists.llvm.org, smithp352@googlemail.com, Ties.Stuij@arm.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Currently sqrdmulh followed by an sqadd can be optimized into sqrdmlah when the
rdm target feature is provided which is incorrect for a small number of values.

#include <arm_neon.h>
#include <stdio.h>

int main(int argc, char **argv) {
  int32x2_t a = {static_cast<int32_t>(0x80000000),
                 static_cast<int32_t>(0x80000000)};
  int32x2_t b = {static_cast<int32_t>(0x80000000),
                 static_cast<int32_t>(0x80000000)};
  int32x2_t c = {static_cast<int32_t>(0x80000000),
                 static_cast<int32_t>(0x80000000)};

  auto val = vqadd_s32(a, vqrdmulh_s32(b, c));
  printf("%d,%d\n", vget_lane_s32(val, 0), vget_lane_s32(val, 1));
  return 0;
}


When compiling that with clang++ -march=armv8a+rdm -O2 test.cpp it would
optimize it into sqrdmlah and output: 0,0.
However, when compiling with clang++ -O2 test.cpp to get the sqrdmulh sqadd it
would actually be -1,-1

This also appears to be how the vqrdmlah intrinsics are currently implemented.</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>