<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 - needless promotion of half to float and back for vector abs, select, shufflevector"
   href="https://bugs.llvm.org/show_bug.cgi?id=43065">43065</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>needless promotion of half to float and back for vector abs, select, shufflevector
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>andrew.b.adams@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22403" name="attach_22403" title="ll that demonstrates the problem">attachment 22403</a> <a href="attachment.cgi?id=22403&action=edit" title="ll that demonstrates the problem">[details]</a></span>
ll that demonstrates the problem

Operations on half vectors that just shuffle data around or can be implemented
as bitwise ops needlessly promote from half to float then back again. The
specific examples I have are abs, select, and concatenating two vectors. Select
is particularly bad, because it both promotes to float and also scalarizes the
select.

It seems that just about every data-shuffling operation I try on half vectors
that could be just implemented using the i16 equivalent instructions needlessly
promotes to float first. Attempts to work around by bitcasting to i16 instead
are foiled by llvm first optimizing away the bitcast. 

I have found it impossible to use the half type in x86 code for this reason,
and have resorted to lowering Halide half types i16s for the x86 and arm
backends. This is clearly suboptimal, as it makes it hard to use the
half->float conversion instructions when I *do* want to do half math, as the
intermediate half type gets propagated through any neighboring bitcasting,
triggering the issues above. It also makes it annoying to pass buffers to code
generated by backends that do half math natively (e.g. ptx).

.ll that reproduces the issue is attached.</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>