Skip to content

Commit e0e5985

Browse files
committed
Improve hash performance for more types
1 parent 59cc8db commit e0e5985

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/frontend/target.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function infer(mi::MethodInstance, interp::AbstractInterpreter)
158158
local ci
159159
try
160160
@static if VERSION v"1.12-DEV"
161-
inferred_ci = CC.typeinf_ext_toplevel(interp, mi, CC.SOURCE_MODE_FORCE_SOURCE)
161+
inferred_ci = CC.typeinf_ext(interp, mi, CC.SOURCE_MODE_ABI)
162162
else
163163
inferred_ci = CC.typeinf_ext_toplevel(interp, mi)
164164
end

src/spir_types.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,21 @@ function Base.:(==)(x::SPIRType, y::SPIRType)
270270
end
271271

272272
function Base.hash(type::SPIRType, h::UInt)
273-
h = hash(SPIRType, hash(type.typename, h))
274-
@match type.typename begin
275-
&SPIR_TYPE_FUNCTION => begin
276-
(; rettype, argtypes) = type.function
277-
hash(rettype, hash(argtypes, h))
278-
end
279-
&SPIR_TYPE_STRUCT => hash(type.struct.uuid, h)
280-
_ => hash(type.data, h)
273+
h = @match type.typename begin
274+
&SPIR_TYPE_FLOAT => hash(type.float)
275+
&SPIR_TYPE_INTEGER => hash(type.integer)
276+
&SPIR_TYPE_VECTOR => hash(type.vector)
277+
&SPIR_TYPE_MATRIX => hash(type.matrix)
278+
&SPIR_TYPE_ARRAY => hash(type.array)
279+
&SPIR_TYPE_OPAQUE => hash(type.opaque)
280+
&SPIR_TYPE_IMAGE => hash(type.image)
281+
&SPIR_TYPE_SAMPLED_IMAGE => hash(type.image_type)
282+
&SPIR_TYPE_STRUCT => hash(type.struct.uuid)
283+
&SPIR_TYPE_POINTER => hash(type.pointer)
284+
&SPIR_TYPE_FUNCTION => hash(type.function)
285+
_ => hash(type.data)
281286
end
287+
hash(SPIRType, hash(type.typename, h))
282288
end
283289

284290
const IS_SPEC_CONST_FALSE = Ref(false)

0 commit comments

Comments
 (0)