xref: /llvm-project/llvm/test/CodeGen/X86/memcmp-constant.ll (revision 2f448bf509432c1a19ec46ab8cbc7353c03c6280)
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(ptr, ptr, 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  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str1, i64 4) nounwind
15  ret i32 %m
16}
17
18define i1 @length4_same_lt() nounwind {
19; CHECK-LABEL: length4_same_lt:
20; CHECK:       # %bb.0:
21; CHECK-NEXT:    xorl %eax, %eax
22; CHECK-NEXT:    retq
23  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str1, i64 4) nounwind
24  %c = icmp slt i32 %m, 0
25  ret i1 %c
26}
27
28define i1 @length4_same_gt() nounwind {
29; CHECK-LABEL: length4_same_gt:
30; CHECK:       # %bb.0:
31; CHECK-NEXT:    xorl %eax, %eax
32; CHECK-NEXT:    retq
33  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str1, i64 4) nounwind
34  %c = icmp sgt i32 %m, 0
35  ret i1 %c
36}
37
38define i1 @length4_same_le() nounwind {
39; CHECK-LABEL: length4_same_le:
40; CHECK:       # %bb.0:
41; CHECK-NEXT:    movb $1, %al
42; CHECK-NEXT:    retq
43  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str1, i64 4) nounwind
44  %c = icmp sle i32 %m, 0
45  ret i1 %c
46}
47
48define i1 @length4_same_ge() nounwind {
49; CHECK-LABEL: length4_same_ge:
50; CHECK:       # %bb.0:
51; CHECK-NEXT:    movb $1, %al
52; CHECK-NEXT:    retq
53  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str1, i64 4) nounwind
54  %c = icmp sge i32 %m, 0
55  ret i1 %c
56}
57
58
59define i32 @length4() nounwind {
60; CHECK-LABEL: length4:
61; CHECK:       # %bb.0:
62; CHECK-NEXT:    movl $-1, %eax
63; CHECK-NEXT:    retq
64  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str2, i64 4) nounwind
65  ret i32 %m
66}
67
68define i1 @length4_lt() nounwind {
69; CHECK-LABEL: length4_lt:
70; CHECK:       # %bb.0:
71; CHECK-NEXT:    movb $1, %al
72; CHECK-NEXT:    retq
73  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str2, i64 4) nounwind
74  %c = icmp slt i32 %m, 0
75  ret i1 %c
76}
77
78define i1 @length4_gt() nounwind {
79; CHECK-LABEL: length4_gt:
80; CHECK:       # %bb.0:
81; CHECK-NEXT:    xorl %eax, %eax
82; CHECK-NEXT:    retq
83  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str2, i64 4) nounwind
84  %c = icmp sgt i32 %m, 0
85  ret i1 %c
86}
87
88define i1 @length4_le() nounwind {
89; CHECK-LABEL: length4_le:
90; CHECK:       # %bb.0:
91; CHECK-NEXT:    movb $1, %al
92; CHECK-NEXT:    retq
93  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str2, i64 4) nounwind
94  %c = icmp sle i32 %m, 0
95  ret i1 %c
96}
97
98define i1 @length4_ge() nounwind {
99; CHECK-LABEL: length4_ge:
100; CHECK:       # %bb.0:
101; CHECK-NEXT:    xorl %eax, %eax
102; CHECK-NEXT:    retq
103  %m = tail call i32 @memcmp(ptr @.str1, ptr @.str2, i64 4) nounwind
104  %c = icmp sge i32 %m, 0
105  ret i1 %c
106}
107
108
109