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

            Bug ID: 30439
           Summary: [ARMv6] Optimization doesn't consider FPSCR as a
                    register that may get clobbered by function calls
           Product: clang
           Version: 3.9
          Hardware: Other
                OS: other
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: e...@80386.nl
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Consider the following piece of code:

---
extern void bar(void);
int foo(void) {
  int x = __builtin_flt_rounds();
  bar();
  return x + __builtin_flt_rounds();
}
---

When built for ARMv6 with Clang 3.9.0, we get the following code:

---
00000000 <foo>:
   0:   e92d4c10        push    {r4, sl, fp, lr}
   4:   e28db008        add     fp, sp, #8
   8:   eef10a10        vmrs    r0, fpscr
   c:   e3a01003        mov     r1, #3
  10:   e2800501        add     r0, r0, #4194304        ; 0x400000
  14:   e0010b20        and     r0, r1, r0, lsr #22
  18:   e0804000        add     r4, r0, r0
  1c:   ebfffffe        bl      0 <bar>
  20:   e1a00004        mov     r0, r4
  24:   e8bd8c10        pop     {r4, sl, fp, pc}
---

Notice how FPSCR is only loaded once and multiplied by two, instead of being
loaded separately. This means that if bar() is implemented as a function
calling fesetround(), the result of this function would be incorrect.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to