[llvm] [Analysis][SVE] Improve cost model for some extending masked loads (PR #65957)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 00:10:36 PDT 2023


================
@@ -2461,6 +2461,25 @@ InstructionCost AArch64TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
             FP16Tbl, ISD, DstTy.getSimpleVT(), SrcTy.getSimpleVT()))
       return AdjustCost(Entry->Cost);
 
+  if ((ISD == ISD::ZERO_EXTEND || ISD == ISD::SIGN_EXTEND) &&
+      CCH == TTI::CastContextHint::Masked && ST->hasSVEorSME() &&
+      TLI->getTypeAction(Src->getContext(), SrcTy) ==
+          TargetLowering::TypePromoteInteger &&
+      TLI->getTypeAction(Dst->getContext(), DstTy) ==
+          TargetLowering::TypeSplitVector) {
+    // The standard behaviour in the backend for these cases is to split the
+    // extend up into two parts:
+    //  1. Perform an extending load or masked load up to the legal type.
+    //  2. Extend the loaded data to the final type.
+    std::pair<InstructionCost, MVT> SrcLT = getTypeLegalizationCost(Src);
----------------
sdesmalen-arm wrote:

You're right, that makes sense. I see you've also added the explicit checks to ensure that SrcTy is promoted and DstTy needs splitting.

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


More information about the llvm-commits mailing list