<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [AArch64][GlobalSel] Incorrect half to single precision code gen"
   href="https://bugs.llvm.org/show_bug.cgi?id=36106">36106</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AArch64][GlobalSel] Incorrect half to single precision code gen
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>carey.williams@arm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19756" name="attach_19756" title="Generated ASM">attachment 19756</a> <a href="attachment.cgi?id=19756&action=edit" title="Generated ASM">[details]</a></span>
Generated ASM

I believe there is a bug in the GlobalISel -0O code generation that affects
AArch64's half-precision (FP16) mechanics.

The generated code tries to convert a float value from single precision to
half-precision via FCVT. The problem is that in this case the immediate value
it is operating on is actually already stored/encoded in the half-precision
format.

Minimal reproducer:

int main() {
    _Float16 b = 1024.0f16;
    return (float)b;
}

Compiled with: clang -S -O0 -mllvm -aarch64-enable-global-isel-at-O=0
--target=aarch64-arm-none-eabi -march=armv8.2-a+fp16

Passing -mllvm -aarch64-enable-global-isel-at-O=-1 instead will generate
correctly functioning code.

---

I've attached the problematic generation with some comments.</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>