1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=memcpyopt -S -verify-memoryssa | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 define void @test(ptr %src, i8 %c, i64 %size) {
7 ; CHECK-NEXT: [[DST1:%.*]] = alloca i8, i64 [[SIZE:%.*]], align 1
8 ; CHECK-NEXT: [[DST2:%.*]] = alloca i8, i64 [[SIZE]], align 1
9 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[DST1]], i8 [[C:%.*]], i64 [[SIZE]], i1 false)
10 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[DST2]], i8 [[C]], i64 [[SIZE]], i1 false)
11 ; CHECK-NEXT: ret void
13 %dst1 = alloca i8, i64 %size
14 %dst2 = alloca i8, i64 %size
15 call void @llvm.memset.p0.i64(ptr align 8 %dst1, i8 %c, i64 %size, i1 false)
16 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst2, ptr align 8 %dst1, i64 %size, i1 false)
21 ; Differing sizes, so left as it is.
22 define void @negative_test(ptr %src, i8 %c, i64 %size1, i64 %size2) {
23 ; CHECK-LABEL: @negative_test(
24 ; CHECK-NEXT: [[DST1:%.*]] = alloca i8, i64 [[SIZE1:%.*]], align 1
25 ; CHECK-NEXT: [[DST2:%.*]] = alloca i8, i64 [[SIZE2:%.*]], align 1
26 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[DST1]], i8 [[C:%.*]], i64 [[SIZE1]], i1 false)
27 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[DST2]], ptr align 8 [[DST1]], i64 [[SIZE2]], i1 false)
28 ; CHECK-NEXT: ret void
30 %dst1 = alloca i8, i64 %size1
31 %dst2 = alloca i8, i64 %size2
32 call void @llvm.memset.p0.i64(ptr align 8 %dst1, i8 %c, i64 %size1, i1 false)
33 call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst2, ptr align 8 %dst1, i64 %size2, i1 false)
38 declare void @llvm.memset.p0.i64(ptr, i8, i64, i1)
39 declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)