================
@@ -233,23 +233,99 @@ static bool isSMEABIRoutineCall(const CallInst &CI,
SMEAttrs(F->getName(),
TLI.getRuntimeLibcallsInfo()).isSMEABIRoutine();
}
+/// Returns true if \p I is an intrinsic that may not be compatible with a
+/// different streaming mode (because it depends on vscale).
+static bool isPossiblyIncompatibleIntrinsic(const Instruction *I) {
+ if (I->isDebugOrPseudoInst())
+ return false;
+
+ if (auto *II = dyn_cast<IntrinsicInst>(I)) {
+ switch (II->getIntrinsicID()) {
+ default:
+ break;
+ case Intrinsic::vscale:
+ case Intrinsic::masked_gather:
+ case Intrinsic::masked_scatter:
+ return true;
+ }
+
+ StringRef Name = II->getCalledFunction()->getName();
+ if (Name.starts_with("llvm.aarch64.neon") ||
+ Name.starts_with("llvm.aarch64.sve") ||
+ Name.starts_with("llvm.aarch64.sme"))
+ return true;
+ }
+
+ return false;
+}
+
+/// Returns true if \p IA has "za" in its clobber list.
+static bool hasZAClobber(const InlineAsm *IA) {
+ for (const InlineAsm::ConstraintInfo &CI : IA->ParseConstraints()) {
+ if (CI.Type != llvm::InlineAsm::ConstraintPrefix::isClobber)
+ continue;
+ if (any_of(CI.Codes, [](StringRef S) { return S == "{za}"; }))
+ return true;
+ }
+ return false;
+}
+
/// Returns true if the function has explicit operations that can only be
/// lowered using incompatible instructions for the selected mode. This also
/// returns true if the function F may use or modify ZA state.
static bool hasPossibleIncompatibleOps(const Function *F,
- const AArch64TargetLowering &TLI) {
+ const AArch64TargetLowering &TLI,
+ bool ConsiderZA, bool ConsiderSM) {
+ assert((ConsiderZA || ConsiderSM) && "No SME state to consider");
+
+ bool HasVLDependentArgsOrRet =
+ F->getReturnType()->isScalableTy() ||
+ any_of(F->getFunctionType()->params(),
+ [](const Type *T) { return T->isScalableTy(); });
+
for (const BasicBlock &BB : *F) {
for (const Instruction &I : BB) {
- // Be conservative for now and assume that any call to inline asm or to
- // intrinsics could could result in non-streaming ops (e.g. calls to
- // @llvm.aarch64.* or @llvm.gather/scatter intrinsics). We can assume
that
- // all native LLVM instructions can be lowered to compatible
instructions.
- if (isa<CallInst>(I) && !I.isDebugOrPseudoInst() &&
- (cast<CallInst>(I).isInlineAsm() || isa<IntrinsicInst>(I) ||
- isSMEABIRoutineCall(cast<CallInst>(I), TLI)))
+ // Inlining operations on fixed-length vectors when the streaming
+ // mode does not match, is rejected because performance may be impacted.
+ // This decision should eventually be moved the cost-model.
+ if (ConsiderSM && (isa<FixedVectorType>(I.getType()) ||
----------------
MacDue wrote:
Do we want to allow this for the `alwaysinline` case in this patch? I think
this is only a concern for the standard inliner.
https://github.com/llvm/llvm-project/pull/223393
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits