Stream: cranelift

Topic: Overflow flag is not used for branches?


view this post on Zulip Adel Prokurov (Nov 05 2025 at 14:24):

Hello! I found out that jo is not emitted on X86 for overflowing ops:

    415c:   f7 ef                   imul   %edi
    415e:   49 89 fc                mov    %rdi,%r12
    4161:   0f 90 c1                seto   %cl
    4164:   84 c9                   test   %cl,%cl
    4166:   0f 85 15 02 00 00       jne    4381 <fn0:fac:(main)_fac+0x391>

It's emitted from this code:

 let (result, ovf) = ssa.builder.ins().smul_overflow(lhs, rhs);
            let succ = ssa.builder.create_block();
            ssa.builder.append_block_param(succ, types::I32);
            ssa.builder
                .ins()
                .brif(ovf, slow, &[], succ, &[BlockArg::Value(result)]);
            ssa.builder.switch_to_block(succ);
            ssa.builder.block_params(succ)[0]

view this post on Zulip Alex Crichton (Nov 05 2025 at 14:57):

Yes this is known to have suboptimal codegen at this time, so this is not unexpected at least. That being said it's something that we'd like to improve nonetheless!

view this post on Zulip Adel Prokurov (Jul 21 2026 at 12:24):

Alex Crichton said:

Yes this is known to have suboptimal codegen at this time, so this is not unexpected at least. That being said it's something that we'd like to improve nonetheless!

Hey, I have opened a PR which does fusion into jo/jb. I did not manage to do it purely on ISLE level and had to modify lower.rs. Would love to get a review on pr! https://github.com/bytecodealliance/wasmtime/pull/13919


Last updated: Jul 29 2026 at 05:03 UTC