This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Force streaming-compatible codegen when attributes are set.
ClosedPublic

Authored by sdesmalen on Jul 17 2023, 1:37 AM.

Details

Summary

Before this patch, the only way to generate streaming-compatible code
was to use the -force-streaming-compatible-sve flag, but the compiler
should also avoid the use of instructions invalid in streaming mode
when a function has the aarch64_pstate_sm_enabled/compatible attribute.

Diff Detail

Event Timeline

sdesmalen created this revision.Jul 17 2023, 1:37 AM
sdesmalen requested review of this revision.Jul 17 2023, 1:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 17 2023, 1:37 AM
sdesmalen updated this revision to Diff 540928.Jul 17 2023, 3:08 AM

Fixed failing test (streaming-compatible-sve-no-maximize-bandwidth.ll) by forcing fixed-length autovec when -force-streaming-compatible-sve is used.

david-arm accepted this revision.Jul 17 2023, 8:43 AM
david-arm added a subscriber: david-arm.

LGTM! The change seems sensible to me.

This revision is now accepted and ready to land.Jul 17 2023, 8:43 AM
Matt added a subscriber: Matt.Jul 17 2023, 4:25 PM
paulwalker-arm accepted this revision.Jul 18 2023, 2:38 AM
This revision was landed with ongoing or failed builds.Jul 18 2023, 3:26 AM
This revision was automatically updated to reflect the committed changes.
dmgreen added inline comments.
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
480

Is there a reason why we don't do this "properly" (with quotes) by having the neon feature disabled when SSVE is being used?

sdesmalen added inline comments.Aug 10 2023, 3:26 AM
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
480

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.