1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 define i8* @memcpy_nonconst_n(i8* %d, i8* nocapture readonly %s, i64 %n) {
5 ; CHECK-LABEL: @memcpy_nonconst_n(
6 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[D:%.*]], i8* align 1 [[S:%.*]], i64 [[N:%.*]], i1 false)
7 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[D]], i64 [[N]]
8 ; CHECK-NEXT: ret i8* [[TMP1]]
10 %r = tail call i8* @mempcpy(i8* %d, i8* %s, i64 %n)
14 define i8* @memcpy_nonconst_n_copy_attrs(i8* %d, i8* nocapture readonly %s, i64 %n) {
15 ; CHECK-LABEL: @memcpy_nonconst_n_copy_attrs(
16 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) [[D:%.*]], i8* align 1 [[S:%.*]], i64 [[N:%.*]], i1 false)
17 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[D]], i64 [[N]]
18 ; CHECK-NEXT: ret i8* [[TMP1]]
20 %r = tail call i8* @mempcpy(i8* dereferenceable(16) %d, i8* %s, i64 %n)
24 define void @memcpy_nonconst_n_unused_retval(i8* %d, i8* nocapture readonly %s, i64 %n) {
25 ; CHECK-LABEL: @memcpy_nonconst_n_unused_retval(
26 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 [[D:%.*]], i8* align 1 [[S:%.*]], i64 [[N:%.*]], i1 false)
27 ; CHECK-NEXT: ret void
29 call i8* @mempcpy(i8* %d, i8* %s, i64 %n)
33 define i8* @memcpy_small_const_n(i8* %d, i8* nocapture readonly %s) {
34 ; CHECK-LABEL: @memcpy_small_const_n(
35 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i8* [[S:%.*]] to i64*
36 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[D:%.*]] to i64*
37 ; CHECK-NEXT: [[TMP3:%.*]] = load i64, i64* [[TMP1]], align 1
38 ; CHECK-NEXT: store i64 [[TMP3]], i64* [[TMP2]], align 1
39 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds i8, i8* [[D]], i64 8
40 ; CHECK-NEXT: ret i8* [[TMP4]]
42 %r = tail call i8* @mempcpy(i8* %d, i8* %s, i64 8)
46 define i8* @memcpy_big_const_n(i8* %d, i8* nocapture readonly %s) {
47 ; CHECK-LABEL: @memcpy_big_const_n(
48 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 1 dereferenceable(1024) [[D:%.*]], i8* nonnull align 1 dereferenceable(1024) [[S:%.*]], i64 1024, i1 false)
49 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[D]], i64 1024
50 ; CHECK-NEXT: ret i8* [[TMP1]]
52 %r = tail call i8* @mempcpy(i8* %d, i8* %s, i64 1024)
56 declare i8* @mempcpy(i8*, i8* nocapture readonly, i64)