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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to