mrk-its / rust-mos

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
55 stars 7 forks source link

bad result of float to int casting #27

Open mrk-its opened 6 months ago

mrk-its commented 6 months ago

following rust program https://github.com/mrk-its/aoc2022/blob/new_rust/pi/src/main.rs

produces bad result:

$ cargo run -p pi --release

100 pi: -2147450880
47611328 cycles

changing casting to to_int_unchecked produces proper result:

$ cargo run -p pi --release --features to_int_unchecked

100 pi: 314
47474448 cycles

This is probably because of some flaw in implementation of intrinsic(@llvm.fptosi.sat) https://github.com/llvm-mos/llvm-mos-sdk/issues/299 (https://github.com/llvm-mos/llvm-mos/commit/2372941659b7fd2cdd1e014f6fe505b032088938 https://github.com/llvm-mos/llvm-mos-sdk/pull/303)