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

            Bug ID: 96476
           Summary: [Request] expose preferred vector width to
                    preprocessor
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: e...@coeus-group.com
  Target Milestone: ---

It would be nice if the value passed to -mprefer-vector-width=* were exposed to
the preprocessor.  Something like `#define __PREFERRED_VECTOR_WIDTH 256` when
-mprefer-vector-width=256 is passed.

I'd be really happy if it was always present when vectorization is enabled
(i.e., 128 with SSE, 256 with AVX), but satisfied if it were only defined when
-mprefer-vector-width is specified.

I'm filing this under the "target" component since -mprefer-vector-width is
x86-specific according to the manual, but it seems like it could be useful
elsewhere, too.

My use case is a bit niche; I'd like to use it in SIMD Everywhere
(<https://github.com/simd-everywhere/simde>) to limit the vector size even when
you call "larger" functions.  For example, simde_mm512_add_ps would be
implemented with two calls to simde_mm256_add_ps with -mprefer-vector-width=256
even if AVX-512F support is enabled.

That said, I think this could be useful for any code which mixes
auto-vectorization with intrinsics.

Reply via email to