[clang] [llvm] [AArch64][SME] Allow more inlining when SME attributes are incompatible. (PR #223393)

Benjamin Maxwell via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 05:23:17 PDT 2026


================
@@ -230,30 +230,114 @@ static cl::opt<bool> EnableFixedwidthAutovecInStreamingMode(
 static cl::opt<bool> EnableScalableAutovecInStreamingMode(
     "enable-scalable-autovec-in-streaming-mode", cl::init(false), cl::Hidden);
 
-static bool isSMEABIRoutineCall(const CallInst &CI,
-                                const AArch64TargetLowering &TLI) {
-  const auto *F = CI.getCalledFunction();
-  return F &&
-         SMEAttrs(F->getName(), TLI.getRuntimeLibcallsInfo()).isSMEABIRoutine();
+/// Returns true if \p I is an intrinsic that may not be compatible in the mode
+/// of the caller. If \p AssumeVScaleIsEquivalent is true, then we can allow
+/// operations that dependent on vscale as long as they are available in both
+/// streaming/non-streaming mode.
+static bool
+isPossiblyIncompatibleIntrinsicInStreamingMode(const Instruction *I,
+                                               bool AssumeVScaleIsEquivalent) {
+  auto *II = dyn_cast<IntrinsicInst>(I);
+  if (!II)
+    return false;
+
+  unsigned IID = II->getIntrinsicID();
+  switch (IID) {
+  default:
+    // Conservatively disallow target intrinsics in other modes.
+    return Intrinsic::isTargetIntrinsic(IID);
+  case Intrinsic::vscale:
+    return !AssumeVScaleIsEquivalent;
+  case Intrinsic::masked_gather:
+    // Instructions that are not available in streaming mode.
+    // Fixed-length operations can still be code-generated by scalarizing.
+    // FIXME: Consider FEAT_FA64.
+    return I->getType()->isScalableTy();
+  case Intrinsic::masked_scatter:
+  case Intrinsic::masked_compressstore:
----------------
MacDue wrote:

For cases like `masked_compresstore` it might make sense to instead call `TTI` `isLegalMaskedCompressStore` (just using the TTI of the function being inlined to).

I think that already includes the checks around SME (and will return false for streaming functions unless +sme2p2 is available). Similar for `expandload`. 

https://github.com/llvm/llvm-project/pull/223393


More information about the cfe-commits mailing list