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: [email protected]
          Reporter: [email protected]
                CC: [email protected],
                    [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to