[llvm] [LLVM][CodeGen][SVE] Lower to multivector stores (PR #207397)
Jacob Crawley via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 8 03:55:49 PDT 2026
================
@@ -7734,6 +7753,93 @@ static SDValue LowerNTStore(StoreSDNode *StoreNode, EVT VT, EVT MemVT,
return SDValue();
}
+// Lower scalable vectors that are 2/4 times the width of a legal SVE type to
+// multi-vector operations.
+static SDValue tryLowerMultiVectorStore(StoreSDNode *StoreNode,
+ SelectionDAG &DAG) {
+ SDValue Value = StoreNode->getValue();
+ EVT VT = Value.getValueType();
+ EVT MemVT = StoreNode->getMemoryVT();
+
+ if (!StoreNode->isSimple() || !StoreNode->isUnindexed() ||
+ StoreNode->isNonTemporal() || !StoreNode->getOffset().isUndef() ||
+ !VT.isScalableVector() || !VT.isSimple() || VT != MemVT)
+ return SDValue();
+
+ MVT StoreVT = VT.getSimpleVT();
+ MVT RegVT;
+ unsigned IntID;
+ unsigned NumVecs;
+
+ switch (StoreVT.SimpleTy) {
+ default:
+ return SDValue();
+
+ case MVT::nxv32i8:
+ case MVT::nxv16i16:
+ case MVT::nxv8i32:
+ case MVT::nxv4i64:
+ case MVT::nxv16f16:
+ case MVT::nxv8f32:
+ case MVT::nxv4f64:
+ case MVT::nxv16bf16:
+ IntID = Intrinsic::aarch64_sve_st1_pn_x2;
+ NumVecs = 2;
+ RegVT = StoreVT.getHalfNumVectorElementsVT();
+ break;
+ case MVT::nxv64i8:
+ case MVT::nxv32i16:
+ case MVT::nxv16i32:
+ case MVT::nxv8i64:
+ case MVT::nxv32f16:
+ case MVT::nxv16f32:
+ case MVT::nxv8f64:
+ case MVT::nxv32bf16:
+ IntID = Intrinsic::aarch64_sve_st1_pn_x4;
+ NumVecs = 4;
+ RegVT = StoreVT.getHalfNumVectorElementsVT().getHalfNumVectorElementsVT();
+ break;
+ }
+
+ unsigned PredIntID;
+ switch (StoreVT.getScalarSizeInBits()) {
+ default:
+ llvm_unreachable("covered by previous switch");
+ case 8:
+ PredIntID = Intrinsic::aarch64_sve_ptrue_c8;
+ break;
+ case 16:
+ PredIntID = Intrinsic::aarch64_sve_ptrue_c16;
+ break;
+ case 32:
+ PredIntID = Intrinsic::aarch64_sve_ptrue_c32;
+ break;
+ case 64:
+ PredIntID = Intrinsic::aarch64_sve_ptrue_c64;
+ break;
+ }
+
+ SDLoc DL(StoreNode);
+ SDValue PNg = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, MVT::aarch64svcount,
----------------
jacob-crawley wrote:
Done, I've moved the shared logic between load/stores in to helpers and also introduced a helper for the load logic to keep it similar to what we do for stores.
https://github.com/llvm/llvm-project/pull/207397
More information about the llvm-commits
mailing list