[llvm] [AArch64][SDAG][NFC] Use CNTP intrinsic for MSTORE lowering (PR #218353)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 24 01:58:54 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Jack Styles (Stylie777)
<details>
<summary>Changes</summary>
Currently, when lowering MSTORE the process is to Zero Extend, VECREDUCE_ADD and then Zero Extend the result for types that are not i64. This for i8/i16 types does not work as AArch64 cannot zero extend these types to i64. Instead, use the CNTP intrinsic to combine the values before storing them.
---
Full diff: https://github.com/llvm/llvm-project/pull/218353.diff
1 Files Affected:
- (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+4-9)
``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 36a86241fe3b2..c1ca0f789e534 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -33922,16 +33922,11 @@ SDValue AArch64TargetLowering::LowerMSTORE(SDValue Op,
return SDValue();
EVT MaskVT = Store->getMask().getValueType();
- EVT MaskExtVT = getPromotedVTForPredicate(MaskVT);
- EVT MaskReduceVT = MaskExtVT.getScalarType();
SDValue Zero = DAG.getConstant(0, DL, MVT::i64);
-
- SDValue MaskExt =
- DAG.getNode(ISD::ZERO_EXTEND, DL, MaskExtVT, Store->getMask());
- SDValue CntActive =
- DAG.getNode(ISD::VECREDUCE_ADD, DL, MaskReduceVT, MaskExt);
- if (MaskReduceVT != MVT::i64)
- CntActive = DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i64, CntActive);
+ SDValue CntActive = DAG.getNode(
+ ISD::INTRINSIC_WO_CHAIN, DL, MVT::i64,
+ DAG.getTargetConstant(Intrinsic::aarch64_sve_cntp, DL, MVT::i64),
+ Store->getMask(), Store->getMask());
SDValue CompressedValue =
DAG.getNode(ISD::VECTOR_COMPRESS, DL, VT, Store->getValue(),
``````````
</details>
https://github.com/llvm/llvm-project/pull/218353
More information about the llvm-commits
mailing list