alexcrichton opened issue #15279:
This input:
test compile target x86_64 function %f(i32x4, i64) -> i32x4 { block0(v0: i32x4, v1: i64): v2 = load.i32x4 v1 v3 = sadd_sat v0, v2 return v3 }fails with:
$ clif-util compile --target x86_64 repro.clif thread 'main' panicked at cranelift/codegen/src/machinst/lower.rs:1746:13: assertion failed: !self.inst_sunk.contains(&inst)The same happens for
sadd_sat.i64x2,ssub_sat.i32x4andssub_sat.i64x2.
alexcrichton added the bug label to Issue #15279.
alexcrichton added the cranelift:area:x64 label to Issue #15279.
alexcrichton added the cranelift label to Issue #15279.
ColonelToad commented on issue #15279:
I'd like to work on this. I reproduced it on main and traced it to the x64 lowering of sadd_sat/ssub_sat for 32- and 64-bit lanes: those are implemented as a wrapping add/sub followed by overflow detection, and the detection reuses both operands. The second operand of the wrapping operation is an XmmMem128, so a single-use load is sunk into it as a memory operand and is then no longer available when the detection asks for it in a register, which trips the inst_sunk assertion in put_value_in_regs.
Forcing both operands into XMM registers before the wrapping operation fixes all four cases (sadd_sat/ssub_sat × i32x4/i64x2). I have that working locally, with a filetest covering the four combinations plus a two-load case; the x64 filetests and the saturating runtests pass. IIf you'd rather change the sink logic to avoid sinking loads that the rule reuses, I'm happy to take that route instead, otherwise I'll open a PR.
cfallin closed issue #15279:
This input:
test compile target x86_64 function %f(i32x4, i64) -> i32x4 { block0(v0: i32x4, v1: i64): v2 = load.i32x4 v1 v3 = sadd_sat v0, v2 return v3 }fails with:
$ clif-util compile --target x86_64 repro.clif thread 'main' panicked at cranelift/codegen/src/machinst/lower.rs:1746:13: assertion failed: !self.inst_sunk.contains(&inst)The same happens for
sadd_sat.i64x2,ssub_sat.i32x4andssub_sat.i64x2.
Last updated: Nov 19 2026 at 20:05 UTC