xref: /llvm-project/llvm/test/Transforms/InstCombine/memcpy.ll (revision 4ab40eca080965c65802710e39adbb78c4ce7bde)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instcombine -S | FileCheck %s
3
4declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind
5declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind
6
7; Same src/dest.
8
9define void @test1(ptr %a) {
10; CHECK-LABEL: @test1(
11; CHECK-NEXT:    ret void
12;
13  tail call void @llvm.memcpy.p0.p0.i32(ptr %a, ptr %a, i32 100, i1 false)
14  ret void
15}
16
17; PR8267 - same src/dest, but volatile.
18
19define void @test2(ptr %a) {
20; CHECK-LABEL: @test2(
21; CHECK-NEXT:    tail call void @llvm.memcpy.p0.p0.i32(ptr [[A:%.*]], ptr [[A]], i32 100, i1 true)
22; CHECK-NEXT:    ret void
23;
24  tail call void @llvm.memcpy.p0.p0.i32(ptr %a, ptr %a, i32 100, i1 true)
25  ret void
26}
27
28; 17179869184 == 0x400000000 - make sure that doesn't get truncated to 32-bit.
29
30define void @test3(ptr %d, ptr %s) {
31; CHECK-LABEL: @test3(
32; CHECK-NEXT:    tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(17179869184) [[D:%.*]], ptr noundef nonnull align 4 dereferenceable(17179869184) [[S:%.*]], i64 17179869184, i1 false)
33; CHECK-NEXT:    ret void
34;
35  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %d, ptr align 4 %s, i64 17179869184, i1 false)
36  ret void
37}
38
39@UnknownConstant = external constant i128
40
41define void @memcpy_to_constant(ptr %src) {
42; CHECK-LABEL: @memcpy_to_constant(
43; CHECK-NEXT:    ret void
44;
45  call void @llvm.memcpy.p0.p0.i32(ptr @UnknownConstant, ptr %src, i32 16, i1 false)
46  ret void
47}
48