1 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s 2 ; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s 3 4 ; This tests codegen time inlining/optimization of memcmp 5 ; rdar://6480398 6 7 @.str = private constant [23 x i8] c"fooooooooooooooooooooo\00", align 1 ; <[23 x i8]*> [#uses=1] 8 9 declare i32 @memcmp(...) 10 11 define void @memcmp2(i8* %X, i8* %Y, i32* nocapture %P) nounwind { 12 entry: 13 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 2) nounwind ; <i32> [#uses=1] 14 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] 15 br i1 %1, label %return, label %bb 16 17 bb: ; preds = %entry 18 store i32 4, i32* %P, align 4 19 ret void 20 21 return: ; preds = %entry 22 ret void 23 ; CHECK: memcmp2: 24 ; CHECK: movw ([[A0:%rdi|%rcx]]), %ax 25 ; CHECK: cmpw ([[A1:%rsi|%rdx]]), %ax 26 } 27 28 define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind { 29 entry: 30 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 1), i32 2) nounwind ; <i32> [#uses=1] 31 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] 32 br i1 %1, label %return, label %bb 33 34 bb: ; preds = %entry 35 store i32 4, i32* %P, align 4 36 ret void 37 38 return: ; preds = %entry 39 ret void 40 ; CHECK: memcmp2a: 41 ; CHECK: cmpw $28527, ([[A0]]) 42 } 43 44 45 define void @memcmp4(i8* %X, i8* %Y, i32* nocapture %P) nounwind { 46 entry: 47 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 4) nounwind ; <i32> [#uses=1] 48 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] 49 br i1 %1, label %return, label %bb 50 51 bb: ; preds = %entry 52 store i32 4, i32* %P, align 4 53 ret void 54 55 return: ; preds = %entry 56 ret void 57 ; CHECK: memcmp4: 58 ; CHECK: movl ([[A0]]), %eax 59 ; CHECK: cmpl ([[A1]]), %eax 60 } 61 62 define void @memcmp4a(i8* %X, i32* nocapture %P) nounwind { 63 entry: 64 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 1), i32 4) nounwind ; <i32> [#uses=1] 65 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] 66 br i1 %1, label %return, label %bb 67 68 bb: ; preds = %entry 69 store i32 4, i32* %P, align 4 70 ret void 71 72 return: ; preds = %entry 73 ret void 74 ; CHECK: memcmp4a: 75 ; CHECK: cmpl $1869573999, ([[A0]]) 76 } 77 78 define void @memcmp8(i8* %X, i8* %Y, i32* nocapture %P) nounwind { 79 entry: 80 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* %Y, i32 8) nounwind ; <i32> [#uses=1] 81 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] 82 br i1 %1, label %return, label %bb 83 84 bb: ; preds = %entry 85 store i32 4, i32* %P, align 4 86 ret void 87 88 return: ; preds = %entry 89 ret void 90 ; CHECK: memcmp8: 91 ; CHECK: movq ([[A0]]), %rax 92 ; CHECK: cmpq ([[A1]]), %rax 93 } 94 95 define void @memcmp8a(i8* %X, i32* nocapture %P) nounwind { 96 entry: 97 %0 = tail call i32 (...)* @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8]* @.str, i32 0, i32 0), i32 8) nounwind ; <i32> [#uses=1] 98 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1] 99 br i1 %1, label %return, label %bb 100 101 bb: ; preds = %entry 102 store i32 4, i32* %P, align 4 103 ret void 104 105 return: ; preds = %entry 106 ret void 107 ; CHECK: memcmp8a: 108 ; CHECK: movabsq $8029759185026510694, %rax 109 ; CHECK: cmpq %rax, ([[A0]]) 110 } 111 112