blob: 72342cbacb4f503371a0ce7e9c758f5454a3ac6f [file] [log] [blame]
Evan Cheng05219282011-01-06 06:52:41 +00001; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s -check-prefix=LINUX
2; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s -check-prefix=DARWIN
Rafael Espindola068317b2007-09-28 12:53:01 +00003
Chris Lattner0ece9a12010-05-31 17:27:17 +00004declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
Rafael Espindola068317b2007-09-28 12:53:01 +00005
Chris Lattner0ece9a12010-05-31 17:27:17 +00006
7; Variable memcpy's should lower to calls.
8define i8* @test1(i8* %a, i8* %b, i64 %n) nounwind {
Rafael Espindola068317b2007-09-28 12:53:01 +00009entry:
Chris Lattner0ece9a12010-05-31 17:27:17 +000010 tail call void @llvm.memcpy.p0i8.p0i8.i64( i8* %a, i8* %b, i64 %n, i32 1, i1 0 )
Rafael Espindola068317b2007-09-28 12:53:01 +000011 ret i8* %a
Chris Lattner0ece9a12010-05-31 17:27:17 +000012
Evan Cheng05219282011-01-06 06:52:41 +000013; LINUX: test1:
14; LINUX: memcpy
Rafael Espindola068317b2007-09-28 12:53:01 +000015}
16
Chris Lattner0ece9a12010-05-31 17:27:17 +000017; Variable memcpy's should lower to calls.
18define i8* @test2(i64* %a, i64* %b, i64 %n) nounwind {
Rafael Espindola068317b2007-09-28 12:53:01 +000019entry:
20 %tmp14 = bitcast i64* %a to i8*
21 %tmp25 = bitcast i64* %b to i8*
Chris Lattner0ece9a12010-05-31 17:27:17 +000022 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp14, i8* %tmp25, i64 %n, i32 8, i1 0 )
Rafael Espindola068317b2007-09-28 12:53:01 +000023 ret i8* %tmp14
Chris Lattner0ece9a12010-05-31 17:27:17 +000024
Evan Cheng05219282011-01-06 06:52:41 +000025; LINUX: test2:
26; LINUX: memcpy
Rafael Espindola068317b2007-09-28 12:53:01 +000027}
Chris Lattner0ece9a12010-05-31 17:27:17 +000028
Chris Lattner6c41ad82010-05-31 17:30:14 +000029; Large constant memcpy's should lower to a call when optimizing for size.
30; PR6623
Evan Cheng05219282011-01-06 06:52:41 +000031
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
Chris Lattner6c41ad82010-05-31 17:30:14 +000035define 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
Evan Cheng05219282011-01-06 06:52:41 +000039; LINUX: test3:
Evan Chenga5e13622011-01-07 19:35:30 +000040; LINUX: memcpy
Evan Cheng05219282011-01-06 06:52:41 +000041
42; DARWIN: test3:
43; DARWIN-NOT: memcpy
Evan Chenga5e13622011-01-07 19:35:30 +000044; 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
Chris Lattner6c41ad82010-05-31 17:30:14 +000060}
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
Evan Cheng05219282011-01-06 06:52:41 +000067; 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
Chris Lattner6c41ad82010-05-31 17:30:14 +000080}
81