Skip to content

Commit b4f6ccd

Browse files
committed
add tests
1 parent ef41f96 commit b4f6ccd

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/spirv.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,37 @@ end
112112

113113
end
114114

115+
@testset "replace i128 allocas" begin
116+
mod = @eval module $(gensym())
117+
# reimplement some of SIMD.jl
118+
struct Vec{N, T}
119+
data::NTuple{N, Core.VecElement{T}}
120+
end
121+
@generated function fadd(x::Vec{N, Float32}, y::Vec{N, Float32}) where {N}
122+
quote
123+
Vec(Base.llvmcall($"""
124+
%ret = fadd <$N x float> %0, %1
125+
ret <$N x float> %ret
126+
""", NTuple{N, Core.VecElement{Float32}}, NTuple{2, NTuple{N, Core.VecElement{Float32}}}, x.data, y.data))
127+
end
128+
end
129+
kernel(x...) = @noinline fadd(x...)
130+
end
131+
132+
@test @filecheck begin
133+
# TODO: should structs of `NTuple{VecElement{T}}` be passed by value instead of sret?
134+
check"CHECK-NOT: i128"
135+
check"CHECK-LABEL: define void @{{(julia|j)_kernel_[0-9]+}}"
136+
check"CHECK: alloca <2 x i64>, align 16"
137+
SPIRV.code_llvm(mod.kernel, NTuple{2, mod.Vec{4, Float32}}; backend, dump_module=true)
138+
end
139+
140+
@test @filecheck begin
141+
check"CHECK-NOT: i128"
142+
check"CHECK-LABEL: define void @{{(julia|j)_kernel_[0-9]+}}"
143+
check"CHECK: alloca [2 x <2 x i64>], align 16"
144+
SPIRV.code_llvm(mod.kernel, NTuple{2, mod.Vec{8, Float32}}; backend, dump_module=true)
145+
end
146+
end
147+
115148
end

0 commit comments

Comments
 (0)