[llvm] r306337 - [x86] add tests for missing sbb transforms; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 15:20:07 PDT 2017
Author: spatel
Date: Mon Jun 26 15:20:07 2017
New Revision: 306337
URL: http://llvm.org/viewvc/llvm-project?rev=306337&view=rev
Log:
[x86] add tests for missing sbb transforms; NFC
Modified:
llvm/trunk/test/CodeGen/X86/sbb.ll
Modified: llvm/trunk/test/CodeGen/X86/sbb.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sbb.ll?rev=306337&r1=306336&r2=306337&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sbb.ll (original)
+++ llvm/trunk/test/CodeGen/X86/sbb.ll Mon Jun 26 15:20:07 2017
@@ -111,6 +111,86 @@ define i8 @i8_select_neg1_or_0_commuted_
ret i8 %add
}
+; (X <u Y) ? -1 : 0 --> cmp, sbb
+
+define i32 @ult_select_neg1_or_0(i32 %x, i32 %y) nounwind {
+; CHECK-LABEL: ult_select_neg1_or_0:
+; CHECK: # BB#0:
+; CHECK-NEXT: cmpl %esi, %edi
+; CHECK-NEXT: sbbl %eax, %eax
+; CHECK-NEXT: retq
+ %cmp = icmp ult i32 %x, %y
+ %ext = sext i1 %cmp to i32
+ ret i32 %ext
+}
+
+; Swap the predicate and compare operands:
+; (Y >u X) ? -1 : 0 --> cmp, sbb
+
+define i32 @ugt_select_neg1_or_0(i32 %x, i32 %y) nounwind {
+; CHECK-LABEL: ugt_select_neg1_or_0:
+; CHECK: # BB#0:
+; CHECK-NEXT: xorl %ecx, %ecx
+; CHECK-NEXT: cmpl %edi, %esi
+; CHECK-NEXT: movl $-1, %eax
+; CHECK-NEXT: cmovbel %ecx, %eax
+; CHECK-NEXT: retq
+ %cmp = icmp ugt i32 %y, %x
+ %ext = sext i1 %cmp to i32
+ ret i32 %ext
+}
+
+; Invert the predicate and effectively swap the select operands:
+; (X >=u Y) ? 0 : -1 --> (X <u Y) ? -1 : 0 --> cmp, sbb
+
+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: retq
+ %cmp = icmp uge i32 %x, %y
+ %ext = zext i1 %cmp to i32
+ %add = add i32 %ext, -1
+ ret i32 %add
+}
+
+; Swap the predicate and compare operands:
+; (Y <=u X) ? 0 : -1 --> (X <u Y) ? -1 : 0 --> cmp, sbb
+
+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: retq
+ %cmp = icmp ule i32 %y, %x
+ %ext = zext i1 %cmp to i32
+ %add = add i32 %ext, -1
+ ret i32 %add
+}
+
+; Verify that subtract with constant is the same thing.
+; (X >=u Y) ? 0 : -1 --> (X <u Y) ? -1 : 0 --> cmp, sbb
+
+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: retq
+ %cmp = icmp uge i32 %x, %y
+ %ext = zext i1 %cmp to i32
+ %sub = sub i32 %ext, 1
+ ret i32 %sub
+}
+
; Make sure we're creating nodes with the right value types. This would crash.
; https://bugs.llvm.org/show_bug.cgi?id=33560
More information about the llvm-commits
mailing list