1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -memcpyopt -S -verify-memoryssa | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 ; Don't delete the memcpy in %if.then, even though it depends on an instruction
7 ; which will be deleted.
9 define void @foo(i1 %c, i8* %d, i8* %e, i8* %f) {
12 ; CHECK-NEXT: [[TMP:%.*]] = alloca [50 x i8], align 8
13 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast [50 x i8]* [[TMP]] to i8*
14 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[TMP4]], i64 1
15 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* nonnull [[D:%.*]], i8 0, i64 10, i1 false)
16 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 8 [[TMP4]], i8 0, i64 11, i1 false)
17 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[EXIT:%.*]]
19 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 8 [[F:%.*]], i8 0, i64 11, i1 false)
20 ; CHECK-NEXT: br label [[EXIT]]
22 ; CHECK-NEXT: ret void
25 %tmp = alloca [50 x i8], align 8
26 %tmp4 = bitcast [50 x i8]* %tmp to i8*
27 %tmp1 = getelementptr inbounds i8, i8* %tmp4, i64 1
28 call void @llvm.memset.p0i8.i64(i8* nonnull %d, i8 0, i64 10, i1 false)
29 store i8 0, i8* %tmp4, align 8
30 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %tmp1, i8* nonnull %d, i64 10, i1 false)
31 br i1 %c, label %if.then, label %exit
34 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %f, i8* nonnull align 8 %tmp4, i64 30, i1 false)
41 declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i1)
42 declare void @llvm.memset.p0i8.i64(i8*, i8, i64, i1)