<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 - Regression for three way min/max"
   href="https://bugs.llvm.org/show_bug.cgi?id=35717">35717</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Regression for three way min/max
          </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>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>david.green@arm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This is a regression that came in with rL320749. We have some code with three
way min/max that is now doing a lot worse than it did previously. The most
basic for I could come up with is this:

int test(int xc, int xm, int xy)
{
  int xk;
  if (xc < xm)
    xk = xc < xy ? xc : xy;
  else
    xk = xm < xy ? xm : xy;
  return xk;
}

This used to come out as (roughly "min(min(a,b),c)"):
define i32 @test(i32 %xc, i32 %xm, i32 %xy) {
entry:
  %cmp = icmp slt i32 %xc, %xm
  %xm.sink15 = select i1 %cmp, i32 %xc, i32 %xm
  %cmp2 = icmp slt i32 %xm.sink15, %xy
  %cond6 = select i1 %cmp2, i32 %xm.sink15, i32 %xy
  ret i32 %cond6
}

But now ends up with extra selects (roughly "min(min(a,b), min(b,c))"):
define i32 @test(i32 %xc, i32 %xm, i32 %xy) {
entry:
  %cmp = icmp slt i32 %xc, %xm
  %cmp1 = icmp slt i32 %xc, %xy
  %cond = select i1 %cmp1, i32 %xc, i32 %xy
  %cmp2 = icmp slt i32 %xm, %xy
  %cond6 = select i1 %cmp2, i32 %xm, i32 %xy
  %xk.0 = select i1 %cmp, i32 %cond, i32 %cond6
  ret i32 %xk.0
}

The original case came from a cmy conversion, where the values were i8 (not
i32) so there is a number of zext and trunc's making things more messy. They
are also inverted (subtracted from 255). It runs especially worse on our small
thumb1 cores.</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>