<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Support TEST DATA CLASS instruction"
   href="https://llvm.org/bugs/show_bug.cgi?id=23418">23418</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Support TEST DATA CLASS instruction
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>Other
          </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: SystemZ
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>uweigand@de.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</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>