[hjl@gnu-6 avx512-1]$ cat x.i typedef long long __m512i __attribute__ ((__vector_size__ (64), __may_alias__)); struct m512i { __m512i x; }; typedef long long __m256i __attribute__ ((__vector_size__ (32), __may_alias__)); struct m256i { __m256i x; }; struct m256i foo1 (struct m256i x, struct m256i y, struct m256i z) { return z; } struct m512i foo2 (struct m512i x, struct m512i y, struct m512i z) { return z; } [hjl@gnu-6 avx512-1]$ make /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -mavx512f -O2 -S x.i [hjl@gnu-6 avx512-1]$ cat x.s .file "x.i" .section .text.unlikely,"ax",@progbits .LCOLDB0: .text .LHOTB0: .p2align 4,,15 .globl foo1 .type foo1, @function foo1: .LFB0: .cfi_startproc vmovdqa %ymm2, %ymm0 ret .cfi_endproc .LFE0: .size foo1, .-foo1 .section .text.unlikely .LCOLDE0: .text .LHOTE0: .section .text.unlikely .LCOLDB1: .text .LHOTB1: .p2align 4,,15 .globl foo2 .type foo2, @function foo2: .LFB1: .cfi_startproc vmovdqa64 136(%rsp), %zmm0 movq %rdi, %rax vmovdqa64 %zmm0, (%rdi) ret .cfi_endproc .LFE1: .size foo2, .-foo2 .section .text.unlikely .LCOLDE1: .text .LHOTE1: .ident "GCC: (GNU) 4.9.0 20140214 (experimental)" .section .note.GNU-stack,"",@progbits [hjl@gnu-6 avx512-1]$ I am expecting struct m512i is passed/returned in zmm register per AVX-512 extension to x86-64 psABI.
From https://github.com/hjl-tools/x86-64-psABI/blob/hjl/avx512/low-level-sys-info.tex \item If the size of an object is larger than four \eightbytes, or it contains unaligned fields, it has class MEMORY struct m512i has size of 64 bytes, which is larger than 8*4=32, so it has class MEMORY and passed on the stack. It looks like everything is according to ABI.
(In reply to tocarip.intel from comment #1) > From > https://github.com/hjl-tools/x86-64-psABI/blob/hjl/avx512/low-level-sys-info. > tex > \item If the size of an object is larger than four \eightbytes, or > it contains unaligned fields, it has class MEMORY > > struct m512i has size of 64 bytes, which is larger than 8*4=32, so it has > class MEMORY and passed on the stack. > > It looks like everything is according to ABI. It is a bug in psABI. It should read as "eight \eightbytes".
(In reply to H.J. Lu from comment #2) > It is a bug in psABI. It should read as "eight \eightbytes". So, let's fix the psABI first and then fix gcc. This PR should be resolved before 4.9 is released.
(In reply to Uroš Bizjak from comment #3) > So, let's fix the psABI first and then fix gcc. psABI is fixed in [1]. [1] https://github.com/hjl-tools/x86-64-psABI/commit/6d7ccd614fe67111d2aecec853c3df0310b372d2
Created attachment 32169 [details] Proposed patch. Currently testing attached patch.
Author: kyukhin Date: Thu Feb 20 06:32:21 2014 New Revision: 207933 URL: http://gcc.gnu.org/viewcvs?rev=207933&root=gcc&view=rev Log: gcc/ PR target/60204 * config/i386/i386.c (classify_argument): Pass structures of size 64 bytes or less in register. tessuite/gcc/ PR target/60204 * gcc.target/x86_64/abi/avx512f/test_passing_structs.c: Update to reflect abi fix. * gcc.target/x86_64/abi/avx512f/test_passing_unions.c: Ditto. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.target/x86_64/abi/avx512f/test_passing_structs.c trunk/gcc/testsuite/gcc.target/x86_64/abi/avx512f/test_passing_unions.c
Fixed.