<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 - /fp in CL-compat does not produce OrderedCompares"
   href="https://bugs.llvm.org/show_bug.cgi?id=37340">37340</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>/fp in CL-compat does not produce OrderedCompares
          </td>
        </tr>

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

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>alexandre.ganea@ubisoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The behavior between MSVC cl.exe and clang, in regards to the /fp flag, seems
to be different when comparing NaNs.

Consider:

// a.cpp
int main() {
    unsigned long a = 0xffc00000; // -Nan
    float f = *(float*)&a;
    if (f <= -1.f)
        return 1;
    return 0;
}

(MSVC) cl.exe a.cpp /arch:AVX2 /Z7 /fp:fast

    if (f <= -1.f)
00007FF6EA036586  vmovss      xmm0,dword ptr [f]  
00007FF6EA03658C  vcomiss     xmm0,dword ptr [__real@bf800000 (07FF6EA094F10h)] 
00007FF6EA036594  ja          main+2Dh (07FF6EA03659Dh)  

(MSVC) cl.exe a.cpp /arch:AVX2 /Z7 /fp:precise

    if (f <= -1.f)
00007FF70AF06586  vmovss      xmm0,dword ptr [__real@bf800000 (07FF70AF64F10h)] 
00007FF70AF0658E  vcomiss     xmm0,dword ptr [f]  
00007FF70AF06594  jb          main+2Dh (07FF70AF0659Dh) 

(Clang) clang-cl.exe a.cpp /arch:AVX2 /Z7 /fp:fast

    if (f <= -1.f)
00007FF7DAAF6598  vucomiss    xmm0,dword ptr [f]  
00007FF7DAAF659E  jb          main+41h (07FF7DAAF65B1h)  

(Clang) clang-cl.exe a.cpp /arch:AVX2 /Z7 /fp:precise

    if (f <= -1.f)
00007FF7DAAF6598  vucomiss    xmm0,dword ptr [f]  
00007FF7DAAF659E  jb          main+41h (07FF7DAAF65B1h)  
   (same as above)

Actually, no matter which /fp: or -f*math* you pass to clang, the result is the
same (when using the clang-cl driver). As you can see, Clang generates
'ucomiss' instructions in all cases, instead of 'comiss' as in cl.exe. Omiting
/arch:AVX2 gives the same result.

I am at r331502.</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>