<html>
    <head>
      <base href="http://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 --- - Assert when combining an AND of two FCMPs."
   href="http://llvm.org/bugs/show_bug.cgi?id=15737">15737</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assert when combining an AND of two FCMPs.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>cameron.mcinally@nyu.edu
          </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>Created <span class=""><a href="attachment.cgi?id=10346" name="attach_10346" title="Tarball of preprocessed source, run script, and backtrace.">attachment 10346</a> <a href="attachment.cgi?id=10346&action=edit" title="Tarball of preprocessed source, run script, and backtrace.">[details]</a></span>
Tarball of preprocessed source, run script, and backtrace.

When compiling this function at -O2, Clang issues an assert:

int kung( float a, double b ) {
  return (a == a) & (b == b);
}

The assert is:

Assertion failed: (getOperand(0)->getType() == getOperand(1)->getType() &&
"Both operands to FCmp instruction are not of the same type!"), function
FCmpInst, file /Users/xkrebstarx/clang/llvm/include/llvm/IR/Instructions.h,
line 1117.


We begin with a float "a" and double "b":

<span class="quote">> (fcmp oeq a, a) & (fcmp oeq b, b) </span >

After canonicalization in InstCombine, we end up with the expression:

<span class="quote">> (fcmp ord a, 0.0) & (fcmp ord b, 0.0)</span >

The bug manifest is in InstCombiner::FoldAndOfFCmps(FCmpInst *LHS, FCmpInst
*RHS), when trying to perform this transformation:

<span class="quote">> (fcmp ord x, c) & (fcmp ord y, c)  -> (fcmp ord x, y)</span >

This is all fine, except that the FCmpInst constructor in the IRBuilder
requires that both operands to the new fcmp are the same type, which they are
not.</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>