[llvm] [AArch64] Lower factor-of-2 interleaved stores to STNP (PR #177938)

Tomer Shafir via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 27 09:17:18 PST 2026


================
@@ -1045,10 +1045,11 @@ bool LoopVectorizationLegality::canVectorizeInstr(Instruction &I) {
     // For nontemporal stores, check that a nontemporal vector version is
     // supported on the target.
     if (ST->getMetadata(LLVMContext::MD_nontemporal)) {
-      // Arbitrarily try a vector of 2 elements.
+      // Check a 2-element vector type, which implictly covers any power-of-2
+      // sized vector type by logically splitting to pairs
       auto *VecTy = FixedVectorType::get(T, /*NumElts=*/2);
       assert(VecTy && "did not find vectorized version of stored type");
-      if (!TTI->isLegalNTStore(VecTy, ST->getAlign())) {
+      if (!TTI->shouldVectorizeNTStore(VecTy, ST->getAlign())) {
----------------
tomershafir wrote:

I think this belongs to another patch. That would be a functional change to the vectorizer, which should be orthogonal to this patch series. I think it makes sense in general given that it would not regress compile time (as the exit would be later). A cost model approximation can be tricky because NT access depends on caching which is not really modeled AFAIK.

What matters here is differentiating the vectorizer use case from cases where we have full type information. The vectorizer doesn't have the final store type at legality check time (and it can be too costly to push NT load/store check down instead of exiting early), thus it requires different logic compared to what backend passes require with complete store type information. Thus we need 2 methods for 2 kinds of logic.

Thus, I think this shouldn't block this series, and we can remove the hooks later when we fix the vectorizer.

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


More information about the llvm-commits mailing list