Skip to content

Commit 962b84e

Browse files
tgymnichmaleadt
andauthored
Fix type suffix of integer intrinsics (#538)
Co-authored-by: Tim Besard <[email protected]>
1 parent 111685f commit 962b84e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/metal.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
894894
function type_suffix(typ)
895895
# XXX: can't we use LLVM to do this kind of mangling?
896896
if typ isa LLVM.IntegerType
897-
(signed::Bool ? "s" : "u") * "$(width(typ))"
897+
"i$(width(typ))"
898898
elseif typ == LLVM.HalfType()
899899
"f16"
900900
elseif typ == LLVM.FloatType()
@@ -907,7 +907,12 @@ function lower_llvm_intrinsics!(@nospecialize(job::CompilerJob), fun::LLVM.Funct
907907
error("Unsupported intrinsic type: $typ")
908908
end
909909
end
910-
fn *= "." * type_suffix(typ)
910+
911+
if typ isa LLVM.IntegerType || (typ isa LLVM.VectorType && eltype(typ) isa LLVM.IntegerType)
912+
fn *= "." * (signed::Bool ? "s" : "u") * "." * type_suffix(typ)
913+
else
914+
fn *= "." * type_suffix(typ)
915+
end
911916

912917
new_intr = if haskey(functions(mod), fn)
913918
functions(mod)[fn]

test/metal_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ end
8787
(NTuple{2, VecElement{Int64}}, NTuple{2, VecElement{Int64}}), x, y)
8888

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

9393
end

0 commit comments

Comments
 (0)