<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 - Incorrect swap of fptrunc with fast-math instructions"
   href="https://bugs.llvm.org/show_bug.cgi?id=49080">49080</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect swap of fptrunc with fast-math instructions
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Keywords</th>
          <td>miscompilation
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nunoplopes@sapo.pt
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>lebedev.ri@gmail.com, llvm-bugs@lists.llvm.org, Matthew.Arsenault@amd.com, regehr@cs.utah.edu, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>See the example below where fptrunc & fabs are swapped. The issue is that fabs
has the nninf tag, which becomes poison because its input is inf.

Two solutions come to mind: drop nninf from fabs in the solution, or add
fast-math flags to fptrunc.


define half @test_shrink_intrin_fabs_fast_double_src(float %D) {
  %E = fabs fast float %D
  %F = fptrunc float %E to half
  ret half %F
}
=>
define half @test_shrink_intrin_fabs_fast_double_src(float %D) {
  %1 = fptrunc float %D to half
  %F = fabs fast half %1
  ret half %F
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source

Example:
float %D = #x477ff080 (65520.5)

Source:
float %E = #x477ff080 (65520.5)
half %F = #x7c00 (+oo)

Target:
half %1 = #x7c00 (+oo)
half %F = poison
Source value: #x7c00 (+oo)
Target value: poison


File: llvm/test/Transforms/InstCombine/double-float-shrink-2.ll
A similar test also fails in Transforms/InstCombine/fpcast.ll (test4-fast)</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>