<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 --- - Regression: Emits worse sequence for conditional move operation"
   href="http://llvm.org/bugs/show_bug.cgi?id=16486">16486</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Regression: Emits worse sequence for conditional move operation
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.majnemer@gmail.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>consider the following:
define i32 @_Z4blahiiii(i32 %a, i32 %b, i32 %c, i32 %d) #0 {
entry:
  %cmp = icmp sgt i32 %a, %b
  %add = add nsw i32 %a, %c
  %add1 = add nsw i32 %b, %d
  %x.0 = select i1 %cmp, i32 %add, i32 %add1
  ret i32 %x.0
}

this leaves us with:
        addl    %edi, %edx
        addl    %esi, %ecx
        cmpl    %esi, %edi
        cmovgl  %edx, %ecx
        movl    %ecx, %eax
        ret

however, if we swap around operands a bit:
define i32 @_Z4blahiiii(i32 %a, i32 %b, i32 %c, i32 %d) #0 {
entry:  
  %cmp = icmp sgt i32 %a, %b
  %add = add nsw i32 %c, %a
  %add1 = add nsw i32 %d, %b
  %x.0 = select i1 %cmp, i32 %add, i32 %add1
  ret i32 %x.0
}

we instead get:
        addl    %edi, %edx
        leal    (%rcx,%rsi), %eax
        cmpl    %esi, %edi
        cmovgl  %edx, %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>