https://bugs.llvm.org/show_bug.cgi?id=35413

            Bug ID: 35413
           Summary: [X86] Failure to use condition code result from
                    promoted bitop
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedb...@nondot.org
          Reporter: llvm-...@redking.me.uk
                CC: craig.top...@gmail.com, fil...@gmail.com,
                    llvm-bugs@lists.llvm.org, spatel+l...@rotateright.com

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to