[llvm-bugs] [Bug 28164] New: Dividing complex numbers produces wrong results on ARM 32bit

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 17 05:53:10 PDT 2016


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

            Bug ID: 28164
           Summary: Dividing complex numbers produces wrong results on ARM
                    32bit
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: violeta.vukobrat at rt-rk.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Clang produces wrong result for complex numbers division.
The following example:

test.c

int main() {
  _Complex double a = 3;
  _Complex double b = 0;
  printf("a/b: %f\n", (double)(a/b));
  return 0;
}

When built for arm32 hard float:

clang -target arm-linux-gnueabihf -march=armv7a -EL
--gcc-toolchain=PATH_TO_TOOLCHAIN --sysroot=PATH_TO_SYSROOT -O2
-mfloat-abi=hard -mfpu=vfp -o test test.c

It produces the following output:
a/b: 3.000000

This is the part of the .s file generated from the example:
        ...
    vldr    d0, .LCPI0_0
    mov    r12, #0
    vldr    d1, .LCPI0_1
    vmov    r0, r1, d0
    str    r12, [sp]
    vmov    r2, r3, d1
    str    r12, [sp, #4]
    str    r12, [sp, #8]
    str    r12, [sp, #12]
    bl    __divdc3
    mov    r2, r0
    movw    r0, :lower16:.L.str
    movt    r0, :upper16:.L.str
        ....

It appears that the function __divdc3 is given the correct values and
calculates the right result, however the problem seems to be that clang reads
the return value from wrong registers (using r0 instead of d0).

-- 
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/20160617/ba82165d/attachment.html>


More information about the llvm-bugs mailing list