1 ; Test to make sure intrinsics are automatically upgraded.
2 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
3 ; RUN: verify-uselistorder %s
7 declare i8 @llvm.ctlz.i8(i8)
8 declare i16 @llvm.ctlz.i16(i16)
9 declare i32 @llvm.ctlz.i32(i32)
10 declare i42 @llvm.ctlz.i42(i42) ; Not a power-of-2
13 define void @test.ctlz(i8 %a, i16 %b, i32 %c, i42 %d) {
17 ; CHECK: call i8 @llvm.ctlz.i8(i8 %a, i1 false)
18 call i8 @llvm.ctlz.i8(i8 %a)
19 ; CHECK: call i16 @llvm.ctlz.i16(i16 %b, i1 false)
20 call i16 @llvm.ctlz.i16(i16 %b)
21 ; CHECK: call i32 @llvm.ctlz.i32(i32 %c, i1 false)
22 call i32 @llvm.ctlz.i32(i32 %c)
23 ; CHECK: call i42 @llvm.ctlz.i42(i42 %d, i1 false)
24 call i42 @llvm.ctlz.i42(i42 %d)
29 declare i8 @llvm.cttz.i8(i8)
30 declare i16 @llvm.cttz.i16(i16)
31 declare i32 @llvm.cttz.i32(i32)
32 declare i42 @llvm.cttz.i42(i42) ; Not a power-of-2
34 define void @test.cttz(i8 %a, i16 %b, i32 %c, i42 %d) {
38 ; CHECK: call i8 @llvm.cttz.i8(i8 %a, i1 false)
39 call i8 @llvm.cttz.i8(i8 %a)
40 ; CHECK: call i16 @llvm.cttz.i16(i16 %b, i1 false)
41 call i16 @llvm.cttz.i16(i16 %b)
42 ; CHECK: call i32 @llvm.cttz.i32(i32 %c, i1 false)
43 call i32 @llvm.cttz.i32(i32 %c)
44 ; CHECK: call i42 @llvm.cttz.i42(i42 %d, i1 false)
45 call i42 @llvm.cttz.i42(i42 %d)
50 declare i1 @llvm.coro.end(ptr, i1)
51 define void @test.coro.end(ptr %ptr) {
52 ; CHECK-LABEL: @test.coro.end(
53 ; CHECK: call i1 @llvm.coro.end(ptr %ptr, i1 false, token none)
54 call i1 @llvm.coro.end(ptr %ptr, i1 false)
58 @a = private global [60 x i8] zeroinitializer, align 1
60 declare i32 @llvm.objectsize.i32(ptr, i1) nounwind readonly
61 define i32 @test.objectsize() {
62 ; CHECK-LABEL: @test.objectsize(
63 ; CHECK: @llvm.objectsize.i32.p0(ptr @a, i1 false, i1 false, i1 false)
64 %s = call i32 @llvm.objectsize.i32(ptr @a, i1 false)
68 declare i64 @llvm.objectsize.i64.p0(ptr, i1) nounwind readonly
69 define i64 @test.objectsize.2() {
70 ; CHECK-LABEL: @test.objectsize.2(
71 ; CHECK: @llvm.objectsize.i64.p0(ptr @a, i1 false, i1 false, i1 false)
72 %s = call i64 @llvm.objectsize.i64.p0(ptr @a, i1 false)
76 @u = private global [60 x ptr] zeroinitializer, align 1
78 declare i32 @llvm.objectsize.i32.unnamed(ptr, i1) nounwind readonly
79 define i32 @test.objectsize.unnamed() {
80 ; CHECK-LABEL: @test.objectsize.unnamed(
81 ; CHECK: @llvm.objectsize.i32.p0(ptr @u, i1 false, i1 false, i1 false)
82 %s = call i32 @llvm.objectsize.i32.unnamed(ptr @u, i1 false)
86 define i64 @test.objectsize.unnamed.2() {
87 ; CHECK-LABEL: @test.objectsize.unnamed.2(
88 ; CHECK: @llvm.objectsize.i64.p0(ptr @u, i1 false, i1 false, i1 false)
89 %s = call i64 @llvm.objectsize.i64.p0(ptr @u, i1 false)
93 declare <2 x double> @llvm.masked.load.v2f64(ptr %ptrs, i32, <2 x i1> %mask, <2 x double> %src0)
95 define <2 x double> @tests.masked.load(ptr %ptr, <2 x i1> %mask, <2 x double> %passthru) {
96 ; CHECK-LABEL: @tests.masked.load(
97 ; CHECK: @llvm.masked.load.v2f64.p0
98 %res = call <2 x double> @llvm.masked.load.v2f64(ptr %ptr, i32 1, <2 x i1> %mask, <2 x double> %passthru)
102 declare void @llvm.masked.store.v2f64(<2 x double> %val, ptr %ptrs, i32, <2 x i1> %mask)
104 define void @tests.masked.store(ptr %ptr, <2 x i1> %mask, <2 x double> %val) {
105 ; CHECK-LABEL: @tests.masked.store(
106 ; CHECK: @llvm.masked.store.v2f64.p0
107 call void @llvm.masked.store.v2f64(<2 x double> %val, ptr %ptr, i32 4, <2 x i1> %mask)
111 declare <2 x double> @llvm.masked.gather.v2f64(<2 x ptr> %ptrs, i32, <2 x i1> %mask, <2 x double> %src0)
113 define <2 x double> @tests.masked.gather(<2 x ptr> %ptr, <2 x i1> %mask, <2 x double> %passthru) {
114 ; CHECK-LABEL: @tests.masked.gather(
115 ; CHECK: @llvm.masked.gather.v2f64.v2p0
116 %res = call <2 x double> @llvm.masked.gather.v2f64(<2 x ptr> %ptr, i32 1, <2 x i1> %mask, <2 x double> %passthru)
117 ret <2 x double> %res
120 declare void @llvm.masked.scatter.v2f64(<2 x double> %val, <2 x ptr> %ptrs, i32, <2 x i1> %mask)
122 define void @tests.masked.scatter(<2 x ptr> %ptr, <2 x i1> %mask, <2 x double> %val) {
123 ; CHECK-LABEL: @tests.masked.scatter(
124 ; CHECK: @llvm.masked.scatter.v2f64.v2p0
125 call void @llvm.masked.scatter.v2f64(<2 x double> %val, <2 x ptr> %ptr, i32 1, <2 x i1> %mask)
129 declare ptr @llvm.invariant.start(i64, ptr nocapture) nounwind readonly
130 declare void @llvm.invariant.end(ptr, i64, ptr nocapture) nounwind
132 define void @tests.invariant.start.end() {
133 ; CHECK-LABEL: @tests.invariant.start.end(
135 %i = call ptr @llvm.invariant.start(i64 1, ptr %a)
136 ; CHECK: call ptr @llvm.invariant.start.p0
138 call void @llvm.invariant.end(ptr %i, i64 1, ptr %a)
139 ; CHECK: call void @llvm.invariant.end.p0
143 declare ptr @llvm.invariant.start.unnamed(i64, ptr nocapture) nounwind readonly
144 declare void @llvm.invariant.end.unnamed(ptr, i64, ptr nocapture) nounwind
146 define void @tests.invariant.start.end.unnamed() {
147 ; CHECK-LABEL: @tests.invariant.start.end.unnamed(
149 %i = call ptr @llvm.invariant.start.unnamed(i64 1, ptr %a)
150 ; CHECK: call ptr @llvm.invariant.start.p0
151 store ptr null, ptr %a
152 call void @llvm.invariant.end.unnamed(ptr %i, i64 1, ptr %a)
153 ; CHECK: call void @llvm.invariant.end.p0
157 @__stack_chk_guard = external global ptr
158 declare void @llvm.stackprotectorcheck(ptr)
160 define void @test.stackprotectorcheck() {
161 ; CHECK-LABEL: @test.stackprotectorcheck(
162 ; CHECK-NEXT: ret void
163 call void @llvm.stackprotectorcheck(ptr @__stack_chk_guard)
167 declare void @llvm.lifetime.start(i64, ptr nocapture) nounwind readonly
168 declare void @llvm.lifetime.end(i64, ptr nocapture) nounwind
170 define void @tests.lifetime.start.end() {
171 ; CHECK-LABEL: @tests.lifetime.start.end(
173 call void @llvm.lifetime.start(i64 1, ptr %a)
174 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %a)
176 call void @llvm.lifetime.end(i64 1, ptr %a)
177 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %a)
181 declare void @llvm.lifetime.start.unnamed(i64, ptr nocapture) nounwind readonly
182 declare void @llvm.lifetime.end.unnamed(i64, ptr nocapture) nounwind
184 define void @tests.lifetime.start.end.unnamed() {
185 ; CHECK-LABEL: @tests.lifetime.start.end.unnamed(
187 call void @llvm.lifetime.start.unnamed(i64 1, ptr %a)
188 ; CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %a)
189 store ptr null, ptr %a
190 call void @llvm.lifetime.end.unnamed(i64 1, ptr %a)
191 ; CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %a)
195 declare void @llvm.prefetch(ptr, i32, i32, i32)
196 define void @test.prefetch(ptr %ptr) {
197 ; CHECK-LABEL: @test.prefetch(
198 ; CHECK: @llvm.prefetch.p0(ptr %ptr, i32 0, i32 3, i32 1)
199 call void @llvm.prefetch(ptr %ptr, i32 0, i32 3, i32 1)
203 declare void @llvm.prefetch.p0(ptr, i32, i32, i32)
204 define void @test.prefetch.2(ptr %ptr) {
205 ; CHECK-LABEL: @test.prefetch.2(
206 ; CHECK: @llvm.prefetch.p0(ptr %ptr, i32 0, i32 3, i32 1)
207 call void @llvm.prefetch(ptr %ptr, i32 0, i32 3, i32 1)
211 declare void @llvm.prefetch.unnamed(ptr, i32, i32, i32)
212 define void @test.prefetch.unnamed(ptr %ptr) {
213 ; CHECK-LABEL: @test.prefetch.unnamed(
214 ; CHECK: @llvm.prefetch.p0(ptr %ptr, i32 0, i32 3, i32 1)
215 call void @llvm.prefetch.unnamed(ptr %ptr, i32 0, i32 3, i32 1)
219 ; This is part of @test.objectsize(), since llvm.objectsize declaration gets
220 ; emitted at the end.
221 ; CHECK: declare i32 @llvm.objectsize.i32.p0
223 ; CHECK: declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
224 ; CHECK: declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)