1 ; RUN: opt -basicaa -memcpyopt -instcombine -S < %s | FileCheck %s
3 target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 define void @foo([8 x i64]* noalias nocapture sret dereferenceable(64) %sret) {
8 %a = alloca [8 x i64], align 8
9 %a.cast = bitcast [8 x i64]* %a to i8*
10 call void @llvm.lifetime.start.p0i8(i64 64, i8* %a.cast)
11 call void @llvm.memset.p0i8.i64(i8* align 8 %a.cast, i8 0, i64 64, i1 false)
12 %sret.cast = bitcast [8 x i64]* %sret to i8*
13 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %sret.cast, i8* align 8 %a.cast, i64 64, i1 false)
14 call void @llvm.lifetime.end.p0i8(i64 64, i8* %a.cast)
18 ; CHECK: %[[sret_cast:[^=]+]] = bitcast [8 x i64]* %sret to i8*
19 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 %[[sret_cast]], i8 0, i64 64
20 ; CHECK-NOT: call void @llvm.memcpy
24 define void @bar([8 x i64]* noalias nocapture sret dereferenceable(64) %sret, [8 x i64]* noalias nocapture dereferenceable(64) %out) {
26 %a = alloca [8 x i64], align 8
27 %a.cast = bitcast [8 x i64]* %a to i8*
28 call void @llvm.lifetime.start.p0i8(i64 64, i8* %a.cast)
29 call void @llvm.memset.p0i8.i64(i8* align 8 %a.cast, i8 0, i64 64, i1 false)
30 %sret.cast = bitcast [8 x i64]* %sret to i8*
31 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %sret.cast, i8* align 8 %a.cast, i64 64, i1 false)
32 call void @llvm.memset.p0i8.i64(i8* align 8 %a.cast, i8 42, i64 32, i1 false)
33 %out.cast = bitcast [8 x i64]* %out to i8*
34 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %out.cast, i8* align 8 %a.cast, i64 64, i1 false)
35 call void @llvm.lifetime.end.p0i8(i64 64, i8* %a.cast)
39 ; CHECK: %[[a:[^=]+]] = alloca [8 x i64]
40 ; CHECK: %[[a_cast:[^=]+]] = bitcast [8 x i64]* %[[a]] to i8*
41 ; CHECK: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 %[[a_cast]], i8 0, i64 64
42 ; CHECK: %[[sret_cast:[^=]+]] = bitcast [8 x i64]* %sret to i8*
43 ; CHECK: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 %[[sret_cast]], i8 0, i64 64
44 ; CHECK: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 %[[a_cast]], i8 42, i64 32
45 ; CHECK: %[[out_cast:[^=]+]] = bitcast [8 x i64]* %out to i8*
46 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 %[[out_cast]], i8* nonnull align 8 %[[a_cast]], i64 64
47 ; CHECK-NOT: call void @llvm.memcpy
51 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind
52 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind
54 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) nounwind
55 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind