<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 - Failed to combine -smax(-x,-y) to smin(x,y)"
   href="https://bugs.llvm.org/show_bug.cgi?id=43310">43310</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Failed to combine -smax(-x,-y) to smin(x,y)
          </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>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>llvm-dev@redking.me.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>lebedev.ri@gmail.com, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Noticed while investigating [<a class="bz_bug_link 
          bz_status_CONFIRMED "
   title="CONFIRMED - [DAGCombine] Convert isNegatibleForFree/GetNegatedExpression to a target hook"
   href="show_bug.cgi?id=42863">Bug #42863</a>] - its a rare case where we do better
on float than integer!

Current codegen: <a href="https://gcc.godbolt.org/z/epgWrG">https://gcc.godbolt.org/z/epgWrG</a>

auto min_f32(float x, float y) {
    return std::min(x, y);
}
auto neg_max_f32(float x, float y) {
    return -std::max(-x, -y);
}

auto min_s32(int x, int y) {
    return std::min(x, y);
}
auto neg_max_s32(int x, int y) {
    return -std::max(-x, -y);
}

min_f32(float, float):
        vminss  %xmm0, %xmm1, %xmm0
        retq
neg_max_f32(float, float):
        vminss  %xmm0, %xmm1, %xmm0
        retq
min_s32(int, int):
        movl    %edi, %eax
        cmpl    %edi, %esi
        cmovlel %esi, %eax
        retq
neg_max_s32(int, int):
        movl    %esi, %eax
        negl    %edi
        negl    %eax
        cmpl    %eax, %edi
        cmovgel %edi, %eax
        negl    %eax
        retq

vs gcc:

min_f32(float, float):
        vminss  %xmm0, %xmm1, %xmm0
        ret
neg_max_f32(float, float):
        vminss  %xmm0, %xmm1, %xmm0
        ret
min_s32(int, int):
        cmpl    %edi, %esi
        movl    %edi, %eax
        cmovle  %esi, %eax
        ret
neg_max_s32(int, int):
        cmpl    %esi, %edi
        movl    %esi, %eax
        cmovle  %edi, %eax
        ret</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>