Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upInneficient code generation, unless splitting part of the code into #[inline(always)] sub-function #55458
Comments
zackmdavis
added
the
A-codegen
label
Oct 29, 2018
This comment has been minimized.
This comment has been minimized.
|
BTW using pub fn square(mut buf: &mut [u8], self_buf: &[u8; 128]) {
while buf.len() >= self_buf.len() {
let (l, r) = {buf}.split_at_mut(self_buf.len());
buf = r;
for (a, b) in l.iter_mut().zip(self_buf.iter()) {
*a ^= *b;
}
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
newpavlov commentedOct 29, 2018
(from #43702)
Both examples are completely equivalent after inlining, but the second one gets compiled into a more efficient assembly:
https://rust.godbolt.org/z/mXrwhv
https://rust.godbolt.org/z/Uk3X3Z