<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 fabs optimization when fdiv or fmul is involved"
   href="https://bugs.llvm.org/show_bug.cgi?id=47943">47943</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect fabs optimization when fdiv or fmul is involved
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

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

        <tr>
          <th>Status</th>
          <td>NEW
          </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>juneyoung.lee@sf.snu.ac.kr
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>----------------------------------------
// Transforms/InstCombine/fmul.ll

define float @fabs_squared(float %x) {
%0:
  %x.fabs = fabs float %x
  %mul = fmul float %x.fabs, %x.fabs
  ret float %mul 
}
=>
define float @fabs_squared(float %x) {
%0:
  %mul = fmul float %x, %x
  ret float %mul 
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
float %x = undef

Source:
float %x.fabs = NaN [based on undef value]
float %mul = NaN  [based on undef value]

Target:
float %mul = #x80000000 (-0.0)
Source value: NaN
Target value: #x80000000 (-0.0)

----------------------------------------
// Transforms/InstCombine/fdiv.ll

define float @fabs_same_op(float %x) {
%0:
  %a = fabs float %x
  %r = fdiv float %a, %a
  ret float %r
}
=>
define float @fabs_same_op(float %x) {
%0:
  %r = fdiv float %x, %x
  ret float %r
}
Transformation doesn't verify!
ERROR: Value mismatch
----------------------------------------

After optimization, `fmul %x, %x` isn't guaranteed to be non-negative because
the result can be negative if %x was undef.
Similarly for the `fdiv` case.</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>