▲ | ohr a day ago | |||||||
Thanks! Would be interesting to see if Rust/LLVM folks can get the compiler to apply this optimization whenever possible, as Rust can be much more accurate w.r.t memory initialization. | ||||||||
▲ | adgjlsfhk1 a day ago | parent | next [-] | |||||||
I think rust may be able to get it by adding a `freeze` intrinsic to the codegen here. that would force LLVM to pick a deterministic value if there was poison, and should thus unblock the optimization (which is fine here because we know the value isn't poison) | ||||||||
▲ | kukkamario a day ago | parent | prev | next [-] | |||||||
I think in this case Rust and C code aren't equivalent which maybe caused this slow down. Union trick also affects the alignment. C side struct is 32 bit aligned, but Rust struct only has 16bit alignment because it only contains fields with 16bit alignment. In practice the fields are likely anyway correctly aligned to 32bits, but compiler optimizations may have hard time verifying that. Have you tried manually defining alignment of Rust struct? | ||||||||
▲ | Ygg2 a day ago | parent | prev [-] | |||||||
Would be great, but wouldn't hold my breath for it. LLVM and Rustc can be both be kinda slow to stabilize. | ||||||||
|