• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
10declare i32 @memcmp(...)
11
12define void @memcmp2(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
13entry:
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
18bb:                                               ; preds = %entry
19  store i32 4, i32* %P, align 4
20  ret void
21
22return:                                           ; preds = %entry
23  ret void
24; CHECK-LABEL: memcmp2:
25; CHECK: movzwl
26; CHECK-NEXT: cmpw
27; NOBUILTIN-LABEL: memcmp2:
28; NOBUILTIN: callq
29}
30
31define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind {
32entry:
33  %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]
34  %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
35  br i1 %1, label %return, label %bb
36
37bb:                                               ; preds = %entry
38  store i32 4, i32* %P, align 4
39  ret void
40
41return:                                           ; preds = %entry
42  ret void
43; CHECK-LABEL: memcmp2a:
44; CHECK: movzwl
45; CHECK-NEXT: cmpl    $28527,
46}
47
48define void @memcmp2nb(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
49entry:
50  %0 = tail call i32 (...) @memcmp(i8* %X, i8* %Y, i32 2) nounwind nobuiltin ; <i32> [#uses=1]
51  %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
52  br i1 %1, label %return, label %bb
53
54bb:                                               ; preds = %entry
55  store i32 4, i32* %P, align 4
56  ret void
57
58return:                                           ; preds = %entry
59  ret void
60; CHECK-LABEL: memcmp2nb:
61; CHECK: callq
62}
63
64define void @memcmp4(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
65entry:
66  %0 = tail call i32 (...) @memcmp(i8* %X, i8* %Y, i32 4) nounwind ; <i32> [#uses=1]
67  %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
68  br i1 %1, label %return, label %bb
69
70bb:                                               ; preds = %entry
71  store i32 4, i32* %P, align 4
72  ret void
73
74return:                                           ; preds = %entry
75  ret void
76; CHECK-LABEL: memcmp4:
77; CHECK: movl
78; CHECK-NEXT: cmpl
79}
80
81define void @memcmp4a(i8* %X, i32* nocapture %P) nounwind {
82entry:
83  %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]
84  %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
85  br i1 %1, label %return, label %bb
86
87bb:                                               ; preds = %entry
88  store i32 4, i32* %P, align 4
89  ret void
90
91return:                                           ; preds = %entry
92  ret void
93; CHECK-LABEL: memcmp4a:
94; CHECK: cmpl $1869573999,
95}
96
97define void @memcmp8(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
98entry:
99  %0 = tail call i32 (...) @memcmp(i8* %X, i8* %Y, i32 8) nounwind ; <i32> [#uses=1]
100  %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
101  br i1 %1, label %return, label %bb
102
103bb:                                               ; preds = %entry
104  store i32 4, i32* %P, align 4
105  ret void
106
107return:                                           ; preds = %entry
108  ret void
109; CHECK-LABEL: memcmp8:
110; CHECK: movq
111; CHECK: cmpq
112}
113
114define void @memcmp8a(i8* %X, i32* nocapture %P) nounwind {
115entry:
116  %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]
117  %1 = icmp eq i32 %0, 0                          ; <i1> [#uses=1]
118  br i1 %1, label %return, label %bb
119
120bb:                                               ; preds = %entry
121  store i32 4, i32* %P, align 4
122  ret void
123
124return:                                           ; preds = %entry
125  ret void
126; CHECK-LABEL: memcmp8a:
127; CHECK: movabsq $8029759185026510694,
128; CHECK: cmpq
129}
130
131