aboutsummaryrefslogtreecommitdiffstats
path: root/test/CodeGen/X86/jump_sign.ll
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-05-01 17:16:15 +0000
committerManman Ren <mren@apple.com>2012-05-01 17:16:15 +0000
commit769ea2f93fa7fdd73f8388e863cf4dc9689d2e38 (patch)
treea26f03e58df98343d7a91ec65aebad9d8dc5f8c3 /test/CodeGen/X86/jump_sign.ll
parentd07d06ceef942c478c0f75a4c4d7442e61ddff1d (diff)
downloadexternal_llvm-769ea2f93fa7fdd73f8388e863cf4dc9689d2e38.zip
external_llvm-769ea2f93fa7fdd73f8388e863cf4dc9689d2e38.tar.gz
external_llvm-769ea2f93fa7fdd73f8388e863cf4dc9689d2e38.tar.bz2
X86: optimization for max-like struct
This patch will optimize the following cases on X86 (a > b) ? (a-b) : 0 (a >= b) ? (a-b) : 0 (b < a) ? (a-b) : 0 (b <= a) ? (a-b) : 0 FROM movl %edi, %ecx subl %esi, %ecx cmpl %edi, %esi movl $0, %eax cmovll %ecx, %eax TO xorl %eax, %eax subl %esi, %edi cmovll %eax, %edi movl %edi, %eax rdar: 10734411 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/jump_sign.ll')
-rw-r--r--test/CodeGen/X86/jump_sign.ll42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/CodeGen/X86/jump_sign.ll b/test/CodeGen/X86/jump_sign.ll
index dbd133c..35f69c9 100644
--- a/test/CodeGen/X86/jump_sign.ll
+++ b/test/CodeGen/X86/jump_sign.ll
@@ -32,3 +32,45 @@ entry:
%cond = select i1 %cmp, i32 %sub, i32 0
ret i32 %cond
}
+
+; rdar://10734411
+define i32 @h(i32 %a, i32 %b) nounwind {
+entry:
+; CHECK: h:
+; CHECK-NOT: cmp
+; CHECK: cmov
+ %cmp = icmp slt i32 %b, %a
+ %sub = sub nsw i32 %a, %b
+ %cond = select i1 %cmp, i32 %sub, i32 0
+ ret i32 %cond
+}
+define i32 @i(i32 %a, i32 %b) nounwind {
+entry:
+; CHECK: i:
+; CHECK-NOT: cmp
+; CHECK: cmov
+ %cmp = icmp sgt i32 %a, %b
+ %sub = sub nsw i32 %a, %b
+ %cond = select i1 %cmp, i32 %sub, i32 0
+ ret i32 %cond
+}
+define i32 @j(i32 %a, i32 %b) nounwind {
+entry:
+; CHECK: j:
+; CHECK-NOT: cmp
+; CHECK: cmov
+ %cmp = icmp ugt i32 %a, %b
+ %sub = sub i32 %a, %b
+ %cond = select i1 %cmp, i32 %sub, i32 0
+ ret i32 %cond
+}
+define i32 @k(i32 %a, i32 %b) nounwind {
+entry:
+; CHECK: k:
+; CHECK-NOT: cmp
+; CHECK: cmov
+ %cmp = icmp ult i32 %b, %a
+ %sub = sub i32 %a, %b
+ %cond = select i1 %cmp, i32 %sub, i32 0
+ ret i32 %cond
+}