1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-unknown               | FileCheck %s
3
4@.str1 = private constant [4 x i8] c"\00\00\00\00", align 1
5@.str2 = private constant [4 x i8] c"\ff\ff\ff\ff", align 1
6
7declare i32 @memcmp(i8*, i8*, i64)
8
9define i32 @length4_same() nounwind {
10; CHECK-LABEL: length4_same:
11; CHECK:       # %bb.0:
12; CHECK-NEXT:    xorl %eax, %eax
13; CHECK-NEXT:    retq
14  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
15  %m = tail call i32 @memcmp(i8* %s1, i8* %s1, i64 4) nounwind
16  ret i32 %m
17}
18
19define i1 @length4_same_lt() nounwind {
20; CHECK-LABEL: length4_same_lt:
21; CHECK:       # %bb.0:
22; CHECK-NEXT:    xorl %eax, %eax
23; CHECK-NEXT:    retq
24  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
25  %m = tail call i32 @memcmp(i8* %s1, i8* %s1, i64 4) nounwind
26  %c = icmp slt i32 %m, 0
27  ret i1 %c
28}
29
30define i1 @length4_same_gt() nounwind {
31; CHECK-LABEL: length4_same_gt:
32; CHECK:       # %bb.0:
33; CHECK-NEXT:    xorl %eax, %eax
34; CHECK-NEXT:    retq
35  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
36  %m = tail call i32 @memcmp(i8* %s1, i8* %s1, i64 4) nounwind
37  %c = icmp sgt i32 %m, 0
38  ret i1 %c
39}
40
41define i1 @length4_same_le() nounwind {
42; CHECK-LABEL: length4_same_le:
43; CHECK:       # %bb.0:
44; CHECK-NEXT:    movb $1, %al
45; CHECK-NEXT:    retq
46  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
47  %m = tail call i32 @memcmp(i8* %s1, i8* %s1, i64 4) nounwind
48  %c = icmp sle i32 %m, 0
49  ret i1 %c
50}
51
52define i1 @length4_same_ge() nounwind {
53; CHECK-LABEL: length4_same_ge:
54; CHECK:       # %bb.0:
55; CHECK-NEXT:    movb $1, %al
56; CHECK-NEXT:    retq
57  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
58  %m = tail call i32 @memcmp(i8* %s1, i8* %s1, i64 4) nounwind
59  %c = icmp sge i32 %m, 0
60  ret i1 %c
61}
62
63
64define i32 @length4() nounwind {
65; CHECK-LABEL: length4:
66; CHECK:       # %bb.0:
67; CHECK-NEXT:    movl $-1, %eax
68; CHECK-NEXT:    retq
69  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
70  %s2 = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
71  %m = tail call i32 @memcmp(i8* %s1, i8* %s2, i64 4) nounwind
72  ret i32 %m
73}
74
75define i1 @length4_lt() nounwind {
76; CHECK-LABEL: length4_lt:
77; CHECK:       # %bb.0:
78; CHECK-NEXT:    movb $1, %al
79; CHECK-NEXT:    retq
80  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
81  %s2 = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
82  %m = tail call i32 @memcmp(i8* %s1, i8* %s2, i64 4) nounwind
83  %c = icmp slt i32 %m, 0
84  ret i1 %c
85}
86
87define i1 @length4_gt() nounwind {
88; CHECK-LABEL: length4_gt:
89; CHECK:       # %bb.0:
90; CHECK-NEXT:    xorl %eax, %eax
91; CHECK-NEXT:    retq
92  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
93  %s2 = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
94  %m = tail call i32 @memcmp(i8* %s1, i8* %s2, i64 4) nounwind
95  %c = icmp sgt i32 %m, 0
96  ret i1 %c
97}
98
99define i1 @length4_le() nounwind {
100; CHECK-LABEL: length4_le:
101; CHECK:       # %bb.0:
102; CHECK-NEXT:    movb $1, %al
103; CHECK-NEXT:    retq
104  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
105  %s2 = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
106  %m = tail call i32 @memcmp(i8* %s1, i8* %s2, i64 4) nounwind
107  %c = icmp sle i32 %m, 0
108  ret i1 %c
109}
110
111define i1 @length4_ge() nounwind {
112; CHECK-LABEL: length4_ge:
113; CHECK:       # %bb.0:
114; CHECK-NEXT:    xorl %eax, %eax
115; CHECK-NEXT:    retq
116  %s1 = getelementptr inbounds [4 x i8], [4 x i8]* @.str1, i32 0, i32 0
117  %s2 = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
118  %m = tail call i32 @memcmp(i8* %s1, i8* %s2, i64 4) nounwind
119  %c = icmp sge i32 %m, 0
120  ret i1 %c
121}
122
123
124