[llvm-bugs] [Bug 43065] New: needless promotion of half to float and back for vector abs, select, shufflevector

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 20 11:18:24 PDT 2019


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

            Bug ID: 43065
           Summary: needless promotion of half to float and back for
                    vector abs, select, shufflevector
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: andrew.b.adams at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

Created attachment 22403
  --> https://bugs.llvm.org/attachment.cgi?id=22403&action=edit
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.

-- 
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/20190820/6f7a33c0/attachment-0001.html>


More information about the llvm-bugs mailing list