[PATCH] D155428: [AArch64] Force streaming-compatible codegen when attributes are set.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 03:26:21 PDT 2023


sdesmalen added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.cpp:480
 
 bool AArch64Subtarget::isNeonAvailable() const {
   if (!hasNEON())
----------------
dmgreen wrote:
> Is there a reason why we don't do this "properly" (with quotes) by having the neon feature disabled when SSVE is being used?
Yes. We're trying to model two different concepts:
(1) target features regardless of runtime mode. E.g. `hasNEON()`, which is set by the target attributes such as `+simd`.
(2) target features for the given runtime mode, which is a subset of (1). These are controlled by the SME attributes such as `"aarch64_pstate_sm_compatible"`.

(1) allows the compiler to parse/emit NEON instructions that are predicated under the `HasNEON` Predicates in TableGen.

When a function is marked as streaming compatible (i.e. it must be able to run both in streaming mode as well as non-streaming mode)  we want to avoid the compiler from using NEON instructions because if the processor is in streaming-SVE mode at runtime, the NEON instructions will be invalid. This is (2), which we represent this by the interface, `isNeonAvailable()`). We can use this interface to tell SelectionDAG to lower ISD nodes using streaming-compatible SVE instructions instead of using NEON.

The reason we can't use (1), is that a user should still be able to write NEON that compiles, provided that they properly guard the code with `if (!__arm_in_streaming_mode()) { /* NEON code here */ }`. A user should also be allowed to write inline-asm that disables streaming mode, executes code with NEON instructions, and then re-enables streaming-mode afterwards. If the target being compiled for doesn't allow NEON instructions (i.e. `hasNEON() == false`), LLVM can't emit them regardless of the runtime mode.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155428/new/

https://reviews.llvm.org/D155428



More information about the llvm-commits mailing list