[LLVMbugs] [Bug 23418] New: Support TEST DATA CLASS instruction

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 5 10:50:33 PDT 2015


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

            Bug ID: 23418
           Summary: Support TEST DATA CLASS instruction
           Product: libraries
           Version: trunk
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: SystemZ
          Assignee: unassignedbugs at nondot.org
          Reporter: uweigand at de.ibm.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

System z provides a TEST DATA CLASS instruction that could be used to
implement any of the floating-point test builtins, including isfinite,
isinf, isnan, or isnormal.

To implement that, the back-end should recognize the typical idioms
used to implement those checks and convert them into TDC primitives,
and then collect multiple such primitives when possible.

For example, __builtin_isfinite (f) is represented in LLVM IR as:

  %iseq = fcmp ord double %f, 0.000000e+00
  %0 = tail call double @llvm.fabs.f64(double %f)
  %isinf = fcmp une double %0, 0x7FF0000000000000
  %and = and i1 %iseq, %isinf

Via repeated application of the following rules:

%y = fcmp ord double %x, 0.000000e+00
 --> %y = TDC %x, 0xff0

%y = fcmp une double %x, 0x7FF0000000000000
 --> %y = TDC %x, 0xfdf

%y = tail call double @llvm.fabs.f64(double %x)
%z = TDC %y, %mask
 --> %z = TDC %x, (%mask & 0xaaa) | ((%mask & 0xaaa) >> 1)

%y = TDC %x, %mask1
%z = TDC %x, %mask2
%t = and i1 %y %z
 --> %t = TDC %x, %mask1 & %mask2

this could be simplified to:
 %and = TDC %f, 0xfc0
which implements exactly the "isfinite" logic.

(The above is just a subset of rules that could be applicable for a fully
generic implementation.)

It should be possible to do this during SelectionDAG isel.

-- 
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/20150505/cae55b2d/attachment.html>


More information about the llvm-bugs mailing list