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

            Bug ID: 87631
           Summary: new attribute for passing structures with multiple
                    SIMD data members in registers
           Product: gcc
           Version: 9.0
               URL: https://godbolt.org/z/M-zEpR
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kretz at kde dot org
  Target Milestone: ---

Consider:

using V [[gnu::vector_size(16)]] = float;

struct X1 { V a; };
struct X2 { V a, b; };

X1 f1(X1 x) { return x; }
X2 f2(X2 x) { return x; }

f1 is typically more efficient at the call site and in the function itself,
since it doesn't have to do the stores to & loads from the stack. The user
still has a choice: Using const-ref, the function arguments can still be passed
via memory.

f2 leaves the user no choice, every object of X2 is unconditionally passed via
memory. If the vector_size attribute is removed, however, objects of X2 are
still passed via registers. I propose a new attribute (e.g.
"pass_via_register"), potentially with an argument that limits the number of
registers it may use (useful for generic types), that would modify the ABI of
such types to have them passed via registers. Consequently, f2 could also
compile to a single "ret".

Note, I would like to use this feature in the implementation of
std::experimental::simd.

Reply via email to