Continuing the discussion from the meeting today, Chris or Nick what was the shape of the simplify_conditional rule y'all were thinking of?
Would it be something like (decl multi simplify_conditional (Value) Value)? Or (decl partial simplify_conditional (Value) Value)? I've never quite wrapped my head around multi things...
Also, how were y'all thinking it'd be applied to trap/brif/select? Naively I'd expect something like:
(rule (simplify (select ty cond a b))
(if-let simpler_cond (simplify_conditional cond))
(select ty simpler_cond a b))
but this'd require a partial constructor as opposed to a multi, and with multi I'm not sure how that'd fit in here
I think a partial constructor would be fine
multi would also require that we figure out how to do egraph extraction / best value computation for these values in the context of being zero/non-zero
hm I added:
(decl partial simplify_conditional (Value) Value)
(rule 0 (simplify_conditional (icmp ty (IntCC.NotEqual) a (iconst_u _ 0))) a)
(rule 1 (simplify_conditional (icmp ty (IntCC.NotEqual) (iconst_u _ 0) a)) a)
and got:
thread 'main' (430396) panicked at cranelift/isle/isle/src/codegen.rs:561:13:
assertion failed: !block.steps.iter().any(|c| matches!(c.check, ControlFlow::Loop { .. }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
during isle compilation
try a multi? (more thoughts here but meetings for a few hours)
how would multi be integrated? Something like this?
(rule (simplify (select ty cond a b))
(select ty (simplify_conditional cond) a b))
I'm not sure how else to integrate it but that feels like an infinite loop or blowup waiting to happen
yes, exactly. no infinite loops here -- maybe not ideal though if we know for sure that the simplified form is better
we may not have ever run multi-calling-non-multi through the new codegen backend before -- we should fix that
Last updated: Jun 01 2026 at 09:49 UTC