<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 --- - InstructionSimplify turns 0.0 to -0.0"
   href="https://llvm.org/bugs/show_bug.cgi?id=26746">26746</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>InstructionSimplify turns 0.0 to -0.0
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </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>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>davemm@cs.rutgers.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, santosh.nagarakatte@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given this input:

define float @foo(float %x) #0 {
entry:
  %a = fsub float -0.0, %x
  %b = fsub float 0.0, %a
  ret float %b
}


opt -instcombine produces

define float @foo(float %x) #0 {
entry:
  ret float %x
}


If %x = -0.0, the original function returns 0.0, but the optimized function
returns -0.0.


I believe this is the relevant code, from lib/Analysis/InstructionSimplify.cpp:

  // fsub 0, (fsub -0.0, X) ==> X
  Value *X;
  if (match(Op0, m_AnyZero())) {
    if (match(Op1, m_FSub(m_NegZero(), m_Value(X)))) // this clause
      return X;
    if (FMF.noSignedZeros() && match(Op1, m_FSub(m_AnyZero(), m_Value(X))))
      return X;
  }</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>