<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 - [X86] Failure to use condition code result from promoted bitop"
   href="https://bugs.llvm.org/show_bug.cgi?id=35413">35413</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86] Failure to use condition code result from promoted bitop
          </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>Backend: X86
          </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>craig.topper@gmail.com, filcab@gmail.com, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>After promoting a OR(i16,i16) to OR(i32,i32) (with signext args), we fail to
realise that we can use the EFLAGS result from the OR to test for zero instead
of creating a separate TESTW.

short bar16();
short foo16(short a, short b) {
  if ((a | b) < 0)
    return bar16();
  return a | b; 
}

int bar32();
int foo32(int a, int b) {
  if ((a | b) < 0)
    return bar32();
  return a | b; 
}

define signext i16 @foo16(i16 signext, i16 signext) {
  %3 = or i16 %1, %0
  %4 = icmp slt i16 %3, 0
  br i1 %4, label %5, label %7

; <label>:5: ; preds = %2
  %6 = tail call signext i16 @bar16()
  br label %7

; <label>:7: ; preds = %2, %5
  %8 = phi i16 [ %6, %5 ], [ %3, %2 ]
  ret i16 %8
}
declare signext i16 @bar16()

define i32 @foo32(i32, i32) {
  %3 = or i32 %1, %0
  %4 = icmp slt i32 %3, 0
  br i1 %4, label %5, label %7

; <label>:5: ; preds = %2
  %6 = tail call i32 @bar32()
  br label %7

; <label>:7: ; preds = %2, %5
  %8 = phi i32 [ %6, %5 ], [ %3, %2 ]
  ret i32 %8
}
declare i32 @bar32()

foo16:
  orl %esi, %edi
  testw %di, %di <<- UNNECESSARY??
  je .LBB1_2
  movl %edi, %eax
  retq
.LBB1_2:
  jmp bar16()@PLT # TAILCALL

foo32:
  orl %esi, %edi
  je .LBB2_2
  movl %edi, %eax
  retq
.LBB2_2:
  jmp bar32()@PLT # TAILCALL</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>