1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=memcpyopt < %s | FileCheck %s
4 declare void @llvm.memset.p0.i64(ptr, i8, i64, i1)
5 declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)
7 define void @zero_size(ptr %p, ptr %p2) {
8 ; CHECK-LABEL: @zero_size(
11 call void @llvm.memcpy.p0.p0.i64(ptr %p, ptr %p2, i64 0, i1 false)
15 ; The memcpy size is zero in a way that is non-trivial, but understood by AA.
16 define void @pr54983(ptr %p, ptr noalias %p2) {
17 ; CHECK-LABEL: @pr54983(
18 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr [[P:%.*]], i8 0, i64 1, i1 false)
19 ; CHECK-NEXT: [[SIZE:%.*]] = shl i64 0, 0
20 ; CHECK-NEXT: ret void
22 call void @llvm.memset.p0.i64(ptr %p, i8 0, i64 1, i1 false)
24 call void @llvm.memcpy.p0.p0.i64(ptr %p, ptr %p2, i64 %size, i1 false)
28 define void @pr64886(i64 %len, ptr noalias %p) {
29 ; CHECK-LABEL: @pr64886(
30 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr inttoptr (i64 -1 to ptr), i8 0, i64 [[LEN:%.*]], i1 false)
31 ; CHECK-NEXT: ret void
33 call void @llvm.memset.p0.i64(ptr inttoptr (i64 -1 to ptr), i8 0, i64 %len, i1 false)
34 call void @llvm.memcpy.p0.p0.i64(ptr inttoptr (i64 -1 to ptr), ptr %p, i64 poison, i1 false)