zlacker

[parent] [thread] 2 comments
1. stevek+(OP)[view] [source] 2024-01-23 21:56:33
Ahh yes, thank you.

Rust doesn't have a -ffast-math flag, though it is interesting that you passed it directly to llvm. I am kinda glad that escape hatch doesn't work, to be honest.

There are currently unstable intrinsics that let you do this, and you seemingly get close to clang codegen with them: https://godbolt.org/z/EEW79Gbxv

The thread tracking this discusses another attempt at a flag to enable this by turning on the CPU feature directly, but that doesn't seem to affect codegen in this case. https://github.com/rust-lang/rust/issues/21690

It would be nice to get these intrinsics stabilized, at least.

EDIT: oops you figured this out while I was writing it, haha.

replies(1): >>cbm-vi+q6
2. cbm-vi+q6[view] [source] 2024-01-23 22:33:07
>>stevek+(OP)
Even without a -ffast-math flag, the current stable Rust compiler will vectorize loops on integer types.

https://godbolt.org/z/KjErzacfv

Edit: ...and I now realize who I responded to, I'm sure you already know this. :)

replies(1): >>galang+wh
◧◩
3. galang+wh[view] [source] [discussion] 2024-01-23 23:42:37
>>cbm-vi+q6
Loops on floats are fine, its just reduction operations that hit the issue with the associativity assumption for floats leading to UB. You can trick it by making f32x16 types like the wide crate does or if you use nightly simba can do it with const generic expressions.
[go to top]