1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -dse < %s | FileCheck %s
4 declare void @llvm.memcpy.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i1) nounwind
5 declare void @llvm.memcpy.inline.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i1) nounwind
6 declare void @llvm.memmove.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i1) nounwind
7 declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i1) nounwind
9 define void @test1(i8* noalias %A, i8* noalias %B) {
10 ; CHECK-LABEL: @test1(
11 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i8(i8* [[A:%.*]], i8* [[B:%.*]], i8 12, i1 false)
12 ; CHECK-NEXT: ret void
14 store i8 0, i8* %A ;; Written to by memcpy
16 call void @llvm.memcpy.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)
21 define void @test2(i8* noalias %A, i8* noalias %B) {
22 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i8(i8* [[A]], i8* [[B:%.*]], i8 12, i1 false)
24 ; CHECK-NEXT: ret void
26 store i8 0, i8* %A ;; Written to by memmove
28 call void @llvm.memmove.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)
33 define void @test2a(i8* %A, i8* %B) {
34 ; CHECK-LABEL: @test2a(
35 ; CHECK-NEXT: store i8 0, i8* [[A:%.*]], align 1
36 ; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i8(i8* [[A]], i8* [[B:%.*]], i8 12, i1 false)
37 ; CHECK-NEXT: ret void
39 store i8 0, i8* %A ;; Written to by memmove
41 call void @llvm.memmove.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)
46 define void @test3(i8* noalias %A) {
47 ; CHECK-LABEL: @test3(
48 ; CHECK-NEXT: call void @llvm.memset.p0i8.i8(i8* [[A:%.*]], i8 0, i8 12, i1 false)
49 ; CHECK-NEXT: ret void
51 store i8 0, i8* %A ;; Written to by memset
53 call void @llvm.memset.p0i8.i8(i8* %A, i8 0, i8 12, i1 false)
58 declare void @llvm.memcpy.element.unordered.atomic.p0i16.p0i16.i16(i16* nocapture, i16* nocapture, i16, i32) nounwind
59 declare void @llvm.memmove.element.unordered.atomic.p0i16.p0i16.i16(i16* nocapture, i16* nocapture, i16, i32) nounwind
60 declare void @llvm.memset.element.unordered.atomic.p0i16.i16(i16* nocapture, i8, i16, i32) nounwind
63 define void @test4() {
64 ; CHECK-LABEL: @test4(
65 ; CHECK-NEXT: ret void
67 %A = alloca i16, i16 1024, align 2
68 %B = alloca i16, i16 1024, align 2
70 store atomic i16 0, i16* %A unordered, align 2 ;; Written to by memcpy
71 store atomic i16 0, i16* %B unordered, align 2 ;; Read by memcpy
73 call void @llvm.memcpy.element.unordered.atomic.p0i16.p0i16.i16(i16* align 2 %A, i16* align 2 %B, i16 1024, i32 2)
78 define void @test5() {
79 ; CHECK-LABEL: @test5(
80 ; CHECK-NEXT: ret void
82 %A = alloca i16, i16 1024, align 2
83 %B = alloca i16, i16 1024, align 2
85 store atomic i16 0, i16* %A unordered, align 2 ;; Written to by memmove
86 store atomic i16 0, i16* %B unordered, align 2 ;; Read by memmove
88 call void @llvm.memmove.element.unordered.atomic.p0i16.p0i16.i16(i16* align 2 %A, i16* align 2 %B, i16 1024, i32 2)
93 define void @test6() {
94 ; CHECK-LABEL: @test6(
95 ; CHECK-NEXT: [[B:%.*]] = alloca i16, i16 1024, align 2
96 ; CHECK-NEXT: ret void
98 %A = alloca i16, i16 1024, align 2
99 %B = alloca i16, i16 1024, align 2
101 store atomic i16 0, i16* %A unordered, align 2 ;; Written to by memset
103 call void @llvm.memset.element.unordered.atomic.p0i16.i16(i16* align 2 %A, i8 0, i16 1024, i32 2)
108 define void @test7(i8* noalias %A, i8* noalias %B) {
109 ; CHECK-LABEL: @test7(
110 ; CHECK-NEXT: call void @llvm.memcpy.inline.p0i8.p0i8.i8(i8* [[A:%.*]], i8* [[B:%.*]], i8 12, i1 false)
111 ; CHECK-NEXT: ret void
113 store i8 0, i8* %A ;; Written to by memcpy
115 call void @llvm.memcpy.inline.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)