1 ; RUN: llc %s -o - -march=x86-64 | FileCheck %s
3 ; This tests codegen time inlining/optimization of memcmp
6 @.str = private constant [23 x i8] c"fooooooooooooooooooooo\00", align 1 ; <[23 x i8]*> [#uses=1]
8 declare i32 @memcmp(...)
10 define void @memcmp2(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
12 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 2) nounwind ; <i32> [#uses=1]
13 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
14 br i1 %1, label %return, label %bb
17 store i32 4, i32* %P, align 4
20 return: ; preds = %entry
23 ; CHECK: movw (%rdi), %ax
24 ; CHECK: cmpw (%rsi), %ax
27 define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind {
29 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 1), i32 2) nounwind ; <i32> [#uses=1]
30 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
31 br i1 %1, label %return, label %bb
34 store i32 4, i32* %P, align 4
37 return: ; preds = %entry
40 ; CHECK: cmpw $28527, (%rdi)
44 define void @memcmp4(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
46 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 4) nounwind ; <i32> [#uses=1]
47 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
48 br i1 %1, label %return, label %bb
51 store i32 4, i32* %P, align 4
54 return: ; preds = %entry
57 ; CHECK: movl (%rdi), %eax
58 ; CHECK: cmpl (%rsi), %eax
61 define void @memcmp4a(i8* %X, i32* nocapture %P) nounwind {
63 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 1), i32 4) nounwind ; <i32> [#uses=1]
64 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
65 br i1 %1, label %return, label %bb
68 store i32 4, i32* %P, align 4
71 return: ; preds = %entry
74 ; CHECK: cmpl $1869573999, (%rdi)
77 define void @memcmp8(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
79 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 8) nounwind ; <i32> [#uses=1]
80 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
81 br i1 %1, label %return, label %bb
84 store i32 4, i32* %P, align 4
87 return: ; preds = %entry
90 ; CHECK: movq (%rdi), %rax
91 ; CHECK: cmpq (%rsi), %rax
94 define void @memcmp8a(i8* %X, i32* nocapture %P) nounwind {
96 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 0), i32 8) nounwind ; <i32> [#uses=1]
97 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
98 br i1 %1, label %return, label %bb
101 store i32 4, i32* %P, align 4
104 return: ; preds = %entry
107 ; CHECK: movabsq $8029759185026510694, %rax
108 ; CHECK: cmpq %rax, (%rdi)