blob: 4af93ad3682172156156e443c55bfa04158870eb [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 Cheng461f1fc2011-01-06 07:58:36 +000040; LINUX-NOT: memcpy
41; LINUX: movups
42; LINUX: movups
43; LINUX: movups
44; LINUX: movups
45; LINUX: movups
46; LINUX: movups
47; LINUX: movups
48; LINUX: movups
Evan Cheng05219282011-01-06 06:52:41 +000049
50; DARWIN: test3:
51; DARWIN-NOT: memcpy
Evan Cheng461f1fc2011-01-06 07:58:36 +000052; DARWIN: movups
53; DARWIN: movups
54; DARWIN: movups
55; DARWIN: movups
56; DARWIN: movups
57; DARWIN: movups
58; DARWIN: movups
59; DARWIN: movups
60; DARWIN: movups
61; DARWIN: movups
62; DARWIN: movups
63; DARWIN: movups
64; DARWIN: movups
65; DARWIN: movups
66; DARWIN: movups
67; DARWIN: movups
Chris Lattner6c41ad82010-05-31 17:30:14 +000068}
69
70; Large constant memcpy's should be inlined when not optimizing for size.
71define void @test4(i8* nocapture %A, i8* nocapture %B) nounwind noredzone {
72entry:
73 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i32 1, i1 false)
74 ret void
Evan Cheng05219282011-01-06 06:52:41 +000075; LINUX: test4:
76; LINUX movq
77; LINUX movq
78; LINUX movq
79; LINUX movq
80; LINUX movq
81; LINUX movq
82; LINUX movq
83; LINUX movq
84; LINUX movq
85; LINUX movq
86; LINUX movq
87; LINUX movq
Chris Lattner6c41ad82010-05-31 17:30:14 +000088}
89