[LLVMbugs] [Bug 24091] New: fabs of -0 returns -0 on Cortex-M4

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jul 11 00:56:10 PDT 2015


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

            Bug ID: 24091
           Summary: fabs of -0 returns -0 on Cortex-M4
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ambrop7 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14574
  --> https://llvm.org/bugs/attachment.cgi?id=14574&action=edit
test case, function that calls fabs

While trying to use Clang for a microcontroller project (Cortex-M4 with FPU), I
am seeing fabs(-0) returning -0. But the correct result is 0. Note, this is for
calculation with doubles not floats.

Attached is a simple test case that can be compiled to assembly, and the
resulting assembly, produced with the command below.

I cannot read ARM assembly well but I suspect the inlined implementation of
fabs really is incorrect with respect to -0. I have also attached the result of
compiling with GCC (same command line), which seems to be a much more optimized
implementation.

arm-none-eabi-clang -mcpu=cortex-m4 -mthumb -O2 -fno-math-errno
-fno-trapping-math -fshort-enums -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fno-rtti
-fno-exceptions abs.c -S -o abs.S

Clang was configured as follows:
../configure --enable-targets=arm --target=arm-none-eabi --enable-cxx11
--disable-docs \
            
--with-gcc-toolchain=${gcc-arm-embedded}/lib/gcc/arm-none-eabi/$gccVersion \
             --with-c-include-dirs=${gcc-arm-embedded}/arm-none-eabi/include

-- 
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/20150711/e1ef0fc1/attachment.html>


More information about the llvm-bugs mailing list