https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127193

Sam Gardner <samuelgardner101 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |samuelgardner101 at gmail dot 
com

--- Comment #1 from Sam Gardner <samuelgardner101 at gmail dot com> ---
also seeing this on trunk (cloned master 03/09/2026). i think alignment
attribute applied through a typedef is not surviving BMI roundtrip.

```
attrs.h:

    typedef long long vec_u __attribute__((__vector_size__(16), __may_alias__,
__aligned__(1)));
    typedef long long vec_a __attribute__((__vector_size__(16)));
    typedef int int_under __attribute__((__aligned__(1)));
    typedef int int_over  __attribute__((__aligned__(32)));
    struct __attribute__((__aligned__(64))) AttrBig { char c; };
    struct alignas(64) AlignasBig { char c; };
    struct __attribute__((__packed__)) Packed { char c; int i; };


t.ixx:

    module;
    #include "attrs.h"
    export module t;
    export using ::vec_u;
    export using ::vec_a;
    export using ::int_under;
    export using ::int_over;
    export using ::AttrBig;
    export using ::AlignasBig;
    export using ::Packed;


t_use.cpp:

    import t;
    #define SHOW(T, want) static_assert(alignof(T) == want, "alignof(" #T ") !=
" #want);
    SHOW(vec_u, 1)
    SHOW(vec_a, 16)
    SHOW(int_under, 1)
    SHOW(int_over, 32)
    SHOW(AttrBig, 64)
    SHOW(AlignasBig, 64)
    static_assert(sizeof(Packed) == 5, "sizeof(Packed) != 5");
    int main() {}

    $ g++ -std=c++20 -fmodules-ts -c t.ixx -o t.o
    $ g++ -std=c++20 -fmodules-ts -fsyntax-only t_use.cpp
    t_use.cpp:2:48: error: static assertion failed: alignof(vec_u) != 1
      * the comparison reduces to '(16 == 1)'
    t_use.cpp:2:48: error: static assertion failed: alignof(int_under) != 1
      * the comparison reduces to '(4 == 1)'
    t_use.cpp:2:48: error: static assertion failed: alignof(int_over) != 32
      * the comparison reduces to '(4 == 32)'
```

but replacing `import t;` with `#include "attrs.h"` makes all seven pass

then the intrinsic stuff is downstream of it because theyre all defined with
alignments of 1 like

```
typedef long long __m128i_u __attribute__ ((__vector_size__ (16),
__may_alias__, __aligned__ (1)));
typedef double __m128d_u __attribute__ ((__vector_size__ (16), __may_alias__,
__aligned__ (1)));
typedef double __x86_double_u __attribute__ ((__may_alias__, __aligned__ (1)));
```


with results of

```
    intrinsic            direct    via import
    -----------------    ------    ----------
    _mm_loadu_si128      movdqu    movdqu       (survives)
    _mm_storeu_si128     movups    movaps
    _mm_loadu_pd         movupd    movapd
    _mm_storeu_pd        movups    movaps
    _mm_loadu_ps         movups    movaps
    _mm_storeu_ps        movups    movaps
```

because they cast like `return *(__m128d_u *)__P;` in their body or deference
that type when assigning into it etc.

Reply via email to