<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [ARMv6] Optimization doesn't consider FPSCR as a register that may get clobbered by function calls"
   href="https://llvm.org/bugs/show_bug.cgi?id=30439">30439</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ARMv6] Optimization doesn't consider FPSCR as a register that may get clobbered by function calls
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ed@80386.nl
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>