akldc opened issue #10996:
.clifTest Casetest optimize set opt_level=none set preserve_frame_pointers=true set enable_multi_ret_implicit_sret=true function %main() -> i64, f32 fast { block0(): v8 = iconst.i64 -3524126683585344751 v10 = f32const 0x1.66e07ap-1 v36 = band.f32 v10, v10 return v8,v36 } ; print: %main()When the
opt_levelis set tonone, the result is as follows.[x86 ] %main() -> [-3524126683585344751, 0x1.66e07ap-1] [riscv64] %main() -> [-3524126683585344751, 0x1.66e07ap-1] [aarch64] thread 'main' panicked at /home/obfuscator/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/regalloc2-0.12.2/src/ion/process.rs:1253:17: Could not allocate minimal bundle, but the allocation problem should be possible to solve note: run with `RUST_BACKTRACE=1` environment variable to display a backtraceBut when
opt_levelis switched tospeed:[x86 ] %main() -> [-3524126683585344751, 0x1.66e07ap-1] [riscv64] %main() -> [-3524126683585344751, 0x1.66e07ap-1] [aarch64] %main() -> [-3524126683585344751, 0x1.66e07ap-1]In this example, there's only one
bandinstruction.
On aarch64, it throws an error before optimization but runs correctly after. What’s the reason for that?
akldc added the bug label to Issue #10996.
akldc added the cranelift label to Issue #10996.
bjorn3 commented on issue #10996:
The reason why it runs with optimizations is probably that the
bandgets optimized out, turningv36into an alias tov10.
akldc commented on issue #10996:
@bjorn3
If thebandoperation on floating-point numbers is actually invalid or illegal, shouldn’t it cause an error both before and after optimization? Simply optimizing it away seems unsound, as it changes the program’s behavior rather than preserving its correctness.
alexcrichton added the cranelift:area:aarch64 label to Issue #10996.
alexcrichton commented on issue #10996:
Float-related bitops are legal, but generally not well supported across backends since they're so rarely used. We've concluded in the past we don't want to remove float-related bitops, so I think that this is a valid bug to have open personally.
The optimization here is sound in that if aarch64 generated code without panicking when optimizations are disabled then the code should do the same thing. The reason this passes with optimizations is as @bjorn3 said in that the shape of the IR being code-generated is different.
akldc commented on issue #10996:
@alexcrichton
Thank you for your response. I look forward to Cranelift becoming more sound over time.
Last updated: Dec 06 2025 at 06:05 UTC