[llvm] [AArch64][TTI] Improve `LegalVF` when computing gather-loads cost (PR #69617)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 12:10:50 PDT 2023


================
@@ -2989,7 +2989,14 @@ InstructionCost AArch64TTIImpl::getGatherScatterOpCost(
       ElementCount::getScalable(1))
     return InstructionCost::getInvalid();
 
-  ElementCount LegalVF = LT.second.getVectorElementCount();
+  ElementCount LegalVF;
+  if (LT.second.isVector()) {
+    LegalVF = LT.second.getVectorElementCount();
+  } else {
+    // If the legalized type is a simple type, treat it as a 1-element vector.
+    LegalVF = ElementCount::getFixed(1);
+  }
+
----------------
alexey-bataev wrote:

If thу vector type gets scalarized (like in your check), isLegalMaskedGather() shall return false for such types, even though useNeonVector() returns true. SLP shall not assume emitting masked gather here at all, the scalarization increases the cost significantly, we should end up with the simple gather here

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


More information about the llvm-commits mailing list