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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 27 06:23:05 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())) {
----------------
fhahn wrote:

so this tries to work around the fact that we don't know the concrete types yet, right?

I think it would be better to avoid adding a new hook and make this more cost-driven.

I think ideally we would remove the check alltogether, and return invalid costs for the concrete vector stores with `!nontemporal`, if the type is not legal, although I am not sure if we have access to the `!nontermporal` info in the TTI cost hooks?

More generally, we should probably refine this even more, by considerng if the speedup from vectorizing is likely to outweigh the speedup from keeping things scalar just for the sake of preservinfg `!nontermporal`

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


More information about the llvm-commits mailing list