[llvm-branch-commits] [llvm] [AArch64] Improve cost model for legal subvec insert/extract (PR #81135)
@@ -568,6 +568,48 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes , } return Cost; } + case Intrinsic::vector_extract: { +// If both the vector argument and the return type are legal types and the +// index is 0, then this should be a no-op or simple operation; return a +// relatively low cost. + +// If arguments aren't actually supplied, then we cannot determine the +// value of the index. +if (ICA.getArgs().size() < 2) + break; +LLVMContext = RetTy->getContext(); +EVT MRTy = getTLI()->getValueType(DL, RetTy); +EVT MPTy = getTLI()->getValueType(DL, ICA.getArgTypes()[0]); +TargetLoweringBase::LegalizeKind RLK = getTLI()->getTypeConversion(C, MRTy); +TargetLoweringBase::LegalizeKind PLK = getTLI()->getTypeConversion(C, MPTy); +const ConstantInt *Idx = dyn_cast(ICA.getArgs()[1]); +if (RLK.first == TargetLoweringBase::TypeLegal && +PLK.first == TargetLoweringBase::TypeLegal && Idx && +Idx->getZExtValue() == 0) + return InstructionCost(1); sdesmalen-arm wrote: Is there a reason this wouldn't this be zero-cost? Also, stylistically to match the rest of this file, maybe return `TTI::TCC_Free` (if this is considered a cost of 0) or `TTI::TCC_Basic` (if this is considered a cost of 1) instead? https://github.com/llvm/llvm-project/pull/81135 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AArch64] Improve cost model for legal subvec insert/extract (PR #81135)
@@ -568,6 +568,48 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes , } return Cost; } + case Intrinsic::vector_extract: { +// If both the vector argument and the return type are legal types and the +// index is 0, then this should be a no-op or simple operation; return a +// relatively low cost. + +// If arguments aren't actually supplied, then we cannot determine the +// value of the index. +if (ICA.getArgs().size() < 2) sdesmalen-arm wrote: nit: ```suggestion if (ICA.getArgs().size() != 2) ``` https://github.com/llvm/llvm-project/pull/81135 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AArch64] Improve cost model for legal subvec insert/extract (PR #81135)
@@ -568,6 +568,32 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes , } return Cost; } + case Intrinsic::vector_extract: { +// If both the vector argument and the return type are legal types, then +// this should be a no-op or simple operation; return a relatively low cost. +LLVMContext = RetTy->getContext(); +EVT MRTy = getTLI()->getValueType(DL, RetTy); +EVT MPTy = getTLI()->getValueType(DL, ICA.getArgTypes()[0]); +TargetLoweringBase::LegalizeKind RLK = getTLI()->getTypeConversion(C, MRTy); +TargetLoweringBase::LegalizeKind PLK = getTLI()->getTypeConversion(C, MPTy); +if (RLK.first == TargetLoweringBase::TypeLegal && +PLK.first == TargetLoweringBase::TypeLegal) + return InstructionCost(1); sdesmalen-arm wrote: Just pointing out that the code isn't updated yet to handle predicates differently, as those inserts/extracts are indeed not free. https://github.com/llvm/llvm-project/pull/81135 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AArch64] Improve cost model for legal subvec insert/extract (PR #81135)
https://github.com/huntergr-arm edited https://github.com/llvm/llvm-project/pull/81135 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits