Re:How Rust 1.26 more than tripled the speed of my code
by comex on Monday May 14, 2018 @11:32AM
(#17066341)
The behavior with "m" is quite strange. In theory, it should produce a memory operand pointing directly to where the function argument was passed on the stack, rather than copying it to registers and then back onto the stack. I can reproduce this with Rust nightly:
This is strange because Rust and Clang both use LLVM for their backend.
Looking at the LLVM IR produced, Rust's IR straightforwardly corresponds to the source code: a load instruction (to evaluate `self_t[0]`) whose result is passed to an asm instruction:
https://play.rust-lang.org/?version=nightly&mode=release
However, Clang appears to do the right thing with equivalent C code:
https://godbolt.org/g/B1sjfS
This is strange because Rust and Clang both use LLVM for their backend.
Looking at the LLVM IR produced, Rust's IR straightforwardly corresponds to the source code: a load instruction (to evaluate `self_t[0]`) whose result is passed to an asm instruction:
But Clang's omits the load, and transforms the "m" constraint to "* m" (without the space, bah HN formatting): Hmm… seems to be related to this Rust bug: https://github.com/rust-lang/rust/issues/16383