public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/99698] New: [aarch64] Impossible to accurately detect extensions using preprocessor
@ 2021-03-21 17:01 evan@coeus-group.com
  2021-03-21 17:12 ` [Bug target/99698] " pinskia at gcc dot gnu.org
  2021-03-21 17:59 ` evan@coeus-group.com
  0 siblings, 2 replies; 3+ messages in thread
From: evan@coeus-group.com @ 2021-03-21 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99698
           Summary: [aarch64] Impossible to accurately detect extensions
                    using preprocessor
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: evan@coeus-group.com
  Target Milestone: ---

Using SHA3 as an example, but this problem exists for other extensions as well.

If you pass something like -march=armv8-a+sha3, GCC will define
__ARM_FEATURE_SHA3.  According to the ACLE documentation:

  __ARM_FEATURE_SHA3 is defined to 1 if the SHA1 & SHA2 Crypto instructions
  from Armv8-A and the SHA2 and SHA3 instructions from Armv8.2-A and newer
  are supported and intrinsics targeting them are available. These
  instructions include AES{E, D}, SHA1{C, P, M}, RAX, and others.

So, I should be able to use the preprocessor to call a function like vbcaxq_u32
if __ARM_FEATURE_SHA3 is defined to 1.

However, if I call vbcaxq_u32 I get an error about a target specific option
mismatch.  It turns out that you need -march=armv8.2-a+sha3 to convince GCC to
accept the function call.

AFAICT there is no way to reliably detect armv8.2-a.  The only difference in
the preprocessor macros defined for armv8-a and armv8.2-a are a few extra
__ARM_FEATURE_* macros.  There is *no* difference in pre-defined macros between
armv8.1-a and armv8.2-a.

FWIW, clang accepts -march=armv8-a+sha3, defines __ARM_FEATURE_SHA3 to 1, and
allows you to call the SHA3 functions, which seems pretty reasonable to me.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/99698] [aarch64] Impossible to accurately detect extensions using preprocessor
  2021-03-21 17:01 [Bug target/99698] New: [aarch64] Impossible to accurately detect extensions using preprocessor evan@coeus-group.com
@ 2021-03-21 17:12 ` pinskia at gcc dot gnu.org
  2021-03-21 17:59 ` evan@coeus-group.com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-03-21 17:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>AFAICT there is no way to reliably detect armv8.2-a. 

There is supposed to be ....  See PR 99312 .

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/99698] [aarch64] Impossible to accurately detect extensions using preprocessor
  2021-03-21 17:01 [Bug target/99698] New: [aarch64] Impossible to accurately detect extensions using preprocessor evan@coeus-group.com
  2021-03-21 17:12 ` [Bug target/99698] " pinskia at gcc dot gnu.org
@ 2021-03-21 17:59 ` evan@coeus-group.com
  1 sibling, 0 replies; 3+ messages in thread
From: evan@coeus-group.com @ 2021-03-21 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Evan Nemerson <evan@coeus-group.com> ---
Nice, thanks!  That would at least make testing possible, though I still think
that just checking __ARM_FEATURE_SHA3 should be sufficient, and ktkachov's
comment reinforces that.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-21 17:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 17:01 [Bug target/99698] New: [aarch64] Impossible to accurately detect extensions using preprocessor evan@coeus-group.com
2021-03-21 17:12 ` [Bug target/99698] " pinskia at gcc dot gnu.org
2021-03-21 17:59 ` evan@coeus-group.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).