[llvm-bugs] [Bug 52419] New: [AArch64] Incorrect optimization to sqrdmlah

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 5 05:45:33 PDT 2021


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

            Bug ID: 52419
           Summary: [AArch64] Incorrect optimization to sqrdmlah
           Product: libraries
           Version: trunk
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: jamie.cunliffe at arm.com
                CC: arnaud.degrandmaison at arm.com,
                    llvm-bugs at lists.llvm.org, smithp352 at googlemail.com,
                    Ties.Stuij at arm.com

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.

-- 
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/20211105/ff9a0b6d/attachment.html>


More information about the llvm-bugs mailing list