1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -basicaa -memcpyopt -instcombine -S < %s | FileCheck %s
4 target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 define void @foo([8 x i64]* noalias nocapture sret dereferenceable(64) %sret) {
9 ; CHECK-NEXT: entry-block:
10 ; CHECK-NEXT: [[SRET1:%.*]] = bitcast [8 x i64]* [[SRET:%.*]] to i8*
11 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(64) [[SRET1]], i8 0, i64 64, i1 false)
12 ; CHECK-NEXT: ret void
15 %a = alloca [8 x i64], align 8
16 %a.cast = bitcast [8 x i64]* %a to i8*
17 call void @llvm.lifetime.start.p0i8(i64 64, i8* %a.cast)
18 call void @llvm.memset.p0i8.i64(i8* align 8 %a.cast, i8 0, i64 64, i1 false)
19 %sret.cast = bitcast [8 x i64]* %sret to i8*
20 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %sret.cast, i8* align 8 %a.cast, i64 64, i1 false)
21 call void @llvm.lifetime.end.p0i8(i64 64, i8* %a.cast)
26 define void @bar([8 x i64]* noalias nocapture sret dereferenceable(64) %sret, [8 x i64]* noalias nocapture dereferenceable(64) %out) {
28 ; CHECK-NEXT: entry-block:
29 ; CHECK-NEXT: [[A:%.*]] = alloca [8 x i64], align 8
30 ; CHECK-NEXT: [[A_CAST:%.*]] = bitcast [8 x i64]* [[A]] to i8*
31 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 64, i8* nonnull [[A_CAST]])
32 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(64) [[A_CAST]], i8 0, i64 64, i1 false)
33 ; CHECK-NEXT: [[SRET_CAST:%.*]] = bitcast [8 x i64]* [[SRET:%.*]] to i8*
34 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(64) [[SRET_CAST]], i8 0, i64 64, i1 false)
35 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull align 8 dereferenceable(32) [[A_CAST]], i8 42, i64 32, i1 false)
36 ; CHECK-NEXT: [[OUT_CAST:%.*]] = bitcast [8 x i64]* [[OUT:%.*]] to i8*
37 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(64) [[OUT_CAST]], i8* nonnull align 8 dereferenceable(64) [[A_CAST]], i64 64, i1 false)
38 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 64, i8* nonnull [[A_CAST]])
39 ; CHECK-NEXT: ret void
42 %a = alloca [8 x i64], align 8
43 %a.cast = bitcast [8 x i64]* %a to i8*
44 call void @llvm.lifetime.start.p0i8(i64 64, i8* %a.cast)
45 call void @llvm.memset.p0i8.i64(i8* align 8 %a.cast, i8 0, i64 64, i1 false)
46 %sret.cast = bitcast [8 x i64]* %sret to i8*
47 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %sret.cast, i8* align 8 %a.cast, i64 64, i1 false)
48 call void @llvm.memset.p0i8.i64(i8* align 8 %a.cast, i8 42, i64 32, i1 false)
49 %out.cast = bitcast [8 x i64]* %out to i8*
50 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %out.cast, i8* align 8 %a.cast, i64 64, i1 false)
51 call void @llvm.lifetime.end.p0i8(i64 64, i8* %a.cast)
56 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) nounwind
57 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) nounwind
59 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1) nounwind
60 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind