Skip to content

clang ignores 'aligned' attribute with 'vector_size' attribute #11416

@tycho

Description

@tycho
Bugzilla Link 11044
Resolution FIXED
Resolved on Dec 19, 2011 15:24
Version trunk
OS Linux
CC @efriedma-quic

Extended Description

Below is a simple test case to show what I mean. Note the 'movaps', which is an aligned move, when the 'aligned(1)' clearly says to do unaligned moves (which GCC respects). The effect of 'movaps' in this case is a fatal fault.

Extra newlines added before each prompt for clarity.

snoonan@loki ~ $ cat test.c
#include <stdint.h>
typedef uint32_t v4 attribute ((vector_size(16), aligned(1)));
void mov_v4(v4 *x, v4 *y)
{
*x = *y;
}

snoonan@loki ~ $ clang -v
clang version 3.0 (ssh://orcus.local/scm/git/tycho/mirrors/llvm/clang.git http://llvm.org/git/clang.git a891a32d3762ee641a29c091d286f2a7432671a5)
Target: x86_64-unknown-linux-gnu
Thread model: posix

snoonan@loki ~ $ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/x86_64-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)

snoonan@loki ~ $ gcc -o test-gcc.s -S test.c

snoonan@loki ~ $ clang -o test-clang.s -S test.c

snoonan@loki ~ $ head -n 50 test-*.s
==> test-clang.s <==
.file "test.c"
.text
.globl mov_v4
.align 16, 0x90
.type mov_v4,@function
mov_v4: # @​mov_v4
.Ltmp0:
.cfi_startproc

BB#0: # %entry

movq	%rdi, -8(%rsp)
movq	%rsi, -16(%rsp)
movq	-8(%rsp), %rdi
movaps	(%rsi), %xmm0
movaps	%xmm0, (%rdi)
ret

.Ltmp1:
.size mov_v4, .Ltmp1-mov_v4
.Ltmp2:
.cfi_endproc
.Leh_func_end0:

.section	".note.GNU-stack","",@progbits

==> test-gcc.s <==
.file "test.c"
.text
.globl mov_v4
.type mov_v4, @​function
mov_v4:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
movq %rsp, %rbp
.cfi_offset 6, -16
.cfi_def_cfa_register 6
movq %rdi, -8(%rbp)
movq %rsi, -16(%rbp)
movq -16(%rbp), %rax
movdqu (%rax), %xmm0
movq -8(%rbp), %rax
movdqu %xmm0, (%rax)
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size mov_v4, .-mov_v4
.ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2"
.section .note.GNU-stack,"",@progbits

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions