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 3 4declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind 5 6 7; Variable memcpy's should lower to calls. 8define i8* @test1(i8* %a, i8* %b, i64 %n) nounwind { 9entry: 10 tail call void @llvm.memcpy.p0i8.p0i8.i64( i8* %a, i8* %b, i64 %n, i32 1, i1 0 ) 11 ret i8* %a 12 13; LINUX: test1: 14; LINUX: memcpy 15} 16 17; Variable memcpy's should lower to calls. 18define i8* @test2(i64* %a, i64* %b, i64 %n) nounwind { 19entry: 20 %tmp14 = bitcast i64* %a to i8* 21 %tmp25 = bitcast i64* %b to i8* 22 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp14, i8* %tmp25, i64 %n, i32 8, i1 0 ) 23 ret i8* %tmp14 24 25; LINUX: test2: 26; LINUX: memcpy 27} 28 29; Large constant memcpy's should lower to a call when optimizing for size. 30; PR6623 31 32; On the other hand, Darwin's definition of -Os is optimizing for size without 33; hurting performance so it should just ignore optsize when expanding memcpy. 34; rdar://8821501 35define void @test3(i8* nocapture %A, i8* nocapture %B) nounwind optsize noredzone { 36entry: 37 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i32 1, i1 false) 38 ret void 39; LINUX: test3: 40; LINUX: memcpy 41 42; DARWIN: test3: 43; DARWIN-NOT: memcpy 44; DARWIN: movq 45; DARWIN: movq 46; DARWIN: movq 47; DARWIN: movq 48; DARWIN: movq 49; DARWIN: movq 50; DARWIN: movq 51; DARWIN: movq 52; DARWIN: movq 53; DARWIN: movq 54; DARWIN: movq 55; DARWIN: movq 56; DARWIN: movq 57; DARWIN: movq 58; DARWIN: movq 59; DARWIN: movq 60} 61 62; Large constant memcpy's should be inlined when not optimizing for size. 63define void @test4(i8* nocapture %A, i8* nocapture %B) nounwind noredzone { 64entry: 65 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i32 1, i1 false) 66 ret void 67; LINUX: test4: 68; LINUX: movq 69; LINUX: movq 70; LINUX: movq 71; LINUX: movq 72; LINUX: movq 73; LINUX: movq 74; LINUX: movq 75; LINUX: movq 76; LINUX: movq 77; LINUX: movq 78; LINUX: movq 79; LINUX: movq 80} 81 82 83@.str = private unnamed_addr constant [30 x i8] c"\00aaaaaaaaaaaaaaaaaaaaaaaaaaaa\00", align 1 84 85define void @test5(i8* nocapture %C) nounwind uwtable ssp { 86entry: 87 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %C, i8* getelementptr inbounds ([30 x i8]* @.str, i64 0, i64 0), i64 16, i32 1, i1 false) 88 ret void 89 90; DARWIN: movabsq $7016996765293437281 91; DARWIN: movabsq $7016996765293437184 92} 93 94 95