1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=core2 | FileCheck %s -check-prefix=LINUX
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=DARWIN
4 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
5 declare void @llvm.memcpy.p256i8.p256i8.i64(i8 addrspace(256)* nocapture, i8 addrspace(256)* nocapture, i64, i1) nounwind
8 ; Variable memcpy's should lower to calls.
9 define i8* @test1(i8* %a, i8* %b, i64 %n) nounwind {
11 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* %b, i64 %n, i1 0 )
18 ; Variable memcpy's should lower to calls.
19 define i8* @test2(i64* %a, i64* %b, i64 %n) nounwind {
21 %tmp14 = bitcast i64* %a to i8*
22 %tmp25 = bitcast i64* %b to i8*
23 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %tmp14, i8* align 8 %tmp25, i64 %n, i1 0 )
30 ; Large constant memcpy's should lower to a call when optimizing for size.
33 ; On the other hand, Darwin's definition of -Os is optimizing for size without
34 ; hurting performance so it should just ignore optsize when expanding memcpy.
36 define void @test3(i8* nocapture %A, i8* nocapture %B) nounwind optsize noredzone {
38 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i1 false)
43 ; DARWIN-LABEL: test3:
63 define void @test3_minsize(i8* nocapture %A, i8* nocapture %B) nounwind minsize noredzone {
64 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i1 false)
66 ; LINUX-LABEL: test3_minsize:
69 ; DARWIN-LABEL: test3_minsize:
73 define void @test3_minsize_optsize(i8* nocapture %A, i8* nocapture %B) nounwind optsize minsize noredzone {
74 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i1 false)
76 ; LINUX-LABEL: test3_minsize_optsize:
79 ; DARWIN-LABEL: test3_minsize_optsize:
83 ; Large constant memcpy's should be inlined when not optimizing for size.
84 define void @test4(i8* nocapture %A, i8* nocapture %B) nounwind noredzone {
86 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i1 false)
104 @.str = private unnamed_addr constant [30 x i8] c"\00aaaaaaaaaaaaaaaaaaaaaaaaaaaa\00", align 1
106 define void @test5(i8* nocapture %C) nounwind uwtable ssp {
108 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %C, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 16, i1 false)
111 ; DARWIN-LABEL: test5:
112 ; DARWIN: movabsq $7016996765293437281
113 ; DARWIN: movabsq $7016996765293437184
118 @.str2 = private unnamed_addr constant [2 x i8] c"x\00", align 1
120 define void @test6() nounwind uwtable {
124 ; DARWIN: movq $120, 0
125 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str2, i64 0, i64 0), i64 10, i1 false)
129 define void @PR15348(i8* %a, i8* %b) {
130 ; Ensure that alignment of '0' in an @llvm.memcpy intrinsic results in
131 ; unaligned loads and stores.
139 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* %b, i64 17, i1 false)
143 ; Memcpys from / to address space 256 should be lowered to appropriate loads /
144 ; stores if small enough.
145 define void @addrspace256(i8 addrspace(256)* %a, i8 addrspace(256)* %b) nounwind {
146 tail call void @llvm.memcpy.p256i8.p256i8.i64(i8 addrspace(256)* align 8 %a, i8 addrspace(256)* align 8 %b, i64 16, i1 false)
148 ; LINUX-LABEL: addrspace256:
151 ; LINUX: movq {{.*}}, %gs:
152 ; LINUX: movq {{.*}}, %gs: