1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=memcpyopt -S -verify-memoryssa | FileCheck %s
3 ; Handle memcpy-memcpy dependencies of differing sizes correctly.
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 ; Don't delete the second memcpy, even though there's an earlier
8 ; memcpy with a larger size from the same address.
10 define i32 @foo(i1 %z) {
13 ; CHECK-NEXT: [[A:%.*]] = alloca [10 x i32], align 4
14 ; CHECK-NEXT: [[S:%.*]] = alloca [10 x i32], align 4
15 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr nonnull align 16 [[S]], i8 0, i64 40, i1 false)
16 ; CHECK-NEXT: store i32 1, ptr [[A]], align 4
17 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr [10 x i32], ptr [[S]], i64 0, i64 1
18 ; CHECK-NEXT: br i1 [[Z:%.*]], label [[FOR_BODY3_LR_PH:%.*]], label [[FOR_INC7_1:%.*]]
19 ; CHECK: for.body3.lr.ph:
20 ; CHECK-NEXT: br label [[FOR_INC7_1]]
22 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[A]], ptr align 4 [[SCEVGEP]], i64 4, i1 false)
23 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[A]], align 4
24 ; CHECK-NEXT: ret i32 [[TMP2]]
27 %a = alloca [10 x i32]
28 %s = alloca [10 x i32]
29 call void @llvm.memset.p0.i64(ptr nonnull align 16 %s, i8 0, i64 40, i1 false)
31 %scevgep = getelementptr [10 x i32], ptr %s, i64 0, i64 1
32 br i1 %z, label %for.body3.lr.ph, label %for.inc7.1
34 for.body3.lr.ph: ; preds = %entry
35 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %scevgep, i64 17179869180, i1 false)
39 call void @llvm.memcpy.p0.p0.i64(ptr align 4 %a, ptr align 4 %scevgep, i64 4, i1 false)
44 declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)
45 declare void @llvm.memset.p0.i64(ptr, i8, i64, i1)