Open workingjubilee opened 3 years ago
For note, here: having done some thought and research, it's not clear using a higher alignment is actually desired in practice. It may be the case that actually the desired alignment for vectors which do not precisely align to the machine's vector sizes is lower, around the element size (as if it were an array), possibly unless it uses a power of 2 element count (as it does here).
I tried this code: (Playground). The random inputs are mostly just to keep the compiler fairly "honest" and block optimizing away the instructions it would use.
Thus, I expected to see this happen:
Instead, this happened:
That does not appear to be the correct alignment to report for this type, unless I am misunderstanding something here.
Meta
rustc --version --verbose
:I believe this is related to, but not exactly the same as, #27060. Apologies if this is a total duplicate, or if I am misunderstanding something here about what Rust means by "alignment", but after careful review with @calebzulawski, we started to arrive at the conclusion that something was off.
Here is the generated assembly, as you can see, it uses multiple SSE instructions, including
movaps
, an aligned load, but I haven't exhaustively analyzed it so I can't immediately tell if actual alignment requirements are being adhered to here and I am just spooked by the seemingly misleading information.x86_64 Assembly
```asm std::sys_common::backtrace::__rust_begin_short_backtrace: # @std::sys_common::backtrace::__rust_begin_short_backtrace # %bb.0: sub rsp, 8 call rdi mov rax, rsp #APP #NO_APP pop rax ret # -- End function std::rt::lang_start: # @std::rt::lang_start # %bb.0: sub rsp, 8 mov rcx, rdx mov rdx, rsi mov qword ptr [rsp], rdi lea rsi, [rip + .L__unnamed_1] mov rdi, rsp call qword ptr [rip + std::rt::lang_start_internal@GOTPCREL] pop rcx ret # -- End function std::rt::lang_start::{{closure}}: # @"std::rt::lang_start::{{closure}}" # %bb.0: sub rsp, 8 mov rdi, qword ptr [rdi] call std::sys_common::backtrace::__rust_begin_short_backtrace xor eax, eax pop rcx ret # -- End function <&T as core::fmt::Debug>::fmt: # @"<&T as core::fmt::Debug>::fmt" # %bb.0: mov rdi, qword ptr [rdi] jmp qword ptr [rip + core::fmt::float::