Floating point rounding fails on mps3-an547 amd cortex-m55 while using LLVM-embedded-toolchain-for-Arm and Picolibic.

Host environment

  • Operating system: Ubuntu 20.04.5 LTS
  • OS/kernel version: Linux 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • Architecture: x86_64
  • QEMU flavor: qemu-system-arm
  • QEMU version: QEMU emulator version 7.1.0
  • QEMU command line: qemu-system-arm -M mps3-an547 -cpu cortex-m55 -chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -monitor none -serial none -nographic -device loader,file=LLVM-embedded-toolchain-for-Arm/build/picolibc/armv8.1m.main_hard_nofp_mve/src/picolibc_armv8.1m_hard_nofp_mve/test/long_double,cpu-num=0

Emulated/Virtualized environment

  • Operating system: N/A
  • OS/kernel version: N/A
  • Architecture: mps3-an547 and cortex-m55

Description of problem

Rounding of long double gives unexpected result. Simple code as example:

#include <math.h>
int main(void)
{
  long double value = -8.5L;
  long rounded_value = lrintl(value);
  if( -8 == rounded_value )
  {
    return 0;
  }
  return 1;
}

Steps to reproduce

  1. Checkout project: LLVM-embedded-toolchain-for-ARM
  2. Configure it with option -DLLVM_TOOLCHAIN_LIBRARY_VARIANTS=armv8.1m.main_hard_nofp_mve
  3. Build project
  4. Run Picolbic tests with ninja picolibc_armv8.1m.main_hard_nofp_mve-test

As a result long_double test fails with incorrect rounding. Last qemu version which successfully execute mentioned test is: qemu 7.0.0 downloaded via qemu-7.0.0. Issue is present since qemu version 7.1.

Additional information

As a result long_double test fails with incorrect rounding. Last qemu version which successfully execute mentioned test is: qemu 7.0.0 downloaded via qemu-7.0.0. Issue is present since qemu version 7.1.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information