<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 --- - AnalyzeBranch() fails on non-equality comparison between a float value and zero on X86." href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23875&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=OiMR4kj55ME6PhLGpXFAB1ezQLBo6Dd0jkgJUbRbzcY&s=WPip-kw0X6yZKGmvw98RuOU29q02tYIW_CY1i6G8Kfw&e=">23875</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AnalyzeBranch() fails on non-equality comparison between a float value and zero on X86.
          </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>Linux
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>congh@google.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>In LLVM and on X86, AnalyzeBranch() returns true (which means failure) on the
branch in the following function:

void foo(float f) {
  if (f != 0)
    printf("*");
}

The generated machine code for this function is:


BB#0: derived from LLVM BB %entry
    Live Ins: %XMM0
        %XMM1<def,tied1> = XORPSrr %XMM1<undef,tied0>, %XMM1<undef>
        UCOMISSrr %XMM0<kill>, %XMM1<kill>, %EFLAGS<imp-def>
        JNE_1 <BB#1>, %EFLAGS<imp-use>
        JNP_1 <BB#2>, %EFLAGS<imp-use>
    Successors according to CFG: BB#1(1) BB#2(101)

BB#1: derived from LLVM BB %if.then
    Predecessors according to CFG: BB#0
        %EDI<def> = MOV32ri 42
        TAILJMPd64 <ga:@putchar>, <regmask>, %RSP<imp-use>, %RSP<imp-use>,
%EDI<imp-use,kill>

BB#2: derived from LLVM BB %if.end
    Predecessors according to CFG: BB#0
        RETQ


To reproduce this problem, compile the test case shown in the bottom with the
command:

clang++ -O2 test.C -c -mllvm -debug 2>&1  | grep "unanalyzable fallthrough"


You will see the message:

Pre-merging due to unanalyzable fallthrough: BB#0 (derived from LLVM BB
'entry') -> BB#1 (derived from LLVM BB 'if.then')


which is emitted from lib/CodeGen/MachineBlockPlacement.cpp.


The test case:


#include <stdio.h>

void foo(float f) {
  if (f != 0)
    printf("*");
}</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>