2011-07-07 23:06:52 +02:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=core2 | FileCheck %s -check-prefix=LINUX
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=DARWIN
|
2007-09-28 14:53:01 +02:00
|
|
|
|
2010-05-31 19:27:17 +02:00
|
|
|
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
|
2007-09-28 14:53:01 +02:00
|
|
|
|
2010-05-31 19:27:17 +02:00
|
|
|
|
|
|
|
; Variable memcpy's should lower to calls.
|
|
|
|
define i8* @test1(i8* %a, i8* %b, i64 %n) nounwind {
|
2007-09-28 14:53:01 +02:00
|
|
|
entry:
|
2010-05-31 19:27:17 +02:00
|
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i64( i8* %a, i8* %b, i64 %n, i32 1, i1 0 )
|
2007-09-28 14:53:01 +02:00
|
|
|
ret i8* %a
|
2010-05-31 19:27:17 +02:00
|
|
|
|
2013-07-13 22:38:47 +02:00
|
|
|
; LINUX-LABEL: test1:
|
2011-01-06 07:52:41 +01:00
|
|
|
; LINUX: memcpy
|
2007-09-28 14:53:01 +02:00
|
|
|
}
|
|
|
|
|
2010-05-31 19:27:17 +02:00
|
|
|
; Variable memcpy's should lower to calls.
|
|
|
|
define i8* @test2(i64* %a, i64* %b, i64 %n) nounwind {
|
2007-09-28 14:53:01 +02:00
|
|
|
entry:
|
|
|
|
%tmp14 = bitcast i64* %a to i8*
|
|
|
|
%tmp25 = bitcast i64* %b to i8*
|
2010-05-31 19:27:17 +02:00
|
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp14, i8* %tmp25, i64 %n, i32 8, i1 0 )
|
2007-09-28 14:53:01 +02:00
|
|
|
ret i8* %tmp14
|
2010-05-31 19:27:17 +02:00
|
|
|
|
2013-07-13 22:38:47 +02:00
|
|
|
; LINUX-LABEL: test2:
|
2011-01-06 07:52:41 +01:00
|
|
|
; LINUX: memcpy
|
2007-09-28 14:53:01 +02:00
|
|
|
}
|
2010-05-31 19:27:17 +02:00
|
|
|
|
2010-05-31 19:30:14 +02:00
|
|
|
; Large constant memcpy's should lower to a call when optimizing for size.
|
|
|
|
; PR6623
|
2011-01-06 07:52:41 +01:00
|
|
|
|
|
|
|
; On the other hand, Darwin's definition of -Os is optimizing for size without
|
|
|
|
; hurting performance so it should just ignore optsize when expanding memcpy.
|
|
|
|
; rdar://8821501
|
2010-05-31 19:30:14 +02:00
|
|
|
define void @test3(i8* nocapture %A, i8* nocapture %B) nounwind optsize noredzone {
|
|
|
|
entry:
|
|
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i32 1, i1 false)
|
|
|
|
ret void
|
2013-07-13 22:38:47 +02:00
|
|
|
; LINUX-LABEL: test3:
|
2011-01-07 20:35:30 +01:00
|
|
|
; LINUX: memcpy
|
2011-01-06 07:52:41 +01:00
|
|
|
|
2013-07-13 22:38:47 +02:00
|
|
|
; DARWIN-LABEL: test3:
|
2011-01-06 07:52:41 +01:00
|
|
|
; DARWIN-NOT: memcpy
|
2011-01-07 20:35:30 +01:00
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
|
|
|
; DARWIN: movq
|
2010-05-31 19:30:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
; Large constant memcpy's should be inlined when not optimizing for size.
|
|
|
|
define void @test4(i8* nocapture %A, i8* nocapture %B) nounwind noredzone {
|
|
|
|
entry:
|
|
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %A, i8* %B, i64 64, i32 1, i1 false)
|
|
|
|
ret void
|
2013-07-13 22:38:47 +02:00
|
|
|
; LINUX-LABEL: test4:
|
2012-08-17 14:28:26 +02:00
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
2010-05-31 19:30:14 +02:00
|
|
|
}
|
|
|
|
|
2012-02-05 03:37:36 +01:00
|
|
|
|
|
|
|
@.str = private unnamed_addr constant [30 x i8] c"\00aaaaaaaaaaaaaaaaaaaaaaaaaaaa\00", align 1
|
|
|
|
|
|
|
|
define void @test5(i8* nocapture %C) nounwind uwtable ssp {
|
|
|
|
entry:
|
|
|
|
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)
|
|
|
|
ret void
|
|
|
|
|
2013-07-13 22:38:47 +02:00
|
|
|
; DARWIN-LABEL: test5:
|
2012-02-05 03:37:36 +01:00
|
|
|
; DARWIN: movabsq $7016996765293437281
|
|
|
|
; DARWIN: movabsq $7016996765293437184
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-10 23:13:27 +01:00
|
|
|
; PR14896
|
|
|
|
@.str2 = private unnamed_addr constant [2 x i8] c"x\00", align 1
|
|
|
|
|
|
|
|
define void @test6() nounwind uwtable {
|
|
|
|
entry:
|
|
|
|
; DARWIN: test6
|
|
|
|
; DARWIN: movw $0, 8
|
|
|
|
; DARWIN: movq $120, 0
|
|
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* null, i8* getelementptr inbounds ([2 x i8]* @.str2, i64 0, i64 0), i64 10, i32 1, i1 false)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2013-02-25 15:20:21 +01:00
|
|
|
define void @PR15348(i8* %a, i8* %b) {
|
|
|
|
; Ensure that alignment of '0' in an @llvm.memcpy intrinsic results in
|
|
|
|
; unaligned loads and stores.
|
|
|
|
; LINUX: PR15348
|
|
|
|
; LINUX: movb
|
|
|
|
; LINUX: movb
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
; LINUX: movq
|
|
|
|
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %a, i8* %b, i64 17, i32 0, i1 false)
|
|
|
|
ret void
|
|
|
|
}
|