memintrinsics.ll
3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -dse -enable-dse-memoryssa < %s | FileCheck %s
declare void @llvm.memcpy.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i1) nounwind
declare void @llvm.memcpy.inline.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i1) nounwind
declare void @llvm.memmove.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i1) nounwind
declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i1) nounwind
define void @test1(i8* noalias %A, i8* noalias %B) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i8(i8* [[A:%.*]], i8* [[B:%.*]], i8 12, i1 false)
; CHECK-NEXT: ret void
;
store i8 0, i8* %A ;; Written to by memcpy
call void @llvm.memcpy.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)
ret void
}
; FIXME: We should eliminate this dead store.
define void @test2(i8* noalias %A, i8* noalias %B) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: store i8 0, i8* [[A:%.*]], align 1
; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i8(i8* [[A]], i8* [[B:%.*]], i8 12, i1 false)
; CHECK-NEXT: ret void
;
store i8 0, i8* %A ;; Written to by memmove
call void @llvm.memmove.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)
ret void
}
define void @test2a(i8* %A, i8* %B) {
; CHECK-LABEL: @test2a(
; CHECK-NEXT: store i8 0, i8* [[A:%.*]], align 1
; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i8(i8* [[A]], i8* [[B:%.*]], i8 12, i1 false)
; CHECK-NEXT: ret void
;
store i8 0, i8* %A ;; Written to by memmove
call void @llvm.memmove.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)
ret void
}
define void @test3(i8* noalias %A) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: call void @llvm.memset.p0i8.i8(i8* [[A:%.*]], i8 0, i8 12, i1 false)
; CHECK-NEXT: ret void
;
store i8 0, i8* %A ;; Written to by memset
call void @llvm.memset.p0i8.i8(i8* %A, i8 0, i8 12, i1 false)
ret void
}
declare void @llvm.memcpy.element.unordered.atomic.p0i16.p0i16.i16(i16* nocapture, i16* nocapture, i16, i32) nounwind
declare void @llvm.memmove.element.unordered.atomic.p0i16.p0i16.i16(i16* nocapture, i16* nocapture, i16, i32) nounwind
declare void @llvm.memset.element.unordered.atomic.p0i16.i16(i16* nocapture, i8, i16, i32) nounwind
define void @test4() {
; CHECK-LABEL: @test4(
; CHECK-NEXT: ret void
;
%A = alloca i16, i16 1024, align 2
%B = alloca i16, i16 1024, align 2
store atomic i16 0, i16* %A unordered, align 2 ;; Written to by memcpy
store atomic i16 0, i16* %B unordered, align 2 ;; Read by memcpy
call void @llvm.memcpy.element.unordered.atomic.p0i16.p0i16.i16(i16* align 2 %A, i16* align 2 %B, i16 1024, i32 2)
ret void
}
define void @test5() {
; CHECK-LABEL: @test5(
; CHECK-NEXT: ret void
;
%A = alloca i16, i16 1024, align 2
%B = alloca i16, i16 1024, align 2
store atomic i16 0, i16* %A unordered, align 2 ;; Written to by memmove
store atomic i16 0, i16* %B unordered, align 2 ;; Read by memmove
call void @llvm.memmove.element.unordered.atomic.p0i16.p0i16.i16(i16* align 2 %A, i16* align 2 %B, i16 1024, i32 2)
ret void
}
define void @test6() {
; CHECK-LABEL: @test6(
; CHECK-NEXT: [[B:%.*]] = alloca i16, i16 1024, align 2
; CHECK-NEXT: ret void
;
%A = alloca i16, i16 1024, align 2
%B = alloca i16, i16 1024, align 2
store atomic i16 0, i16* %A unordered, align 2 ;; Written to by memset
call void @llvm.memset.element.unordered.atomic.p0i16.i16(i16* align 2 %A, i8 0, i16 1024, i32 2)
ret void
}
define void @test7(i8* noalias %A, i8* noalias %B) {
; CHECK-LABEL: @test7(
; CHECK-NEXT: call void @llvm.memcpy.inline.p0i8.p0i8.i8(i8* [[A:%.*]], i8* [[B:%.*]], i8 12, i1 false)
; CHECK-NEXT: ret void
;
store i8 0, i8* %A ;; Written to by memcpy
call void @llvm.memcpy.inline.p0i8.p0i8.i8(i8* %A, i8* %B, i8 12, i1 false)
ret void
}