Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/metal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
function type_suffix(typ)
# XXX: can't we use LLVM to do this kind of mangling?
if typ isa LLVM.IntegerType
(signed::Bool ? "s" : "u") * "$(width(typ))"
"i$(width(typ))"
elseif typ == LLVM.HalfType()
"f16"
elseif typ == LLVM.FloatType()
Expand All @@ -907,7 +907,12 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
error("Unsupported intrinsic type: $typ")
end
end
fn *= "." * type_suffix(typ)

if typ isa LLVM.IntegerType || (typ isa LLVM.VectorType && eltype(typ) isa LLVM.IntegerType)
fn *= "." * (signed::Bool ? "s" : "u") * "." * type_suffix(typ)
else
fn *= "." * type_suffix(typ)
end

new_intr = if haskey(functions(mod), fn)
functions(mod)[fn]
Expand Down
2 changes: 1 addition & 1 deletion test/metal_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ end
(NTuple{2, VecElement{Int64}}, NTuple{2, VecElement{Int64}}), x, y)

ir = sprint(io->Metal.code_llvm(io, foo, (NTuple{2, VecElement{Int64}}, NTuple{2, VecElement{Int64}})))
@test occursin("air.max.v2s64", ir)
@test occursin("air.max.s.v2i64", ir)
end

end
Expand Down