Rust TOTD: rustc doesn't optimize this well: for i in x..y { buf[i] = z; } It does optimize this: for b in &mut buf[x..y] { *b = z; }
@jimblandy In my code, the first gets compiled into a loop with a bounds check in each iteration. The second gets compiled into memset.
-
-
@BRIAN_____ One of the motivations for the slice iterators was to encourage the omission of bounds checks, so perhaps not too surprising. -
@jimblandy Surprising b/c: 1. buf is a fixed-sized array [u8; 64]. 2. Even if it weren't fixed borrow checker ensures length doesn't change. -
@brian_____@jimblandy Probably because of lack of alias information provided to LLVM at the moment. -
@pcwalton Interesting. Mightn't Rust be able to provide better alias information to LLVM than a C or C++ front end could?@BRIAN_____ -
@jimblandy@brian_____ Yeah, in time. Probably want MIR to land first
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.