[x86] add tests for improving sbb transforms; NFC

We're subtracting X from X the hard way...

llvm-svn: 307819
This commit is contained in:
Sanjay Patel 2017-07-12 17:44:50 +00:00
parent b38045d02e
commit 6d6c06879c
1 changed files with 35 additions and 0 deletions

View File

@ -185,6 +185,41 @@ 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: xorl %eax, %eax
; CHECK-NEXT: cmpq %rdi, %rsi
; CHECK-NEXT: sbbq $0, %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: xorl %eax, %eax
; CHECK-NEXT: cmpw %di, %si
; CHECK-NEXT: sbbl $0, %eax
; CHECK-NEXT: # kill: %AX<def> %AX<kill> %EAX<kill>
; 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