-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Small discriminants are causing bad code generation #10613
Comments
cc @jld |
I would expect similar code generation with |
Look at the asm. This may actually not be so bad unless the |
Here is the asm. It is not actually generating a call to
|
@alexcrichton the equivalent to no |
I agree that the assembly doesn't look that bad, but this is still completely unnecessary, no? I was looking at assembly with huge waterfalls of moving al/ax/eax/rax over and over again. I don't think this is a closed bug because this is a real problem. This may not be a high priority bug, but our assembly is certainly doing things that it doesn't need to do. |
Is this #6736 ? |
Aha, I see the problem:
SROA happened, split up our struct into 3 elements, one of which is the padding, and stored the padding. The solution is to add |
It may be, but I don't know enough about LLVM's optimizations to know whether that would help or not. |
It would be possible to make the type It would also be possible to make |
Patch has been submitted to LLVM upstream. |
This code
Will generate this IR under
-O
Yes, that is a
memcpy
of length 7. I have no idea why this is getting generated, I'm trying to narrow down which pass is generating this, but that is absolutely awful code to generate for such a simple operation. I would expect this function to generate two stores, one of the discriminant and one of the value.Now change the program to have
#[repr(uint)]
in front of the enum, and we get this code:The text was updated successfully, but these errors were encountered: