-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suboptimal assembly for Contiguous derive #175
Comments
I'd certainly be happy to accept a PR which improves the generated assembly of any of the proc-macros. |
The issue is cause by the transmute in |
Hopefully fixed for Rust 1.71 -- try it out on nightly and let me know if it helped. |
Thanks. Will try to remember to test this again when 1.71 releases. |
Was not fixed by Rust 1.71. Tried with the stable release today. |
Oh, I see the problem. When I read
I heard With true So I guess the way forward here is either
|
Thanks for your analysis. I might look into the derive change. |
That's my fault since I only reported |
aside: now that ptr reading is const fn i hope transmute_copy is const fn soon too |
`from_integer` and `into_integer` are usually provided by the trait's default implementation. We override this implementation because it goes through `transmute_copy`, which can lead to inefficient assembly as seen in Lokathor#175 .
`from_integer` and `into_integer` are usually provided by the trait's default implementation. We override this implementation because it goes through `transmute_copy`, which can lead to inefficient assembly as seen in Lokathor#175 .
`from_integer` and `into_integer` are usually provided by the trait's default implementation. We override this implementation because it goes through `transmute_copy`, which can lead to inefficient assembly as seen in Lokathor#175 .
`from_integer` and `into_integer` are usually provided by the trait's default implementation. We override this implementation because it goes through `transmute_copy`, which can lead to inefficient assembly as seen in #175 .
The derived implementation of
Contiguous::into_integer
prevents some optimizations from happening. See the following example in which I have commented the resulting assembly as retrieved through cargo-show-asm on my stable-x86_64-unknown-linux-gnu machine.The assembly for
E::val_into
should be the same as forE::val_as
.This could be an issue with the default forbidden-to-override implementation of
Contiguous::into_integer
or it could be an issue with rustc. As a workaround the derive macro could emitas Int
since it knows what the repr type is. If you feel this is a rustc issue then I am happy to report it there.The text was updated successfully, but these errors were encountered: