-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Sub-optimal codegen for types containing float+ZST #38269
Comments
@eddyb This seems fixed to me. #[inline(never)]
pub fn calc(v: P<X>) -> P<X> {
let a = P::<X>::new(v.get_value() * 1.234_f32);
let b = P::<X>::new(5.0_f32);
a / b
} define float @example::calc(float) unnamed_addr #2 !dbg !22 {
%1 = fmul float %0, 0x3FF3BE76C0000000, !dbg !24
%2 = fdiv float %1, 5.000000e+00, !dbg !25
ret float %2, !dbg !31
} Cc @rust-lang/wg-codegen |
Yeah this should be fixed for all ZSTs (edit: and even multiple ZST fields), @eddyb told me we do fully general newtype unwrapping for scalars and vectors now when I implemented |
Just tested this with |
The README could do with updating to reflect the fact that this is fixed. |
Similar to #32031 a
struct P<D> { value: f32, PhantomData<D>, }
is mapped toi32
instead off32
in the resulting llvm-ir output. Based on IRC discussions with @rkruppe the issue is likely caused by the inclusion of any zero-sized types in the struct.A minimal example is available at https://github.com/iliekturtles/llvm-opt/tree/fa05ddb4fb869e492e04c93e04fa0e939fb2fb49 and includes the offending llvm-ir and asm output.
The text was updated successfully, but these errors were encountered: