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!


Last updated: Dec 06 2025 at 06:05 UTC