From bac1bc4a04a46a3eb0f5f7a13ae29324964c0bd5 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Tue, 26 Nov 2024 13:56:53 +0100 Subject: [PATCH] fixup! emit egal checks for const set splitting --- Compiler/src/ssair/inlining.jl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Compiler/src/ssair/inlining.jl b/Compiler/src/ssair/inlining.jl index cb3b72e1232d1..976db8306b8cc 100644 --- a/Compiler/src/ssair/inlining.jl +++ b/Compiler/src/ssair/inlining.jl @@ -566,10 +566,25 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs:: for i = 1:nparams argex = argexprs[i] tT, sT = argtypes[i], argextype(argex, compact) + aft, mft = fieldtype(atype, i), fieldtype(mtype, i) + if !(aft <: mft) + # Generate isa check + isa_expr = Expr(:call, isa, argex, mft) + isa_type = isa_tfunc(optimizer_lattice(interp), argextype(argex, compact), Const(mft)) + ssa = insert_node_here!(compact, NewInstruction(isa_expr, isa_type, line)) + if cond === true + cond = ssa + else + and_expr = Expr(:call, and_int, cond, ssa) + and_type = and_int_tfunc(optimizer_lattice(interp), argextype(cond, compact), isa_type) + cond = insert_node_here!(compact, NewInstruction(and_expr, and_type, line)) + end + end + if isa(tT, Const) && isa(sT, ConstSet) # Generate egal check egal_expr = Expr(:call, ===, argex, tT) - egal_type = egal_tfunc(optimizer_lattice(interp), argextype(argexprs[i], compact), tT) + egal_type = egal_tfunc(optimizer_lattice(interp), argextype(argex, compact), tT) ssa = insert_node_here!(compact, NewInstruction(egal_expr, egal_type, line)) if cond === true cond = ssa