[opaque pointer type] Add textual IR support for explicit type parameter to the call...
[oota-llvm.git] / test / CodeGen / X86 / memcmp.ll
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: movzwl
26 ; CHECK-NEXT: movzwl
27 ; CHECK-NEXT: cmpl
28 ; NOBUILTIN-LABEL: memcmp2:
29 ; NOBUILTIN: callq
30 }
31
32 define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind {
33 entry:
34   %0 = tail call i32 (...) @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 1), i32 2) nounwind ; <i32> [#uses=1]
35   %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
36   br i1 %1, label %return, label %bb
37
38 bb:                                               ; preds = %entry
39   store i32 4, i32* %P, align 4
40   ret void
41
42 return:                                           ; preds = %entry
43   ret void
44 ; CHECK-LABEL: memcmp2a:
45 ; CHECK: movzwl
46 ; CHECK-NEXT: cmpl    $28527,
47 }
48
49
50 define void @memcmp4(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
51 entry:
52   %0 = tail call i32 (...) @memcmp(i8* %X, i8* %Y, i32 4) nounwind ; <i32> [#uses=1]
53   %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
54   br i1 %1, label %return, label %bb
55
56 bb:                                               ; preds = %entry
57   store i32 4, i32* %P, align 4
58   ret void
59
60 return:                                           ; preds = %entry
61   ret void
62 ; CHECK-LABEL: memcmp4:
63 ; CHECK: movl
64 ; CHECK-NEXT: cmpl
65 }
66
67 define void @memcmp4a(i8* %X, i32* nocapture %P) nounwind {
68 entry:
69   %0 = tail call i32 (...) @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 1), i32 4) nounwind ; <i32> [#uses=1]
70   %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
71   br i1 %1, label %return, label %bb
72
73 bb:                                               ; preds = %entry
74   store i32 4, i32* %P, align 4
75   ret void
76
77 return:                                           ; preds = %entry
78   ret void
79 ; CHECK-LABEL: memcmp4a:
80 ; CHECK: cmpl $1869573999,
81 }
82
83 define void @memcmp8(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
84 entry:
85   %0 = tail call i32 (...) @memcmp(i8* %X, i8* %Y, i32 8) nounwind ; <i32> [#uses=1]
86   %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
87   br i1 %1, label %return, label %bb
88
89 bb:                                               ; preds = %entry
90   store i32 4, i32* %P, align 4
91   ret void
92
93 return:                                           ; preds = %entry
94   ret void
95 ; CHECK-LABEL: memcmp8:
96 ; CHECK: movq
97 ; CHECK: cmpq
98 }
99
100 define void @memcmp8a(i8* %X, i32* nocapture %P) nounwind {
101 entry:
102   %0 = tail call i32 (...) @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), i32 8) nounwind ; <i32> [#uses=1]
103   %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
104   br i1 %1, label %return, label %bb
105
106 bb:                                               ; preds = %entry
107   store i32 4, i32* %P, align 4
108   ret void
109
110 return:                                           ; preds = %entry
111   ret void
112 ; CHECK-LABEL: memcmp8a:
113 ; CHECK: movabsq $8029759185026510694,
114 ; CHECK: cmpq
115 }
116