https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127193
Bug ID: 127193
Summary: Alignment problem when using modules
Product: gcc
Version: 16.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
hi -
I'm seeing an issue with C++ modules and alignments with gcc16
(gcc version 16.2.1 20260901, on x86_64 fedora 44).
Consider this source:
------------------------------------------------------------------------------
#include <iostream>
#include <emmintrin.h>
__m128d foo (const double* p)
{
return _mm_loadu_pd(p);
}
------------------------------------------------------------------------------
If i build the C++ std module and then build this with x86_64-v2
and look at the code:
------------------------------------------------------------------------------
$ g++ -c -std=c++23 -fmodules -march=x86-64-v2 -O0 --compile-std-module
$ g++ -o a.o -c -std=c++23 -fmodules -march=x86-64-v2 -O0 a.cc
$ objdump -drR a.o
...
0: 55 push %rbp
1: 48 89 e5 mov %rsp,%rbp
4: 48 89 7d e8 mov %rdi,-0x18(%rbp)
8: 48 8b 45 e8 mov -0x18(%rbp),%rax
c: 48 89 45 f8 mov %rax,-0x8(%rbp)
10: 48 8b 45 f8 mov -0x8(%rbp),%rax
14: 66 0f 28 00 movapd (%rax),%xmm0
18: 5d pop %rbp
19: c3 ret
------------------------------------------------------------------------------
I see that _mm_loadu_pd has been miscompiled to use an aligned load
rather than an unaligned one. If i remove the -fmodules from the
compilation, then i see a movupd instruction, as expected. The same
thing happens if i swap the order of the two #includes.