Hi, I'm interested in writing an optimization (((X / Y) = N) = ((Y * N) = X)) in ISLE.
The left-hand side will have something like (icmp (IntCC.Equal) (udiv x y) ...).
However, the problem is that the udiv term yields an Inst node while the icmp term requires Value nodes as operands.
It makes writing such a rule very difficult.
Is there any walkaround possible in ISLE? Thank you!
It looks like there is some glue missing here:
So it appears that the only missing piece is moving the
(convert Inst Value def_inst)
line from the lowering-specific prelude to the common prelude. I just checked that doing so causes a simple rule of the form you show to typecheck in the mid-end. (I didn't take the time to come up with a valid rule and check its full execution but please let me know if that doesn't work!)
Feel free to do so as part of an upcoming PR if you have one, or separately and tag me for review, either way.
(and, goes without saying but: thank you for continuing to work on optimizations of this sort! the slow but steady improvements to our codegen are greatly appreciated)
Thank you for the detailed answer! I'm trying to generate valid ISLE rules as many as possible.
For that you mentioned improvements for cranelift's codegen,
I wonder if we can precisely measure the improvements on generated code, and the compilation overhead. At the moment, I can think of running cranelift on some benchmarks and measure the time spent. Is there any established method for Cranelift per se?
We normally use Sightglass for that; see this part of the readme in particular showing how to build two different .sos from Wasmtime and compare them
the benchmark suite still isn't super-well filled out, but at least will give you something. Typically the numbers that are most interesting to the core Cranelift folks are the non-microbenchmarks, which more or less is the default suite plus maybe regex and blake3-*
Thank you very much. I hope the improved codegen can make some change. I'll try the benchamrks.
Last updated: Dec 06 2025 at 07:03 UTC