<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 --- - Different IR if intermediate variable used for fcmp + select"
   href="http://llvm.org/bugs/show_bug.cgi?id=21610">21610</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Different IR if intermediate variable used for fcmp + select
          </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>Matthew.Arsenault@amd.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>I expect these 2 functions to produce the same optimized IR, but they currently
end up using a different fcmp type.


float max_uge_f32_0(float a, float b)
{
    bool cmp = !(a < b);
    return cmp ? b : a;
}

float max_uge_f32_2(float a, float b)
{
    return !(a < b) ? b : a;
}


clang -O3 for this produces:


define float @max_uge_f32_0(float %a, float %b) #0 {
  %1 = fcmp uge float %a, %b
  %2 = select i1 %1, float %b, float %a
  ret float %2
}

define float @max_uge_f32_2(float %a, float %b) #0 {
  %1 = fcmp olt float %a, %b
  %2 = select i1 %1, float %a, float %b
  ret float %2
}

I expect the second's results for the first, swapping the select operands and
using the ordered comparison. However, the first version is using the original
select order with the unordered compare.</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>