Skip to content

Commit 18a25db

Browse files
committed
add infer as test
1 parent dec2420 commit 18a25db

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
; RUN: opt < %s -S -passes=infer-address-spaces | FileCheck %s --check-prefix=INFER
2+
; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_90 -mattr=+ptx80 | FileCheck %s --check-prefix=PTX
3+
; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64 -mcpu=sm_90 -mattr=+ptx80 | %ptxas-verify %}
4+
5+
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
6+
target triple = "nvptx64-unknown-unknown"
7+
8+
@constant_tensormap = addrspace(4) global [64 x i8] zeroinitializer, align 64
9+
10+
; Inference from const address space
11+
define void @test_infer_const_from_cast() {
12+
; INFER-LABEL: @test_infer_const_from_cast
13+
; INFER: call void @llvm.nvvm.prefetch.tensormap.p4(ptr addrspace(4) @constant_tensormap)
14+
; BOTH: call void @llvm.nvvm.prefetch.tensormap.p4(ptr addrspace(4) @constant_tensormap)
15+
; PTX-LABEL: .visible .func test_infer_const_from_cast(
16+
; PTX: mov.b64 %rd{{[0-9]+}}, constant_tensormap;
17+
; PTX: cvta.const.u64 %rd{{[0-9]+}}, %rd{{[0-9]+}};
18+
; PTX: prefetch.tensormap [%rd{{[0-9]+}}];
19+
entry:
20+
%casted = addrspacecast ptr addrspace(4) @constant_tensormap to ptr
21+
call void @llvm.nvvm.prefetch.tensormap.p0(ptr %casted)
22+
ret void
23+
}
24+
25+
; Cast from Const space to Generic
26+
define void @test_const_to_generic_cast(ptr addrspace(4) %const_ptr) {
27+
; INFER-LABEL: @test_const_to_generic_cast
28+
; INFER: call void @llvm.nvvm.prefetch.tensormap.p4(ptr addrspace(4) %const_ptr)
29+
; PTX-LABEL: .visible .func test_const_to_generic_cast(
30+
; PTX: prefetch.const.tensormap [%rd{{[0-9]+}}];
31+
entry:
32+
%cast = addrspacecast ptr addrspace(4) %const_ptr to ptr
33+
call void @llvm.nvvm.prefetch.tensormap.p0(ptr %cast)
34+
ret void
35+
}
36+
37+
; No inference possible
38+
define void @test_no_inference_possible(ptr %generic_ptr) {
39+
; INFER-LABEL: @test_no_inference_possible
40+
; INFER: call void @llvm.nvvm.prefetch.tensormap.p0(ptr %generic_ptr)
41+
; PTX-LABEL: .visible .func test_no_inference_possible(
42+
; PTX: prefetch.tensormap [%rd{{[0-9]+}}];
43+
entry:
44+
call void @llvm.nvvm.prefetch.tensormap.p0(ptr %generic_ptr)
45+
ret void
46+
}
47+
48+
; Cast from Parameter space to Generic
49+
define void @test_param_to_generic_cast(ptr addrspace(101) %param_ptr) {
50+
; INFER-LABEL: @test_param_to_generic_cast
51+
; INFER: call void @llvm.nvvm.prefetch.tensormap.p101(ptr addrspace(101) %param_ptr)
52+
; PTX-LABEL: .visible .func test_param_to_generic_cast(
53+
; PTX: prefetch.param.tensormap [%rd{{[0-9]+}}];
54+
entry:
55+
%cast = addrspacecast ptr addrspace(101) %param_ptr to ptr
56+
call void @llvm.nvvm.prefetch.tensormap.p0(ptr %cast)
57+
ret void
58+
}
59+
60+
; Multiple casts in sequence
61+
define void @test_infer_through_multiple_casts() {
62+
; INFER-LABEL: @test_infer_through_multiple_casts
63+
; INFER: call void @llvm.nvvm.prefetch.tensormap.p4(ptr addrspace(4) @constant_tensormap)
64+
; PTX-LABEL: .visible .func test_infer_through_multiple_casts(
65+
; PTX: mov.b64 %rd{{[0-9]+}}, constant_tensormap;
66+
; PTX: cvta.const.u64 %rd{{[0-9]+}}, %rd{{[0-9]+}};
67+
; PTX: prefetch.tensormap [%rd{{[0-9]+}}];
68+
entry:
69+
%cast1 = addrspacecast ptr addrspace(4) @constant_tensormap to ptr
70+
%cast2 = addrspacecast ptr %cast1 to ptr addrspace(4)
71+
%cast3 = addrspacecast ptr addrspace(4) %cast2 to ptr
72+
call void @llvm.nvvm.prefetch.tensormap(ptr %cast3)
73+
ret void
74+
}
75+
76+
declare void @llvm.nvvm.prefetch.tensormap.p0(ptr)
77+
declare void @llvm.nvvm.prefetch.tensormap.p4(ptr addrspace(4))
78+
declare void @llvm.nvvm.prefetch.tensormap.p101(ptr addrspace(101))

0 commit comments

Comments
 (0)