As far as I can see we don't have anything like br_icmp for floats, right? Do I have to use x = ffcmp(...); brff(cond, x, target) ?
Currently I'm generating this:
block0(v0: i64, v1: f64, v2: f64, v3: f64):
v4 = ffcmp v2, v1
brff le v4, block1
jump block2
But it fails with Compilation(Verifier(VerifierErrors([VerifierError { location: inst1, context: Some("brff le v4, block1"), message: "Branch must have an encoding" }])))
You should normally use icmp + brz/brnz instead of br_icmp. For floats that is fcmp + brz/brnz. The brz instruction jumps when the argument is false or zero. The brnz instruction jumps when the argument is true or non-zero.
"You should" <-- why? It's easier with one instruction.
There is an optimization pass that does this for you: https://github.com/bytecodealliance/wasmtime/blob/49622bde586deeb8400529fd61bf5bf1abab38e3/cranelift/codegen/src/postopt.rs#L134
Last updated: Jan 10 2026 at 02:36 UTC