diff options
Diffstat (limited to 'test/CodeGen/X86/sbb.ll')
| -rw-r--r-- | test/CodeGen/X86/sbb.ll | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/test/CodeGen/X86/sbb.ll b/test/CodeGen/X86/sbb.ll index 414780b2d4e6..b6e8ebf6ed06 100644 --- a/test/CodeGen/X86/sbb.ll +++ b/test/CodeGen/X86/sbb.ll @@ -146,10 +146,8 @@ define i32 @ugt_select_neg1_or_0(i32 %x, i32 %y) nounwind { define i32 @uge_select_0_or_neg1(i32 %x, i32 %y) nounwind { ; CHECK-LABEL: uge_select_0_or_neg1: ; CHECK: # BB#0: -; CHECK-NEXT: xorl %eax, %eax ; CHECK-NEXT: cmpl %esi, %edi -; CHECK-NEXT: setae %al -; CHECK-NEXT: decl %eax +; CHECK-NEXT: sbbl %eax, %eax ; CHECK-NEXT: retq %cmp = icmp uge i32 %x, %y %ext = zext i1 %cmp to i32 @@ -163,10 +161,8 @@ define i32 @uge_select_0_or_neg1(i32 %x, i32 %y) nounwind { define i32 @ule_select_0_or_neg1(i32 %x, i32 %y) nounwind { ; CHECK-LABEL: ule_select_0_or_neg1: ; CHECK: # BB#0: -; CHECK-NEXT: xorl %eax, %eax -; CHECK-NEXT: cmpl %edi, %esi -; CHECK-NEXT: setbe %al -; CHECK-NEXT: decl %eax +; CHECK-NEXT: cmpl %esi, %edi +; CHECK-NEXT: sbbl %eax, %eax ; CHECK-NEXT: retq %cmp = icmp ule i32 %y, %x %ext = zext i1 %cmp to i32 @@ -180,10 +176,8 @@ define i32 @ule_select_0_or_neg1(i32 %x, i32 %y) nounwind { define i32 @uge_select_0_or_neg1_sub(i32 %x, i32 %y) nounwind { ; CHECK-LABEL: uge_select_0_or_neg1_sub: ; CHECK: # BB#0: -; CHECK-NEXT: xorl %eax, %eax ; CHECK-NEXT: cmpl %esi, %edi -; CHECK-NEXT: setae %al -; CHECK-NEXT: decl %eax +; CHECK-NEXT: sbbl %eax, %eax ; CHECK-NEXT: retq %cmp = icmp uge i32 %x, %y %ext = zext i1 %cmp to i32 @@ -191,6 +185,38 @@ define i32 @uge_select_0_or_neg1_sub(i32 %x, i32 %y) nounwind { ret i32 %sub } +; Check more sub-from-zero patterns. +; (X >u Y) ? -1 : 0 --> cmp, sbb + +define i64 @ugt_select_neg1_or_0_sub(i64 %x, i64 %y) nounwind { +; CHECK-LABEL: ugt_select_neg1_or_0_sub: +; CHECK: # BB#0: +; CHECK-NEXT: cmpq %rdi, %rsi +; CHECK-NEXT: sbbq %rax, %rax +; CHECK-NEXT: retq + %cmp = icmp ugt i64 %x, %y + %zext = zext i1 %cmp to i64 + %sub = sub i64 0, %zext + ret i64 %sub +} + +; Swap the predicate and compare operands: +; (Y <u X) ? -1 : 0 --> cmp, sbb + +define i16 @ult_select_neg1_or_0_sub(i16 %x, i16 %y) nounwind { +; CHECK-LABEL: ult_select_neg1_or_0_sub: +; CHECK: # BB#0: +; CHECK-NEXT: cmpw %di, %si +; CHECK-NEXT: sbbw %ax, %ax +; CHECK-NEXT: retq + %cmp = icmp ult i16 %y, %x + %zext = zext i1 %cmp to i16 + %sub = sub i16 0, %zext + ret i16 %sub +} + + + ; Make sure we're creating nodes with the right value types. This would crash. ; https://bugs.llvm.org/show_bug.cgi?id=33560 |
