comparison test/CodeGen/X86/memcmp.ll @ 0:95c75e76d11b LLVM3.4

LLVM 3.4
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Thu, 12 Dec 2013 13:56:28 +0900
parents
children e4204d083e25
comparison
equal deleted inserted replaced
-1:000000000000 0:95c75e76d11b
1 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s
2 ; RUN: llc < %s -disable-simplify-libcalls -mtriple=x86_64-linux | FileCheck %s --check-prefix=NOBUILTIN
3 ; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s
4
5 ; This tests codegen time inlining/optimization of memcmp
6 ; rdar://6480398
7
8 @.str = private constant [23 x i8] c"fooooooooooooooooooooo\00", align 1 ; <[23 x i8]*> [#uses=1]
9
10 declare i32 @memcmp(...)
11
12 define void @memcmp2(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
13 entry:
14 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 2) nounwind ; <i32> [#uses=1]
15 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
16 br i1 %1, label %return, label %bb
17
18 bb: ; preds = %entry
19 store i32 4, i32* %P, align 4
20 ret void
21
22 return: ; preds = %entry
23 ret void
24 ; CHECK-LABEL: memcmp2:
25 ; CHECK: movw ([[A0:%rdi|%rcx]]), %ax
26 ; CHECK: cmpw ([[A1:%rsi|%rdx]]), %ax
27 ; NOBUILTIN-LABEL: memcmp2:
28 ; NOBUILTIN: callq
29 }
30
31 define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind {
32 entry:
33 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 1), i32 2) nounwind ; <i32> [#uses=1]
34 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
35 br i1 %1, label %return, label %bb
36
37 bb: ; preds = %entry
38 store i32 4, i32* %P, align 4
39 ret void
40
41 return: ; preds = %entry
42 ret void
43 ; CHECK-LABEL: memcmp2a:
44 ; CHECK: cmpw $28527, ([[A0]])
45 }
46
47
48 define void @memcmp4(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
49 entry:
50 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 4) nounwind ; <i32> [#uses=1]
51 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
52 br i1 %1, label %return, label %bb
53
54 bb: ; preds = %entry
55 store i32 4, i32* %P, align 4
56 ret void
57
58 return: ; preds = %entry
59 ret void
60 ; CHECK-LABEL: memcmp4:
61 ; CHECK: movl ([[A0]]), %eax
62 ; CHECK: cmpl ([[A1]]), %eax
63 }
64
65 define void @memcmp4a(i8* %X, i32* nocapture %P) nounwind {
66 entry:
67 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 1), i32 4) nounwind ; <i32> [#uses=1]
68 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
69 br i1 %1, label %return, label %bb
70
71 bb: ; preds = %entry
72 store i32 4, i32* %P, align 4
73 ret void
74
75 return: ; preds = %entry
76 ret void
77 ; CHECK-LABEL: memcmp4a:
78 ; CHECK: cmpl $1869573999, ([[A0]])
79 }
80
81 define void @memcmp8(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
82 entry:
83 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 8) nounwind ; <i32> [#uses=1]
84 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
85 br i1 %1, label %return, label %bb
86
87 bb: ; preds = %entry
88 store i32 4, i32* %P, align 4
89 ret void
90
91 return: ; preds = %entry
92 ret void
93 ; CHECK-LABEL: memcmp8:
94 ; CHECK: movq ([[A0]]), %rax
95 ; CHECK: cmpq ([[A1]]), %rax
96 }
97
98 define void @memcmp8a(i8* %X, i32* nocapture %P) nounwind {
99 entry:
100 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 0), i32 8) nounwind ; <i32> [#uses=1]
101 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
102 br i1 %1, label %return, label %bb
103
104 bb: ; preds = %entry
105 store i32 4, i32* %P, align 4
106 ret void
107
108 return: ; preds = %entry
109 ret void
110 ; CHECK-LABEL: memcmp8a:
111 ; CHECK: movabsq $8029759185026510694, %rax
112 ; CHECK: cmpq %rax, ([[A0]])
113 }
114