1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=dse < %s | FileCheck %s
4 declare void @llvm.memcpy.p0.p0.i8(ptr nocapture, ptr nocapture, i8, i1) nounwind
5 declare void @llvm.memcpy.inline.p0.p0.i8(ptr nocapture, ptr nocapture, i8, i1) nounwind
6 declare void @llvm.memmove.p0.p0.i8(ptr nocapture, ptr nocapture, i8, i1) nounwind
7 declare void @llvm.memset.p0.i8(ptr nocapture, i8, i8, i1) nounwind
9 define void @test1(ptr noalias %A, ptr noalias %B) {
10 ; CHECK-LABEL: @test1(
11 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i8(ptr [[A:%.*]], ptr [[B:%.*]], i8 12, i1 false)
12 ; CHECK-NEXT: ret void
14 store i8 0, ptr %A ;; Written to by memcpy
16 call void @llvm.memcpy.p0.p0.i8(ptr %A, ptr %B, i8 12, i1 false)
21 define void @test2(ptr noalias %A, ptr noalias %B) {
22 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i8(ptr [[A]], ptr [[B:%.*]], i8 12, i1 false)
24 ; CHECK-NEXT: ret void
26 store i8 0, ptr %A ;; Written to by memmove
28 call void @llvm.memmove.p0.p0.i8(ptr %A, ptr %B, i8 12, i1 false)
33 define void @test2a(ptr %A, ptr %B) {
34 ; CHECK-LABEL: @test2a(
35 ; CHECK-NEXT: store i8 0, ptr [[A:%.*]], align 1
36 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i8(ptr [[A]], ptr [[B:%.*]], i8 12, i1 false)
37 ; CHECK-NEXT: ret void
39 store i8 0, ptr %A ;; Written to by memmove
41 call void @llvm.memmove.p0.p0.i8(ptr %A, ptr %B, i8 12, i1 false)
46 define void @test3(ptr noalias %A) {
47 ; CHECK-LABEL: @test3(
48 ; CHECK-NEXT: call void @llvm.memset.p0.i8(ptr [[A:%.*]], i8 0, i8 12, i1 false)
49 ; CHECK-NEXT: ret void
51 store i8 0, ptr %A ;; Written to by memset
53 call void @llvm.memset.p0.i8(ptr %A, i8 0, i8 12, i1 false)
58 declare void @llvm.memcpy.element.unordered.atomic.p0.p0.i16(ptr nocapture, ptr nocapture, i16, i32) nounwind
59 declare void @llvm.memmove.element.unordered.atomic.p0.p0.i16(ptr nocapture, ptr nocapture, i16, i32) nounwind
60 declare void @llvm.memset.element.unordered.atomic.p0.i16(ptr 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, ptr %A unordered, align 2 ;; Written to by memcpy
71 store atomic i16 0, ptr %B unordered, align 2 ;; Read by memcpy
73 call void @llvm.memcpy.element.unordered.atomic.p0.p0.i16(ptr align 2 %A, ptr 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, ptr %A unordered, align 2 ;; Written to by memmove
86 store atomic i16 0, ptr %B unordered, align 2 ;; Read by memmove
88 call void @llvm.memmove.element.unordered.atomic.p0.p0.i16(ptr align 2 %A, ptr 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, ptr %A unordered, align 2 ;; Written to by memset
103 call void @llvm.memset.element.unordered.atomic.p0.i16(ptr align 2 %A, i8 0, i16 1024, i32 2)
108 define void @test7(ptr noalias %A, ptr noalias %B) {
109 ; CHECK-LABEL: @test7(
110 ; CHECK-NEXT: call void @llvm.memcpy.inline.p0.p0.i8(ptr [[A:%.*]], ptr [[B:%.*]], i8 12, i1 false)
111 ; CHECK-NEXT: ret void
113 store i8 0, ptr %A ;; Written to by memcpy
115 call void @llvm.memcpy.inline.p0.p0.i8(ptr %A, ptr %B, i8 12, i1 false)