diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -1394,12 +1394,14 @@ for (auto VT : {MVT::v4f16, MVT::v8f16, MVT::v2f32, MVT::v4f32, MVT::v2f64}) setOperationAction(ISD::VECREDUCE_SEQ_FADD, VT, Custom); - if (Subtarget->forceStreamingModeCompatibleSVE()) { - for (MVT VT : MVT::integer_fixedlen_vector_valuetypes()) + if (Subtarget->forceStreamingCompatibleSVE()) { + for (MVT VT : {MVT::v8i8, MVT::v16i8, MVT::v4i16, MVT::v8i16, MVT::v2i32, + MVT::v4i32, MVT::v1i64, MVT::v2i64}) if (useSVEForFixedLengthVectorVT(VT, true)) addTypeForStreamingSVE(VT); - for (MVT VT : MVT::fp_fixedlen_vector_valuetypes()) + for (MVT VT : {MVT::v4f16, MVT::v8f16, MVT::v2f32, + MVT::v4f32, MVT::v1f64, MVT::v2f64}) if (useSVEForFixedLengthVectorVT(VT, true)) addTypeForStreamingSVE(VT); } @@ -1612,6 +1614,10 @@ void AArch64TargetLowering::addTypeForStreamingSVE(MVT VT) { setOperationAction(ISD::LOAD, VT, Custom); + setOperationAction(ISD::ANY_EXTEND, VT, Custom); + setOperationAction(ISD::ZERO_EXTEND, VT, Custom); + setOperationAction(ISD::SIGN_EXTEND, VT, Custom); + setOperationAction(ISD::CONCAT_VECTORS, VT, Custom); } void AArch64TargetLowering::addTypeForFixedLengthSVE(MVT VT) { @@ -5774,8 +5780,8 @@ case ISD::MLOAD: return LowerMLOAD(Op, DAG); case ISD::LOAD: - if (useSVEForFixedLengthVectorVT(Op.getValueType(), - Subtarget->forceStreamingModeCompatibleSVE())) + if (useSVEForFixedLengthVectorVT( + Op.getValueType(), Subtarget->forceStreamingCompatibleSVE())) return LowerFixedLengthVectorLoadToSVE(Op, DAG); return LowerLOAD(Op, DAG); case ISD::ADD: @@ -10896,7 +10902,8 @@ ShuffleVectorSDNode *SVN = cast(Op.getNode()); - if (useSVEForFixedLengthVectorVT(VT)) + if (useSVEForFixedLengthVectorVT( + VT, Subtarget->forceStreamingCompatibleSVE())) return LowerFixedLengthVECTOR_SHUFFLEToSVE(Op, DAG); // Convert shuffles that are directly supported on NEON to target-specific @@ -11586,9 +11593,8 @@ SelectionDAG &DAG) const { EVT VT = Op.getValueType(); - // override NEON if possible. - if (useSVEForFixedLengthVectorVT(VT, - Subtarget->forceStreamingModeCompatibleSVE())) { + if (useSVEForFixedLengthVectorVT( + VT, Subtarget->forceStreamingCompatibleSVE())) { if (auto SeqInfo = cast(Op)->isConstantSequence()) { SDLoc DL(Op); EVT ContainerVT = getContainerForFixedLengthVector(DAG, VT); @@ -11918,7 +11924,8 @@ SDValue AArch64TargetLowering::LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const { - if (useSVEForFixedLengthVectorVT(Op.getValueType())) + if (useSVEForFixedLengthVectorVT( + Op.getValueType(), Subtarget->forceStreamingCompatibleSVE())) return LowerFixedLengthConcatVectorsToSVE(Op, DAG); assert(Op.getValueType().isScalableVector() && @@ -12024,8 +12031,8 @@ return DAG.getAnyExtOrTrunc(Extract, DL, Op.getValueType()); } - // try overriding NEON if possible. - if (useSVEForFixedLengthVectorVT(VT)) + if (useSVEForFixedLengthVectorVT( + VT, Subtarget->forceStreamingCompatibleSVE())) return LowerFixedLengthExtractVectorElt(Op, DAG); // Check for non-constant or out of range lane. @@ -12084,13 +12091,16 @@ if (Idx == 0 && InVT.getSizeInBits() <= 128) return Op; - // If this is extracting the upper 64-bits of a 128-bit vector, we match - // that directly. - if (Size == 64 && Idx * InVT.getScalarSizeInBits() == 64 && - InVT.getSizeInBits() == 128) - return Op; + if (!Subtarget->forceStreamingCompatibleSVE()) { + // If this is extracting the upper 64-bits of a 128-bit vector, we match + // that directly. + if (Size == 64 && Idx * InVT.getScalarSizeInBits() == 64 && + InVT.getSizeInBits() == 128) + return Op; + } - if (useSVEForFixedLengthVectorVT(InVT)) { + if (useSVEForFixedLengthVectorVT( + InVT, Subtarget->forceStreamingCompatibleSVE())) { SDLoc DL(Op); EVT ContainerVT = getContainerForFixedLengthVector(DAG, InVT); @@ -12388,8 +12398,9 @@ switch (Op.getOpcode()) { case ISD::SHL: - // override NEON if possible. - if (VT.isScalableVector() || useSVEForFixedLengthVectorVT(VT)) + if (VT.isScalableVector() || + useSVEForFixedLengthVectorVT( + VT, Subtarget->forceStreamingCompatibleSVE())) return LowerToPredicatedOp(Op, DAG, AArch64ISD::SHL_PRED); if (isVShiftLImm(Op.getOperand(1), VT, false, Cnt) && Cnt < EltSize) @@ -12401,8 +12412,9 @@ Op.getOperand(0), Op.getOperand(1)); case ISD::SRA: case ISD::SRL: - // override NEON if possible. - if (VT.isScalableVector() || useSVEForFixedLengthVectorVT(VT)) { + if (VT.isScalableVector() || + useSVEForFixedLengthVectorVT( + VT, Subtarget->forceStreamingCompatibleSVE())) { unsigned Opc = Op.getOpcode() == ISD::SRA ? AArch64ISD::SRA_PRED : AArch64ISD::SRL_PRED; return LowerToPredicatedOp(Op, DAG, Opc); diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td @@ -218,6 +218,8 @@ def UseScalarIncVL : Predicate<"Subtarget->useScalarIncVL()">; +def IsStreamingCompatibleSVEDisabled : Predicate<"!Subtarget->forceStreamingCompatibleSVE()">; + def AArch64LocalRecover : SDNode<"ISD::LOCAL_RECOVER", SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisInt<1>]>>; diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td --- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -3032,30 +3032,31 @@ (EXTRACT_SUBREG (DUP_ZZI_D ZPR:$vec, sve_elm_idx_extdup_d:$index), dsub)>; // Extract element from vector with immediate index that's within the bottom 128-bits. - let AddedComplexity = 1 in { - def : Pat<(i32 (vector_extract (nxv16i8 ZPR:$vec), VectorIndexB:$index)), - (i32 (UMOVvi8 (v16i8 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexB:$index))>; - def : Pat<(i32 (vector_extract (nxv8i16 ZPR:$vec), VectorIndexH:$index)), - (i32 (UMOVvi16 (v8i16 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexH:$index))>; - def : Pat<(i32 (vector_extract (nxv4i32 ZPR:$vec), VectorIndexS:$index)), - (i32 (UMOVvi32 (v4i32 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexS:$index))>; - def : Pat<(i64 (vector_extract (nxv2i64 ZPR:$vec), VectorIndexD:$index)), - (i64 (UMOVvi64 (v2i64 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexD:$index))>; - } - - def : Pat<(sext_inreg (vector_extract (nxv16i8 ZPR:$vec), VectorIndexB:$index), i8), - (i32 (SMOVvi8to32 (v16i8 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexB:$index))>; - def : Pat<(sext_inreg (anyext (vector_extract (nxv16i8 ZPR:$vec), VectorIndexB:$index)), i8), - (i64 (SMOVvi8to64 (v16i8 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexB:$index))>; + let Predicates = [IsStreamingCompatibleSVEDisabled] in { + let AddedComplexity = 1 in { + def : Pat<(i32 (vector_extract (nxv16i8 ZPR:$vec), VectorIndexB:$index)), + (i32 (UMOVvi8 (v16i8 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexB:$index))>; + def : Pat<(i32 (vector_extract (nxv8i16 ZPR:$vec), VectorIndexH:$index)), + (i32 (UMOVvi16 (v8i16 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexH:$index))>; + def : Pat<(i32 (vector_extract (nxv4i32 ZPR:$vec), VectorIndexS:$index)), + (i32 (UMOVvi32 (v4i32 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexS:$index))>; + def : Pat<(i64 (vector_extract (nxv2i64 ZPR:$vec), VectorIndexD:$index)), + (i64 (UMOVvi64 (v2i64 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexD:$index))>; + } - def : Pat<(sext_inreg (vector_extract (nxv8i16 ZPR:$vec), VectorIndexH:$index), i16), - (i32 (SMOVvi16to32 (v8i16 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexH:$index))>; - def : Pat<(sext_inreg (anyext (vector_extract (nxv8i16 ZPR:$vec), VectorIndexH:$index)), i16), - (i64 (SMOVvi16to64 (v8i16 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexH:$index))>; + def : Pat<(sext_inreg (vector_extract (nxv16i8 ZPR:$vec), VectorIndexB:$index), i8), + (i32 (SMOVvi8to32 (v16i8 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexB:$index))>; + def : Pat<(sext_inreg (anyext (vector_extract (nxv16i8 ZPR:$vec), VectorIndexB:$index)), i8), + (i64 (SMOVvi8to64 (v16i8 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexB:$index))>; - def : Pat<(sext (vector_extract (nxv4i32 ZPR:$vec), VectorIndexS:$index)), - (i64 (SMOVvi32to64 (v4i32 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexS:$index))>; + def : Pat<(sext_inreg (vector_extract (nxv8i16 ZPR:$vec), VectorIndexH:$index), i16), + (i32 (SMOVvi16to32 (v8i16 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexH:$index))>; + def : Pat<(sext_inreg (anyext (vector_extract (nxv8i16 ZPR:$vec), VectorIndexH:$index)), i16), + (i64 (SMOVvi16to64 (v8i16 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexH:$index))>; + def : Pat<(sext (vector_extract (nxv4i32 ZPR:$vec), VectorIndexS:$index)), + (i64 (SMOVvi32to64 (v4i32 (EXTRACT_SUBREG ZPR:$vec, zsub)), VectorIndexS:$index))>; + } // Extract first element from vector. let AddedComplexity = 2 in { def : Pat<(vector_extract (nxv16i8 ZPR:$Zs), (i64 0)), diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h b/llvm/lib/Target/AArch64/AArch64Subtarget.h --- a/llvm/lib/Target/AArch64/AArch64Subtarget.h +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h @@ -361,7 +361,7 @@ bool useSVEForFixedLengthVectors() const; - bool forceStreamingModeCompatibleSVE() const; + bool forceStreamingCompatibleSVE() const; unsigned getVScaleForTuning() const { return VScaleForTuning; } diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp --- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp @@ -66,8 +66,8 @@ cl::CommaSeparated, cl::Hidden); static cl::opt - ForceStreamingModeCompatibleSVE("force-streaming-mode-compatible-sve", - cl::init(false), cl::Hidden); + ForceStreamingCompatibleSVE("force-streaming-compatible-sve", + cl::init(false), cl::Hidden); unsigned AArch64Subtarget::getVectorInsertExtractBaseCost() const { if (OverrideVectorInsertExtractBaseCost.getNumOccurrences() > 0) @@ -437,15 +437,19 @@ bool AArch64Subtarget::useAA() const { return UseAA; } bool AArch64Subtarget::useSVEForFixedLengthVectors() const { - if (ForceStreamingModeCompatibleSVE) + if (ForceStreamingCompatibleSVE) { + assert(hasSVE() && "Expected SVE to be available"); return hasSVE(); + } // Prefer NEON unless larger SVE registers are available. return hasSVE() && getMinSVEVectorSizeInBits() >= 256; } -bool AArch64Subtarget::forceStreamingModeCompatibleSVE() const { - if (ForceStreamingModeCompatibleSVE) +bool AArch64Subtarget::forceStreamingCompatibleSVE() const { + if (ForceStreamingCompatibleSVE) { + assert(hasSVE() && "Expected SVE to be available"); return hasSVE(); + } return false; } diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-ext-loads.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-ext-loads.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-ext-loads.ll @@ -0,0 +1,216 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -force-streaming-compatible-sve < %s | FileCheck %s + +target triple = "aarch64-unknown-linux-gnu" + +define <8 x i16> @load_zext_v8i8i16(<8 x i8>* %ap) #0 { +; CHECK-LABEL: load_zext_v8i8i16: +; CHECK: // %bb.0: +; CHECK-NEXT: mov w8, #4 +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: ld1b { z1.h }, p0/z, [x0, x8] +; CHECK-NEXT: ld1b { z0.h }, p0/z, [x0] +; CHECK-NEXT: splice z0.h, p0, z0.h, z1.h +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %a = load <8 x i8>, <8 x i8>* %ap + %val = zext <8 x i8> %a to <8 x i16> + ret <8 x i16> %val +} + +define <4 x i32> @load_zext_v4i16i32(<4 x i16>* %ap) #0 { +; CHECK-LABEL: load_zext_v4i16i32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0] +; CHECK-NEXT: uunpklo z0.s, z0.h +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %a = load <4 x i16>, <4 x i16>* %ap + %val = zext <4 x i16> %a to <4 x i32> + ret <4 x i32> %val +} + +define <2 x i64> @load_zext_v2i32i64(<2 x i32>* %ap) #0 { +; CHECK-LABEL: load_zext_v2i32i64: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s, vl2 +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0] +; CHECK-NEXT: uunpklo z0.d, z0.s +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %a = load <2 x i32>, <2 x i32>* %ap + %val = zext <2 x i32> %a to <2 x i64> + ret <2 x i64> %val +} + +define <2 x i256> @load_zext_v2i64i256(<2 x i64>* %ap) #0 { +; CHECK-LABEL: load_zext_v2i64i256: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI3_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI3_0 +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: mov x1, xzr +; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0] +; CHECK-NEXT: mov x5, xzr +; CHECK-NEXT: ld1d { z1.d }, p0/z, [x8] +; CHECK-NEXT: mov z2.d, z0.d[1] +; CHECK-NEXT: fmov x0, d0 +; CHECK-NEXT: mov z0.d, z1.d[1] +; CHECK-NEXT: fmov x2, d1 +; CHECK-NEXT: fmov x3, d0 +; CHECK-NEXT: fmov x4, d2 +; CHECK-NEXT: mov x6, x2 +; CHECK-NEXT: mov x7, x3 +; CHECK-NEXT: ret + %a = load <2 x i64>, <2 x i64>* %ap + %val = zext <2 x i64> %a to <2 x i256> + ret <2 x i256> %val +} + +define <16 x i32> @load_sext_v16i8i32(<16 x i8>* %ap) #0 { +; CHECK-LABEL: load_sext_v16i8i32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.b, vl16 +; CHECK-NEXT: ld1b { z1.b }, p0/z, [x0] +; CHECK-NEXT: sunpklo z3.h, z1.b +; CHECK-NEXT: ext z1.b, z1.b, z1.b, #8 +; CHECK-NEXT: sunpklo z4.h, z1.b +; CHECK-NEXT: sunpklo z0.s, z3.h +; CHECK-NEXT: ext z3.b, z3.b, z3.b, #8 +; CHECK-NEXT: sunpklo z2.s, z4.h +; CHECK-NEXT: ext z4.b, z4.b, z4.b, #8 +; CHECK-NEXT: sunpklo z1.s, z3.h +; CHECK-NEXT: sunpklo z3.s, z4.h +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: // kill: def $q2 killed $q2 killed $z2 +; CHECK-NEXT: // kill: def $q3 killed $q3 killed $z3 +; CHECK-NEXT: ret + %a = load <16 x i8>, <16 x i8>* %ap + %val = sext <16 x i8> %a to <16 x i32> + ret <16 x i32> %val +} + +define <8 x i32> @load_sext_v8i16i32(<8 x i16>* %ap) #0 { +; CHECK-LABEL: load_sext_v8i16i32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.h, vl8 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x0] +; CHECK-NEXT: sunpklo z0.s, z1.h +; CHECK-NEXT: ext z1.b, z1.b, z1.b, #8 +; CHECK-NEXT: sunpklo z1.s, z1.h +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: ret + %a = load <8 x i16>, <8 x i16>* %ap + %val = sext <8 x i16> %a to <8 x i32> + ret <8 x i32> %val +} + +define <4 x i256> @load_sext_v4i32i256(<4 x i32>* %ap) #0 { +; CHECK-LABEL: load_sext_v4i32i256: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0] +; CHECK-NEXT: sunpklo z1.d, z0.s +; CHECK-NEXT: ext z0.b, z0.b, z0.b, #8 +; CHECK-NEXT: fmov x9, d1 +; CHECK-NEXT: mov z1.d, z1.d[1] +; CHECK-NEXT: fmov x11, d1 +; CHECK-NEXT: sunpklo z0.d, z0.s +; CHECK-NEXT: asr x10, x9, #63 +; CHECK-NEXT: asr x12, x11, #63 +; CHECK-NEXT: stp x9, x10, [x8] +; CHECK-NEXT: fmov x9, d0 +; CHECK-NEXT: mov z0.d, z0.d[1] +; CHECK-NEXT: stp x11, x12, [x8, #32] +; CHECK-NEXT: fmov x11, d0 +; CHECK-NEXT: stp x10, x10, [x8, #16] +; CHECK-NEXT: stp x12, x12, [x8, #48] +; CHECK-NEXT: asr x10, x9, #63 +; CHECK-NEXT: asr x12, x11, #63 +; CHECK-NEXT: stp x10, x10, [x8, #80] +; CHECK-NEXT: stp x9, x10, [x8, #64] +; CHECK-NEXT: stp x12, x12, [x8, #112] +; CHECK-NEXT: stp x11, x12, [x8, #96] +; CHECK-NEXT: ret + %a = load <4 x i32>, <4 x i32>* %ap + %val = sext <4 x i32> %a to <4 x i256> + ret <4 x i256> %val +} + +define <2 x i256> @load_sext_v2i64i256(<2 x i64>* %ap) #0 { +; CHECK-LABEL: load_sext_v2i64i256: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0] +; CHECK-NEXT: mov z1.d, z0.d[1] +; CHECK-NEXT: fmov x8, d0 +; CHECK-NEXT: fmov x9, d1 +; CHECK-NEXT: asr x8, x8, #63 +; CHECK-NEXT: asr x9, x9, #63 +; CHECK-NEXT: fmov d2, x8 +; CHECK-NEXT: fmov d3, x9 +; CHECK-NEXT: zip1 z0.d, z0.d, z2.d +; CHECK-NEXT: zip1 z2.d, z2.d, z2.d +; CHECK-NEXT: zip1 z1.d, z1.d, z3.d +; CHECK-NEXT: mov z4.d, z0.d[1] +; CHECK-NEXT: fmov x0, d0 +; CHECK-NEXT: mov z0.d, z2.d[1] +; CHECK-NEXT: fmov x2, d2 +; CHECK-NEXT: mov z2.d, z1.d[1] +; CHECK-NEXT: fmov x4, d1 +; CHECK-NEXT: zip1 z1.d, z3.d, z3.d +; CHECK-NEXT: fmov x3, d0 +; CHECK-NEXT: mov z0.d, z1.d[1] +; CHECK-NEXT: fmov x1, d4 +; CHECK-NEXT: fmov x6, d1 +; CHECK-NEXT: fmov x5, d2 +; CHECK-NEXT: fmov x7, d0 +; CHECK-NEXT: ret + %a = load <2 x i64>, <2 x i64>* %ap + %val = sext <2 x i64> %a to <2 x i256> + ret <2 x i256> %val +} + +define <16 x i64> @load_zext_v16i16i64(<16 x i16>* %ap) #0 { +; CHECK-LABEL: load_zext_v16i16i64: +; CHECK: // %bb.0: +; CHECK-NEXT: mov x8, #8 +; CHECK-NEXT: ptrue p0.h, vl8 +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0, x8, lsl #1] +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x0] +; CHECK-NEXT: uunpklo z2.s, z0.h +; CHECK-NEXT: ext z0.b, z0.b, z0.b, #8 +; CHECK-NEXT: uunpklo z3.s, z1.h +; CHECK-NEXT: ext z1.b, z1.b, z1.b, #8 +; CHECK-NEXT: uunpklo z4.d, z2.s +; CHECK-NEXT: ext z2.b, z2.b, z2.b, #8 +; CHECK-NEXT: uunpklo z7.s, z0.h +; CHECK-NEXT: uunpklo z16.s, z1.h +; CHECK-NEXT: uunpklo z0.d, z3.s +; CHECK-NEXT: ext z3.b, z3.b, z3.b, #8 +; CHECK-NEXT: uunpklo z5.d, z2.s +; CHECK-NEXT: uunpklo z6.d, z7.s +; CHECK-NEXT: ext z7.b, z7.b, z7.b, #8 +; CHECK-NEXT: uunpklo z2.d, z16.s +; CHECK-NEXT: ext z16.b, z16.b, z16.b, #8 +; CHECK-NEXT: uunpklo z1.d, z3.s +; CHECK-NEXT: uunpklo z7.d, z7.s +; CHECK-NEXT: uunpklo z3.d, z16.s +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: // kill: def $q2 killed $q2 killed $z2 +; CHECK-NEXT: // kill: def $q3 killed $q3 killed $z3 +; CHECK-NEXT: // kill: def $q4 killed $q4 killed $z4 +; CHECK-NEXT: // kill: def $q5 killed $q5 killed $z5 +; CHECK-NEXT: // kill: def $q6 killed $q6 killed $z6 +; CHECK-NEXT: // kill: def $q7 killed $q7 killed $z7 +; CHECK-NEXT: ret + %a = load <16 x i16>, <16 x i16>* %ap + %val = zext <16 x i16> %a to <16 x i64> + ret <16 x i64> %val +} + +attributes #0 = { "target-features"="+sve" } diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-loads.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-loads.ll --- a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-loads.ll +++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-loads.ll @@ -1,20 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -aarch64-sve-vector-bits-min=128 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=256 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=384 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=512 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=640 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=768 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=896 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1024 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1152 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1280 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1408 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1536 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1664 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1792 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1920 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=2048 -force-streaming-mode-compatible-sve < %s | FileCheck %s +; RUN: llc -force-streaming-compatible-sve < %s | FileCheck %s target triple = "aarch64-unknown-linux-gnu" @@ -82,9 +67,18 @@ ret <4 x float> %load } -define <32 x float> @load_v32f32(<32 x float>* %a) #0 { - %load = load <32 x float>, <32 x float>* %a - ret <32 x float> %load +define <8 x float> @load_v8f32(<8 x float>* %a) #0 { +; CHECK-LABEL: load_v8f32: +; CHECK: // %bb.0: +; CHECK-NEXT: mov x8, #2 +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: ld1d { z1.d }, p0/z, [x0, x8, lsl #3] +; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: ret + %load = load <8 x float>, <8 x float>* %a + ret <8 x float> %load } define <2 x double> @load_v2f64(<2 x double>* %a) #0 { diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-masked-load.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-masked-load.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-masked-load.ll @@ -0,0 +1,402 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -force-streaming-compatible-sve < %s | FileCheck %s + +target triple = "aarch64-unknown-linux-gnu" + +; +; Masked Load +; + +define <4 x i8> @masked_load_v4i8(<4 x i8>* %src, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v4i8: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI0_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI0_0 +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: ld1b { z0.h }, p0/z, [x0] +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: ret + %load = call <4 x i8> @llvm.masked.load.v4i8(<4 x i8>* %src, i32 8, <4 x i1> %mask, <4 x i8> zeroinitializer) + ret <4 x i8> %load +} + +define <8 x i8> @masked_load_v8i8(<8 x i8>* %src, <8 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v8i8: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI1_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI1_0 +; CHECK-NEXT: ptrue p0.b, vl8 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ld1b { z1.b }, p0/z, [x8] +; CHECK-NEXT: lsl z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: asr z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: cmpne p0.b, p0/z, z0.b, #0 +; CHECK-NEXT: ld1b { z0.b }, p0/z, [x0] +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: ret + %load = call <8 x i8> @llvm.masked.load.v8i8(<8 x i8>* %src, i32 8, <8 x i1> %mask, <8 x i8> zeroinitializer) + ret <8 x i8> %load +} + +define <16 x i8> @masked_load_v16i8(<16 x i8>* %src, <16 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v16i8: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI2_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI2_0 +; CHECK-NEXT: ptrue p0.b, vl16 +; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0 +; CHECK-NEXT: ld1b { z1.b }, p0/z, [x8] +; CHECK-NEXT: lsl z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: asr z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: cmpne p0.b, p0/z, z0.b, #0 +; CHECK-NEXT: ld1b { z0.b }, p0/z, [x0] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %load = call <16 x i8> @llvm.masked.load.v16i8(<16 x i8>* %src, i32 8, <16 x i1> %mask, <16 x i8> zeroinitializer) + ret <16 x i8> %load +} + +define <32 x i8> @masked_load_v32i8(<32 x i8>* %src, <32 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v32i8: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #32 +; CHECK-NEXT: .cfi_def_cfa_offset 32 +; CHECK-NEXT: ldr w8, [sp, #224] +; CHECK-NEXT: strb w7, [sp, #6] +; CHECK-NEXT: ldr w9, [sp, #216] +; CHECK-NEXT: strb w6, [sp, #5] +; CHECK-NEXT: ldr w10, [sp, #208] +; CHECK-NEXT: strb w5, [sp, #4] +; CHECK-NEXT: strb w8, [sp, #31] +; CHECK-NEXT: ldr w8, [sp, #200] +; CHECK-NEXT: strb w9, [sp, #30] +; CHECK-NEXT: ldr w9, [sp, #192] +; CHECK-NEXT: strb w10, [sp, #29] +; CHECK-NEXT: ldr w10, [sp, #184] +; CHECK-NEXT: strb w8, [sp, #28] +; CHECK-NEXT: ldr w8, [sp, #176] +; CHECK-NEXT: strb w9, [sp, #27] +; CHECK-NEXT: ldr w9, [sp, #168] +; CHECK-NEXT: strb w10, [sp, #26] +; CHECK-NEXT: ldr w10, [sp, #160] +; CHECK-NEXT: strb w8, [sp, #25] +; CHECK-NEXT: ldr w8, [sp, #152] +; CHECK-NEXT: strb w9, [sp, #24] +; CHECK-NEXT: ldr w9, [sp, #144] +; CHECK-NEXT: strb w10, [sp, #23] +; CHECK-NEXT: ldr w10, [sp, #136] +; CHECK-NEXT: strb w8, [sp, #22] +; CHECK-NEXT: ldr w8, [sp, #128] +; CHECK-NEXT: strb w9, [sp, #21] +; CHECK-NEXT: ldr w9, [sp, #120] +; CHECK-NEXT: strb w10, [sp, #20] +; CHECK-NEXT: ldr w10, [sp, #112] +; CHECK-NEXT: strb w8, [sp, #19] +; CHECK-NEXT: ldr w8, [sp, #104] +; CHECK-NEXT: strb w9, [sp, #18] +; CHECK-NEXT: ldr w9, [sp, #96] +; CHECK-NEXT: strb w10, [sp, #17] +; CHECK-NEXT: ldr w10, [sp, #88] +; CHECK-NEXT: strb w8, [sp, #16] +; CHECK-NEXT: ldr w8, [sp, #80] +; CHECK-NEXT: strb w9, [sp, #15] +; CHECK-NEXT: ldr w9, [sp, #72] +; CHECK-NEXT: strb w10, [sp, #14] +; CHECK-NEXT: ldr w10, [sp, #64] +; CHECK-NEXT: strb w8, [sp, #13] +; CHECK-NEXT: ldr w8, [sp, #56] +; CHECK-NEXT: strb w9, [sp, #12] +; CHECK-NEXT: ldr w9, [sp, #48] +; CHECK-NEXT: strb w10, [sp, #11] +; CHECK-NEXT: ldr w10, [sp, #40] +; CHECK-NEXT: strb w8, [sp, #10] +; CHECK-NEXT: ldr w8, [sp, #32] +; CHECK-NEXT: strb w9, [sp, #9] +; CHECK-NEXT: adrp x9, .LCPI3_0 +; CHECK-NEXT: add x9, x9, :lo12:.LCPI3_0 +; CHECK-NEXT: strb w10, [sp, #8] +; CHECK-NEXT: strb w8, [sp, #7] +; CHECK-NEXT: ptrue p0.b, vl16 +; CHECK-NEXT: strb w4, [sp, #3] +; CHECK-NEXT: mov x8, sp +; CHECK-NEXT: strb w3, [sp, #2] +; CHECK-NEXT: strb w2, [sp, #1] +; CHECK-NEXT: strb w1, [sp] +; CHECK-NEXT: ld1b { z0.b }, p0/z, [x9] +; CHECK-NEXT: add x9, sp, #16 +; CHECK-NEXT: ld1b { z1.b }, p0/z, [x9] +; CHECK-NEXT: ld1b { z2.b }, p0/z, [x8] +; CHECK-NEXT: mov w8, #16 +; CHECK-NEXT: lsl z1.b, p0/m, z1.b, z0.b +; CHECK-NEXT: lsl z2.b, p0/m, z2.b, z0.b +; CHECK-NEXT: asr z1.b, p0/m, z1.b, z0.b +; CHECK-NEXT: asrr z0.b, p0/m, z0.b, z2.b +; CHECK-NEXT: cmpne p1.b, p0/z, z1.b, #0 +; CHECK-NEXT: cmpne p0.b, p0/z, z0.b, #0 +; CHECK-NEXT: ld1b { z0.b }, p0/z, [x0] +; CHECK-NEXT: ld1b { z1.b }, p1/z, [x0, x8] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: add sp, sp, #32 +; CHECK-NEXT: ret + %load = call <32 x i8> @llvm.masked.load.v32i8(<32 x i8>* %src, i32 8, <32 x i1> %mask, <32 x i8> zeroinitializer) + ret <32 x i8> %load +} + +define <2 x half> @masked_load_v2f16(<2 x half>* %src, <2 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v2f16: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: str wzr, [sp, #12] +; CHECK-NEXT: mov z0.s, z0.s[1] +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: fmov w9, s0 +; CHECK-NEXT: strh w8, [sp, #8] +; CHECK-NEXT: adrp x8, .LCPI4_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI4_0 +; CHECK-NEXT: strh w9, [sp, #10] +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x8] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: lsl z1.h, p0/m, z1.h, z0.h +; CHECK-NEXT: asrr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0] +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: add sp, sp, #16 +; CHECK-NEXT: ret + %load = call <2 x half> @llvm.masked.load.v2f16(<2 x half>* %src, i32 8, <2 x i1> %mask, <2 x half> zeroinitializer) + ret <2 x half> %load +} + +define <4 x half> @masked_load_v4f16(<4 x half>* %src, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v4f16: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI5_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI5_0 +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0] +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: ret + %load = call <4 x half> @llvm.masked.load.v4f16(<4 x half>* %src, i32 8, <4 x i1> %mask, <4 x half> zeroinitializer) + ret <4 x half> %load +} + +define <8 x half> @masked_load_v8f16(<8 x half>* %src, <8 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v8f16: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI6_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI6_0 +; CHECK-NEXT: ptrue p0.h, vl8 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: uunpklo z0.h, z0.b +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %load = call <8 x half> @llvm.masked.load.v8f16(<8 x half>* %src, i32 8, <8 x i1> %mask, <8 x half> zeroinitializer) + ret <8 x half> %load +} + +define <16 x half> @masked_load_v16f16(<16 x half>* %src, <16 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v16f16: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI7_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI7_0 +; CHECK-NEXT: ptrue p0.h, vl8 +; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0 +; CHECK-NEXT: uunpklo z2.h, z0.b +; CHECK-NEXT: ext z0.b, z0.b, z0.b, #8 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: uunpklo z0.h, z0.b +; CHECK-NEXT: mov x8, #8 +; CHECK-NEXT: lsl z2.h, p0/m, z2.h, z1.h +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: asr z2.h, p0/m, z2.h, z1.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p1.h, p0/z, z2.h, #0 +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: ld1h { z0.h }, p1/z, [x0] +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x0, x8, lsl #1] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: ret + %load = call <16 x half> @llvm.masked.load.v16f16(<16 x half>* %src, i32 8, <16 x i1> %mask, <16 x half> zeroinitializer) + ret <16 x half> %load +} + +define <2 x float> @masked_load_v2f32(<2 x float>* %src, <2 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v2f32: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI8_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI8_0 +; CHECK-NEXT: ptrue p0.s, vl2 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ld1w { z1.s }, p0/z, [x8] +; CHECK-NEXT: lsl z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: asr z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: cmpne p0.s, p0/z, z0.s, #0 +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0] +; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0 +; CHECK-NEXT: ret + %load = call <2 x float> @llvm.masked.load.v2f32(<2 x float>* %src, i32 8, <2 x i1> %mask, <2 x float> zeroinitializer) + ret <2 x float> %load +} + +define <4 x float> @masked_load_v4f32(<4 x float>* %src, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v4f32: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI9_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI9_0 +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: uunpklo z0.s, z0.h +; CHECK-NEXT: ld1w { z1.s }, p0/z, [x8] +; CHECK-NEXT: lsl z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: asr z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: cmpne p0.s, p0/z, z0.s, #0 +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %load = call <4 x float> @llvm.masked.load.v4f32(<4 x float>* %src, i32 8, <4 x i1> %mask, <4 x float> zeroinitializer) + ret <4 x float> %load +} + +define <8 x float> @masked_load_v8f32(<8 x float>* %src, <8 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v8f32: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: fmov w9, s0 +; CHECK-NEXT: mov z1.b, z0.b[3] +; CHECK-NEXT: mov z3.b, z0.b[1] +; CHECK-NEXT: fmov w10, s1 +; CHECK-NEXT: mov z2.b, z0.b[2] +; CHECK-NEXT: mov z4.b, z0.b[7] +; CHECK-NEXT: strh w9, [sp] +; CHECK-NEXT: fmov w9, s3 +; CHECK-NEXT: mov z6.b, z0.b[5] +; CHECK-NEXT: fmov w11, s2 +; CHECK-NEXT: strh w10, [sp, #6] +; CHECK-NEXT: fmov w10, s4 +; CHECK-NEXT: strh w9, [sp, #2] +; CHECK-NEXT: fmov w9, s6 +; CHECK-NEXT: mov z5.b, z0.b[6] +; CHECK-NEXT: mov z0.b, z0.b[4] +; CHECK-NEXT: strh w11, [sp, #4] +; CHECK-NEXT: fmov w11, s5 +; CHECK-NEXT: strh w10, [sp, #14] +; CHECK-NEXT: fmov w10, s0 +; CHECK-NEXT: mov x8, sp +; CHECK-NEXT: strh w9, [sp, #10] +; CHECK-NEXT: adrp x9, .LCPI10_0 +; CHECK-NEXT: add x9, x9, :lo12:.LCPI10_0 +; CHECK-NEXT: strh w11, [sp, #12] +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: strh w10, [sp, #8] +; CHECK-NEXT: ptrue p1.h, vl4 +; CHECK-NEXT: ld1w { z1.s }, p0/z, [x9] +; CHECK-NEXT: ld1h { z0.h }, p1/z, [x8] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: uunpklo z0.s, z0.h +; CHECK-NEXT: lsl z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: asr z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: cmpne p2.s, p0/z, z0.s, #0 +; CHECK-NEXT: ld1w { z0.s }, p2/z, [x0] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x8] +; CHECK-NEXT: mov x8, #4 +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z1.s +; CHECK-NEXT: asrr z1.s, p0/m, z1.s, z2.s +; CHECK-NEXT: cmpne p0.s, p0/z, z1.s, #0 +; CHECK-NEXT: ld1w { z1.s }, p0/z, [x0, x8, lsl #2] +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: add sp, sp, #16 +; CHECK-NEXT: ret + %load = call <8 x float> @llvm.masked.load.v8f32(<8 x float>* %src, i32 8, <8 x i1> %mask, <8 x float> zeroinitializer) + ret <8 x float> %load +} + +define <2 x double> @masked_load_v2f64(<2 x double>* %src, <2 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v2f64: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI11_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI11_0 +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: uunpklo z0.d, z0.s +; CHECK-NEXT: ld1d { z1.d }, p0/z, [x8] +; CHECK-NEXT: lsl z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: asr z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: cmpne p0.d, p0/z, z0.d, #0 +; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %load = call <2 x double> @llvm.masked.load.v2f64(<2 x double>* %src, i32 8, <2 x i1> %mask, <2 x double> zeroinitializer) + ret <2 x double> %load +} + +define <4 x double> @masked_load_v4f64(<4 x double>* %src, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_load_v4f64: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI12_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI12_0 +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: uunpklo z0.s, z0.h +; CHECK-NEXT: ld1d { z1.d }, p0/z, [x8] +; CHECK-NEXT: uunpklo z2.d, z0.s +; CHECK-NEXT: ext z0.b, z0.b, z0.b, #8 +; CHECK-NEXT: mov x8, #2 +; CHECK-NEXT: uunpklo z0.d, z0.s +; CHECK-NEXT: lsl z2.d, p0/m, z2.d, z1.d +; CHECK-NEXT: lsl z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: asr z2.d, p0/m, z2.d, z1.d +; CHECK-NEXT: asr z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: cmpne p1.d, p0/z, z2.d, #0 +; CHECK-NEXT: cmpne p0.d, p0/z, z0.d, #0 +; CHECK-NEXT: ld1d { z0.d }, p1/z, [x0] +; CHECK-NEXT: ld1d { z1.d }, p0/z, [x0, x8, lsl #3] +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: // kill: def $q1 killed $q1 killed $z1 +; CHECK-NEXT: ret + %load = call <4 x double> @llvm.masked.load.v4f64(<4 x double>* %src, i32 8, <4 x i1> %mask, <4 x double> zeroinitializer) + ret <4 x double> %load +} + +declare <4 x i8> @llvm.masked.load.v4i8(<4 x i8>*, i32, <4 x i1>, <4 x i8>) +declare <8 x i8> @llvm.masked.load.v8i8(<8 x i8>*, i32, <8 x i1>, <8 x i8>) +declare <16 x i8> @llvm.masked.load.v16i8(<16 x i8>*, i32, <16 x i1>, <16 x i8>) +declare <32 x i8> @llvm.masked.load.v32i8(<32 x i8>*, i32, <32 x i1>, <32 x i8>) + +declare <2 x half> @llvm.masked.load.v2f16(<2 x half>*, i32, <2 x i1>, <2 x half>) +declare <4 x half> @llvm.masked.load.v4f16(<4 x half>*, i32, <4 x i1>, <4 x half>) +declare <8 x half> @llvm.masked.load.v8f16(<8 x half>*, i32, <8 x i1>, <8 x half>) +declare <16 x half> @llvm.masked.load.v16f16(<16 x half>*, i32, <16 x i1>, <16 x half>) + +declare <2 x float> @llvm.masked.load.v2f32(<2 x float>*, i32, <2 x i1>, <2 x float>) +declare <4 x float> @llvm.masked.load.v4f32(<4 x float>*, i32, <4 x i1>, <4 x float>) +declare <8 x float> @llvm.masked.load.v8f32(<8 x float>*, i32, <8 x i1>, <8 x float>) + +declare <2 x double> @llvm.masked.load.v2f64(<2 x double>*, i32, <2 x i1>, <2 x double>) +declare <4 x double> @llvm.masked.load.v4f64(<4 x double>*, i32, <4 x i1>, <4 x double>) + +attributes #0 = { "target-features"="+sve" } diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-masked-store.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-masked-store.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-masked-store.ll @@ -0,0 +1,543 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -force-streaming-compatible-sve < %s | FileCheck %s + +target triple = "aarch64-unknown-linux-gnu" + +; +; Masked Store +; + +define void @masked_store_v4i8(<4 x i8>* %dst, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v4i8: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI0_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI0_0 +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI0_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI0_1 +; CHECK-NEXT: ld1h { z2.h }, p0/z, [x8] +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: st1b { z2.h }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v4i8(<4 x i8> zeroinitializer, <4 x i8>* %dst, i32 8, <4 x i1> %mask) + ret void +} + +define void @masked_store_v8i8(<8 x i8>* %dst, <8 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v8i8: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI1_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI1_0 +; CHECK-NEXT: ptrue p0.b, vl8 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ld1b { z1.b }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI1_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI1_1 +; CHECK-NEXT: ld1b { z2.b }, p0/z, [x8] +; CHECK-NEXT: lsl z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: asr z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: cmpne p0.b, p0/z, z0.b, #0 +; CHECK-NEXT: st1b { z2.b }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v8i8(<8 x i8> zeroinitializer, <8 x i8>* %dst, i32 8, <8 x i1> %mask) + ret void +} + +define void @masked_store_v16i8(<16 x i8>* %dst, <16 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v16i8: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI2_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI2_0 +; CHECK-NEXT: ptrue p0.b, vl16 +; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0 +; CHECK-NEXT: ld1b { z1.b }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI2_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI2_1 +; CHECK-NEXT: ld1b { z2.b }, p0/z, [x8] +; CHECK-NEXT: lsl z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: asr z0.b, p0/m, z0.b, z1.b +; CHECK-NEXT: cmpne p0.b, p0/z, z0.b, #0 +; CHECK-NEXT: st1b { z2.b }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v16i8(<16 x i8> zeroinitializer, <16 x i8>* %dst, i32 8, <16 x i1> %mask) + ret void +} + +define void @masked_store_v32i8(<32 x i8>* %dst, <32 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v32i8: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #32 +; CHECK-NEXT: .cfi_def_cfa_offset 32 +; CHECK-NEXT: ldr w8, [sp, #96] +; CHECK-NEXT: strb w7, [sp, #6] +; CHECK-NEXT: ldr w9, [sp, #88] +; CHECK-NEXT: strb w6, [sp, #5] +; CHECK-NEXT: ldr w10, [sp, #80] +; CHECK-NEXT: strb w5, [sp, #4] +; CHECK-NEXT: strb w8, [sp, #15] +; CHECK-NEXT: ldr w8, [sp, #72] +; CHECK-NEXT: strb w9, [sp, #14] +; CHECK-NEXT: ldr w9, [sp, #64] +; CHECK-NEXT: strb w10, [sp, #13] +; CHECK-NEXT: ldr w10, [sp, #56] +; CHECK-NEXT: strb w8, [sp, #12] +; CHECK-NEXT: ldr w8, [sp, #48] +; CHECK-NEXT: strb w9, [sp, #11] +; CHECK-NEXT: ldr w9, [sp, #40] +; CHECK-NEXT: strb w10, [sp, #10] +; CHECK-NEXT: ldr w10, [sp, #32] +; CHECK-NEXT: strb w8, [sp, #9] +; CHECK-NEXT: ldr w8, [sp, #224] +; CHECK-NEXT: strb w9, [sp, #8] +; CHECK-NEXT: ldr w9, [sp, #216] +; CHECK-NEXT: strb w10, [sp, #7] +; CHECK-NEXT: ldr w10, [sp, #208] +; CHECK-NEXT: strb w8, [sp, #31] +; CHECK-NEXT: ldr w8, [sp, #200] +; CHECK-NEXT: strb w9, [sp, #30] +; CHECK-NEXT: ldr w9, [sp, #192] +; CHECK-NEXT: strb w10, [sp, #29] +; CHECK-NEXT: ldr w10, [sp, #184] +; CHECK-NEXT: strb w8, [sp, #28] +; CHECK-NEXT: ldr w8, [sp, #176] +; CHECK-NEXT: strb w9, [sp, #27] +; CHECK-NEXT: ldr w9, [sp, #168] +; CHECK-NEXT: strb w10, [sp, #26] +; CHECK-NEXT: ldr w10, [sp, #160] +; CHECK-NEXT: strb w8, [sp, #25] +; CHECK-NEXT: ldr w8, [sp, #152] +; CHECK-NEXT: strb w9, [sp, #24] +; CHECK-NEXT: ldr w9, [sp, #144] +; CHECK-NEXT: strb w10, [sp, #23] +; CHECK-NEXT: ldr w10, [sp, #136] +; CHECK-NEXT: strb w8, [sp, #22] +; CHECK-NEXT: ldr w8, [sp, #128] +; CHECK-NEXT: strb w9, [sp, #21] +; CHECK-NEXT: ldr w9, [sp, #120] +; CHECK-NEXT: strb w10, [sp, #20] +; CHECK-NEXT: ldr w10, [sp, #112] +; CHECK-NEXT: strb w8, [sp, #19] +; CHECK-NEXT: ldr w8, [sp, #104] +; CHECK-NEXT: strb w4, [sp, #3] +; CHECK-NEXT: ptrue p0.b, vl16 +; CHECK-NEXT: strb w3, [sp, #2] +; CHECK-NEXT: strb w8, [sp, #16] +; CHECK-NEXT: adrp x8, .LCPI3_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI3_0 +; CHECK-NEXT: strb w2, [sp, #1] +; CHECK-NEXT: strb w1, [sp] +; CHECK-NEXT: strb w9, [sp, #18] +; CHECK-NEXT: mov x9, sp +; CHECK-NEXT: strb w10, [sp, #17] +; CHECK-NEXT: ld1b { z0.b }, p0/z, [x8] +; CHECK-NEXT: add x8, sp, #16 +; CHECK-NEXT: ld1b { z1.b }, p0/z, [x9] +; CHECK-NEXT: ld1b { z2.b }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI3_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI3_1 +; CHECK-NEXT: lsl z1.b, p0/m, z1.b, z0.b +; CHECK-NEXT: asr z1.b, p0/m, z1.b, z0.b +; CHECK-NEXT: ld1b { z3.b }, p0/z, [x8] +; CHECK-NEXT: lsl z2.b, p0/m, z2.b, z0.b +; CHECK-NEXT: mov w8, #16 +; CHECK-NEXT: asrr z0.b, p0/m, z0.b, z2.b +; CHECK-NEXT: cmpne p1.b, p0/z, z1.b, #0 +; CHECK-NEXT: cmpne p0.b, p0/z, z0.b, #0 +; CHECK-NEXT: st1b { z3.b }, p0, [x0, x8] +; CHECK-NEXT: st1b { z3.b }, p1, [x0] +; CHECK-NEXT: add sp, sp, #32 +; CHECK-NEXT: ret + call void @llvm.masked.store.v32i8(<32 x i8> zeroinitializer, <32 x i8>* %dst, i32 8, <32 x i1> %mask) + ret void +} + +define void @masked_store_v2f16(<2 x half>* %dst, <2 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v2f16: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: str wzr, [sp, #12] +; CHECK-NEXT: mov z0.s, z0.s[1] +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: fmov w9, s0 +; CHECK-NEXT: strh w8, [sp, #8] +; CHECK-NEXT: adrp x8, .LCPI4_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI4_0 +; CHECK-NEXT: strh w9, [sp, #10] +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x8] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI4_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI4_1 +; CHECK-NEXT: ld1h { z2.h }, p0/z, [x8] +; CHECK-NEXT: lsl z1.h, p0/m, z1.h, z0.h +; CHECK-NEXT: asrr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: st1h { z2.h }, p0, [x0] +; CHECK-NEXT: add sp, sp, #16 +; CHECK-NEXT: ret + call void @llvm.masked.store.v2f16(<2 x half> zeroinitializer, <2 x half>* %dst, i32 8, <2 x i1> %mask) + ret void +} + +define void @masked_store_v4f16(<4 x half>* %dst, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v4f16: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI5_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI5_0 +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI5_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI5_1 +; CHECK-NEXT: ld1h { z2.h }, p0/z, [x8] +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: st1h { z2.h }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v4f16(<4 x half> zeroinitializer, <4 x half>* %dst, i32 8, <4 x i1> %mask) + ret void +} + +define void @masked_store_v8f16(<8 x half>* %dst, <8 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v8f16: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI6_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI6_0 +; CHECK-NEXT: ptrue p0.h, vl8 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: uunpklo z0.h, z0.b +; CHECK-NEXT: ld1h { z1.h }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI6_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI6_1 +; CHECK-NEXT: ld1h { z2.h }, p0/z, [x8] +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: st1h { z2.h }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v8f16(<8 x half> zeroinitializer, <8 x half>* %dst, i32 8, <8 x i1> %mask) + ret void +} + +define void @masked_store_v16f16(<16 x half>* %dst, <16 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v16f16: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI7_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI7_0 +; CHECK-NEXT: ptrue p0.h, vl8 +; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0 +; CHECK-NEXT: mov z1.d, z0.d +; CHECK-NEXT: ext z1.b, z1.b, z0.b, #8 +; CHECK-NEXT: uunpklo z0.h, z0.b +; CHECK-NEXT: ld1h { z2.h }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI7_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI7_1 +; CHECK-NEXT: uunpklo z1.h, z1.b +; CHECK-NEXT: ld1h { z3.h }, p0/z, [x8] +; CHECK-NEXT: lsl z1.h, p0/m, z1.h, z2.h +; CHECK-NEXT: mov x8, #8 +; CHECK-NEXT: lsl z0.h, p0/m, z0.h, z2.h +; CHECK-NEXT: asr z1.h, p0/m, z1.h, z2.h +; CHECK-NEXT: asr z0.h, p0/m, z0.h, z2.h +; CHECK-NEXT: cmpne p1.h, p0/z, z1.h, #0 +; CHECK-NEXT: cmpne p0.h, p0/z, z0.h, #0 +; CHECK-NEXT: st1h { z3.h }, p1, [x0, x8, lsl #1] +; CHECK-NEXT: st1h { z3.h }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v16f16(<16 x half> zeroinitializer, <16 x half>* %dst, i32 8, <16 x i1> %mask) + ret void +} + +define void @masked_store_v4f32(<4 x float>* %dst, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v4f32: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI8_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI8_0 +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: uunpklo z0.s, z0.h +; CHECK-NEXT: ld1w { z1.s }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI8_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI8_1 +; CHECK-NEXT: ld1w { z2.s }, p0/z, [x8] +; CHECK-NEXT: lsl z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: asr z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: cmpne p0.s, p0/z, z0.s, #0 +; CHECK-NEXT: st1w { z2.s }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v4f32(<4 x float> zeroinitializer, <4 x float>* %dst, i32 8, <4 x i1> %mask) + ret void +} + +define void @masked_store_v8f32(<8 x float>* %dst, <8 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v8f32: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: mov z1.b, z0.b[7] +; CHECK-NEXT: mov z2.b, z0.b[6] +; CHECK-NEXT: fmov w9, s1 +; CHECK-NEXT: mov z1.b, z0.b[5] +; CHECK-NEXT: fmov w10, s2 +; CHECK-NEXT: mov z2.b, z0.b[4] +; CHECK-NEXT: fmov w11, s1 +; CHECK-NEXT: adrp x8, .LCPI9_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI9_0 +; CHECK-NEXT: strh w9, [sp, #14] +; CHECK-NEXT: fmov w9, s2 +; CHECK-NEXT: strh w10, [sp, #12] +; CHECK-NEXT: strh w11, [sp, #10] +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: ptrue p1.h, vl4 +; CHECK-NEXT: mov z4.b, z0.b[3] +; CHECK-NEXT: strh w9, [sp, #8] +; CHECK-NEXT: mov x9, #4 +; CHECK-NEXT: ld1w { z1.s }, p0/z, [x8] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: fmov w10, s4 +; CHECK-NEXT: mov z5.b, z0.b[2] +; CHECK-NEXT: mov z6.b, z0.b[1] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI9_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI9_1 +; CHECK-NEXT: ld1w { z3.s }, p0/z, [x8] +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z1.s +; CHECK-NEXT: movprfx z0, z2 +; CHECK-NEXT: asr z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: cmpne p2.s, p0/z, z0.s, #0 +; CHECK-NEXT: st1w { z3.s }, p2, [x0, x9, lsl #2] +; CHECK-NEXT: fmov w9, s5 +; CHECK-NEXT: strh w8, [sp] +; CHECK-NEXT: fmov w8, s6 +; CHECK-NEXT: strh w10, [sp, #6] +; CHECK-NEXT: mov x10, sp +; CHECK-NEXT: strh w9, [sp, #4] +; CHECK-NEXT: strh w8, [sp, #2] +; CHECK-NEXT: ld1h { z0.h }, p1/z, [x10] +; CHECK-NEXT: uunpklo z0.s, z0.h +; CHECK-NEXT: lsl z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: asr z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: cmpne p0.s, p0/z, z0.s, #0 +; CHECK-NEXT: st1w { z3.s }, p0, [x0] +; CHECK-NEXT: add sp, sp, #16 +; CHECK-NEXT: ret + call void @llvm.masked.store.v8f32(<8 x float> zeroinitializer, <8 x float>* %dst, i32 8, <8 x i1> %mask) + ret void +} + +define void @masked_store_v32f32(<32 x float>* %dst, <32 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v32f32: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #64 +; CHECK-NEXT: .cfi_def_cfa_offset 64 +; CHECK-NEXT: ldr w8, [sp, #256] +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: ldr w9, [sp, #248] +; CHECK-NEXT: ptrue p1.h, vl4 +; CHECK-NEXT: ldr w10, [sp, #240] +; CHECK-NEXT: ldr w11, [sp, #232] +; CHECK-NEXT: strh w8, [sp, #62] +; CHECK-NEXT: adrp x8, .LCPI10_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI10_0 +; CHECK-NEXT: strh w9, [sp, #60] +; CHECK-NEXT: ldr w9, [sp, #224] +; CHECK-NEXT: strh w10, [sp, #58] +; CHECK-NEXT: adrp x10, .LCPI10_1 +; CHECK-NEXT: add x10, x10, :lo12:.LCPI10_1 +; CHECK-NEXT: strh w11, [sp, #56] +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x8] +; CHECK-NEXT: add x8, sp, #56 +; CHECK-NEXT: ldr w11, [sp, #216] +; CHECK-NEXT: ldr w12, [sp, #208] +; CHECK-NEXT: ld1h { z1.h }, p1/z, [x8] +; CHECK-NEXT: ldr w8, [sp, #200] +; CHECK-NEXT: uunpklo z2.s, z1.h +; CHECK-NEXT: ld1w { z1.s }, p0/z, [x10] +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: mov x10, #28 +; CHECK-NEXT: asr z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: cmpne p2.s, p0/z, z2.s, #0 +; CHECK-NEXT: st1w { z1.s }, p2, [x0, x10, lsl #2] +; CHECK-NEXT: strh w9, [sp, #54] +; CHECK-NEXT: add x9, sp, #48 +; CHECK-NEXT: strh w11, [sp, #52] +; CHECK-NEXT: strh w12, [sp, #50] +; CHECK-NEXT: mov x10, #24 +; CHECK-NEXT: strh w8, [sp, #48] +; CHECK-NEXT: ldr w8, [sp, #168] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x9] +; CHECK-NEXT: ldr w9, [sp, #192] +; CHECK-NEXT: ldr w11, [sp, #184] +; CHECK-NEXT: ldr w12, [sp, #176] +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: asr z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: cmpne p2.s, p0/z, z2.s, #0 +; CHECK-NEXT: st1w { z1.s }, p2, [x0, x10, lsl #2] +; CHECK-NEXT: strh w9, [sp, #46] +; CHECK-NEXT: add x9, sp, #40 +; CHECK-NEXT: strh w11, [sp, #44] +; CHECK-NEXT: strh w12, [sp, #42] +; CHECK-NEXT: mov x10, #20 +; CHECK-NEXT: strh w8, [sp, #40] +; CHECK-NEXT: ldr w8, [sp, #136] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x9] +; CHECK-NEXT: ldr w9, [sp, #160] +; CHECK-NEXT: ldr w11, [sp, #152] +; CHECK-NEXT: ldr w12, [sp, #144] +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: asr z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: cmpne p2.s, p0/z, z2.s, #0 +; CHECK-NEXT: st1w { z1.s }, p2, [x0, x10, lsl #2] +; CHECK-NEXT: strh w9, [sp, #38] +; CHECK-NEXT: add x9, sp, #32 +; CHECK-NEXT: strh w11, [sp, #36] +; CHECK-NEXT: strh w12, [sp, #34] +; CHECK-NEXT: mov x10, #16 +; CHECK-NEXT: strh w8, [sp, #32] +; CHECK-NEXT: ldr w8, [sp, #104] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x9] +; CHECK-NEXT: ldr w9, [sp, #128] +; CHECK-NEXT: ldr w11, [sp, #120] +; CHECK-NEXT: ldr w12, [sp, #112] +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: asr z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: cmpne p2.s, p0/z, z2.s, #0 +; CHECK-NEXT: st1w { z1.s }, p2, [x0, x10, lsl #2] +; CHECK-NEXT: strh w9, [sp, #30] +; CHECK-NEXT: add x9, sp, #24 +; CHECK-NEXT: strh w11, [sp, #28] +; CHECK-NEXT: strh w12, [sp, #26] +; CHECK-NEXT: mov x10, #12 +; CHECK-NEXT: strh w8, [sp, #24] +; CHECK-NEXT: ldr w8, [sp, #72] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x9] +; CHECK-NEXT: ldr w9, [sp, #96] +; CHECK-NEXT: ldr w11, [sp, #88] +; CHECK-NEXT: ldr w12, [sp, #80] +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: asr z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: cmpne p2.s, p0/z, z2.s, #0 +; CHECK-NEXT: st1w { z1.s }, p2, [x0, x10, lsl #2] +; CHECK-NEXT: strh w9, [sp, #22] +; CHECK-NEXT: add x9, sp, #16 +; CHECK-NEXT: strh w11, [sp, #20] +; CHECK-NEXT: strh w12, [sp, #18] +; CHECK-NEXT: strh w8, [sp, #16] +; CHECK-NEXT: ldr w8, [sp, #64] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x9] +; CHECK-NEXT: mov x9, #8 +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: asr z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: cmpne p2.s, p0/z, z2.s, #0 +; CHECK-NEXT: st1w { z1.s }, p2, [x0, x9, lsl #2] +; CHECK-NEXT: strh w8, [sp, #14] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: strh w7, [sp, #12] +; CHECK-NEXT: strh w6, [sp, #10] +; CHECK-NEXT: strh w5, [sp, #8] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x8] +; CHECK-NEXT: mov x8, #4 +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: asr z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: cmpne p2.s, p0/z, z2.s, #0 +; CHECK-NEXT: st1w { z1.s }, p2, [x0, x8, lsl #2] +; CHECK-NEXT: mov x8, sp +; CHECK-NEXT: strh w4, [sp, #6] +; CHECK-NEXT: strh w3, [sp, #4] +; CHECK-NEXT: strh w2, [sp, #2] +; CHECK-NEXT: strh w1, [sp] +; CHECK-NEXT: ld1h { z2.h }, p1/z, [x8] +; CHECK-NEXT: uunpklo z2.s, z2.h +; CHECK-NEXT: lsl z2.s, p0/m, z2.s, z0.s +; CHECK-NEXT: asrr z0.s, p0/m, z0.s, z2.s +; CHECK-NEXT: cmpne p0.s, p0/z, z0.s, #0 +; CHECK-NEXT: st1w { z1.s }, p0, [x0] +; CHECK-NEXT: add sp, sp, #64 +; CHECK-NEXT: ret + call void @llvm.masked.store.v32f32(<32 x float> zeroinitializer, <32 x float>* %dst, i32 8, <32 x i1> %mask) + ret void +} + +define void @masked_store_v2f64(<2 x double>* %dst, <2 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v2f64: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI11_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI11_0 +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: uunpklo z0.d, z0.s +; CHECK-NEXT: ld1d { z1.d }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI11_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI11_1 +; CHECK-NEXT: ld1d { z2.d }, p0/z, [x8] +; CHECK-NEXT: lsl z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: asr z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: cmpne p0.d, p0/z, z0.d, #0 +; CHECK-NEXT: st1d { z2.d }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v2f64(<2 x double> zeroinitializer, <2 x double>* %dst, i32 8, <2 x i1> %mask) + ret void +} + +define void @masked_store_v4f64(<4 x double>* %dst, <4 x i1> %mask) #0 { +; CHECK-LABEL: masked_store_v4f64: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI12_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI12_0 +; CHECK-NEXT: // kill: def $d0 killed $d0 def $z0 +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: uunpklo z0.s, z0.h +; CHECK-NEXT: ld1d { z2.d }, p0/z, [x8] +; CHECK-NEXT: adrp x8, .LCPI12_1 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI12_1 +; CHECK-NEXT: mov z1.d, z0.d +; CHECK-NEXT: ext z1.b, z1.b, z0.b, #8 +; CHECK-NEXT: uunpklo z0.d, z0.s +; CHECK-NEXT: uunpklo z1.d, z1.s +; CHECK-NEXT: ld1d { z3.d }, p0/z, [x8] +; CHECK-NEXT: lsl z1.d, p0/m, z1.d, z2.d +; CHECK-NEXT: mov x8, #2 +; CHECK-NEXT: lsl z0.d, p0/m, z0.d, z2.d +; CHECK-NEXT: asr z1.d, p0/m, z1.d, z2.d +; CHECK-NEXT: asr z0.d, p0/m, z0.d, z2.d +; CHECK-NEXT: cmpne p1.d, p0/z, z1.d, #0 +; CHECK-NEXT: cmpne p0.d, p0/z, z0.d, #0 +; CHECK-NEXT: st1d { z3.d }, p1, [x0, x8, lsl #3] +; CHECK-NEXT: st1d { z3.d }, p0, [x0] +; CHECK-NEXT: ret + call void @llvm.masked.store.v4f64(<4 x double> zeroinitializer, <4 x double>* %dst, i32 8, <4 x i1> %mask) + ret void +} + +declare void @llvm.masked.store.v4i8(<4 x i8>, <4 x i8>*, i32, <4 x i1>) +declare void @llvm.masked.store.v8i8(<8 x i8>, <8 x i8>*, i32, <8 x i1>) +declare void @llvm.masked.store.v16i8(<16 x i8>, <16 x i8>*, i32, <16 x i1>) +declare void @llvm.masked.store.v32i8(<32 x i8>, <32 x i8>*, i32, <32 x i1>) +declare void @llvm.masked.store.v2f16(<2 x half>, <2 x half>*, i32, <2 x i1>) +declare void @llvm.masked.store.v4f16(<4 x half>, <4 x half>*, i32, <4 x i1>) +declare void @llvm.masked.store.v8f16(<8 x half>, <8 x half>*, i32, <8 x i1>) +declare void @llvm.masked.store.v16f16(<16 x half>, <16 x half>*, i32, <16 x i1>) +declare void @llvm.masked.store.v4f32(<4 x float>, <4 x float>*, i32, <4 x i1>) +declare void @llvm.masked.store.v8f32(<8 x float>, <8 x float>*, i32, <8 x i1>) +declare void @llvm.masked.store.v32f32(<32 x float>, <32 x float>*, i32, <32 x i1>) +declare void @llvm.masked.store.v2f64(<2 x double>, <2 x double>*, i32, <2 x i1>) +declare void @llvm.masked.store.v4f64(<4 x double>, <4 x double>*, i32, <4 x i1>) + +attributes #0 = { "target-features"="+sve" } diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll --- a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll +++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-stores.ll @@ -1,20 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -aarch64-sve-vector-bits-min=128 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=256 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=384 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=512 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=640 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=768 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=896 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1024 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1152 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1280 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1408 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1536 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1664 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1792 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=1920 -force-streaming-mode-compatible-sve < %s | FileCheck %s -; RUN: llc -aarch64-sve-vector-bits-min=2048 -force-streaming-mode-compatible-sve < %s | FileCheck %s +; RUN: llc -force-streaming-compatible-sve < %s | FileCheck %s target triple = "aarch64-unknown-linux-gnu" @@ -51,7 +36,8 @@ ; CHECK-NEXT: add x8, x8, :lo12:.LCPI2_0 ; CHECK-NEXT: ptrue p0.h, vl4 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x8] -; CHECK-NEXT: str s0, [x0] +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: str w8, [x0] ; CHECK-NEXT: ret store <2 x half> zeroinitializer, <2 x half>* %a ret void @@ -88,6 +74,19 @@ ret void } +define void @store_v8f32(<8 x float>* %a) #0 { +; CHECK-LABEL: store_v8f32: +; CHECK: // %bb.0: +; CHECK-NEXT: adrp x8, .LCPI6_0 +; CHECK-NEXT: add x8, x8, :lo12:.LCPI6_0 +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x8] +; CHECK-NEXT: stp q0, q0, [x0] +; CHECK-NEXT: ret + store <8 x float> zeroinitializer, <8 x float>* %a + ret void +} + define void @store_v2f64(<2 x double>* %a) #0 { ; CHECK-LABEL: store_v2f64: ; CHECK: // %bb.0: diff --git a/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-trunc-stores.ll b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-trunc-stores.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve-streaming-mode-fixed-length-trunc-stores.ll @@ -0,0 +1,136 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -force-streaming-compatible-sve < %s | FileCheck %s + +target triple = "aarch64-unknown-linux-gnu" + +define void @store_trunc_v8i16i8(<8 x i16>* %ap, <8 x i8>* %dest) #0 { +; CHECK-LABEL: store_trunc_v8i16i8: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: ptrue p0.h, vl8 +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0] +; CHECK-NEXT: ptrue p0.b, vl8 +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: mov z1.h, z0.h[7] +; CHECK-NEXT: mov z3.h, z0.h[5] +; CHECK-NEXT: fmov w9, s1 +; CHECK-NEXT: mov z2.h, z0.h[6] +; CHECK-NEXT: mov z4.h, z0.h[4] +; CHECK-NEXT: strb w8, [sp, #8] +; CHECK-NEXT: fmov w8, s3 +; CHECK-NEXT: mov z6.h, z0.h[2] +; CHECK-NEXT: fmov w10, s2 +; CHECK-NEXT: strb w9, [sp, #15] +; CHECK-NEXT: fmov w9, s4 +; CHECK-NEXT: strb w8, [sp, #13] +; CHECK-NEXT: fmov w8, s6 +; CHECK-NEXT: mov z5.h, z0.h[3] +; CHECK-NEXT: mov z0.h, z0.h[1] +; CHECK-NEXT: strb w10, [sp, #14] +; CHECK-NEXT: fmov w10, s5 +; CHECK-NEXT: strb w9, [sp, #12] +; CHECK-NEXT: fmov w9, s0 +; CHECK-NEXT: strb w8, [sp, #10] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: strb w10, [sp, #11] +; CHECK-NEXT: strb w9, [sp, #9] +; CHECK-NEXT: ld1b { z0.b }, p0/z, [x8] +; CHECK-NEXT: str d0, [x1] +; CHECK-NEXT: add sp, sp, #16 +; CHECK-NEXT: ret + %a = load <8 x i16>, <8 x i16>* %ap + %val = trunc <8 x i16> %a to <8 x i8> + store <8 x i8> %val, <8 x i8>* %dest + ret void +} + +define void @store_trunc_v4i32i8(<4 x i32>* %ap, <4 x i8>* %dest) #0 { +; CHECK-LABEL: store_trunc_v4i32i8: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0] +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: mov z1.s, z0.s[3] +; CHECK-NEXT: mov z2.s, z0.s[2] +; CHECK-NEXT: mov z0.s, z0.s[1] +; CHECK-NEXT: fmov w9, s1 +; CHECK-NEXT: fmov w10, s2 +; CHECK-NEXT: strh w8, [sp, #8] +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: strh w9, [sp, #14] +; CHECK-NEXT: strh w8, [sp, #10] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: strh w10, [sp, #12] +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x8] +; CHECK-NEXT: st1b { z0.h }, p0, [x1] +; CHECK-NEXT: add sp, sp, #16 +; CHECK-NEXT: ret + %a = load <4 x i32>, <4 x i32>* %ap + %val = trunc <4 x i32> %a to <4 x i8> + store <4 x i8> %val, <4 x i8>* %dest + ret void +} + +define void @store_trunc_v4i32i16(<4 x i32>* %ap, <4 x i16>* %dest) #0 { +; CHECK-LABEL: store_trunc_v4i32i16: +; CHECK: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: ptrue p0.s, vl4 +; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0] +; CHECK-NEXT: ptrue p0.h, vl4 +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: mov z1.s, z0.s[3] +; CHECK-NEXT: mov z2.s, z0.s[2] +; CHECK-NEXT: mov z0.s, z0.s[1] +; CHECK-NEXT: fmov w9, s1 +; CHECK-NEXT: fmov w10, s2 +; CHECK-NEXT: strh w8, [sp, #8] +; CHECK-NEXT: fmov w8, s0 +; CHECK-NEXT: strh w9, [sp, #14] +; CHECK-NEXT: strh w8, [sp, #10] +; CHECK-NEXT: add x8, sp, #8 +; CHECK-NEXT: strh w10, [sp, #12] +; CHECK-NEXT: ld1h { z0.h }, p0/z, [x8] +; CHECK-NEXT: str d0, [x1] +; CHECK-NEXT: add sp, sp, #16 +; CHECK-NEXT: ret + %a = load <4 x i32>, <4 x i32>* %ap + %val = trunc <4 x i32> %a to <4 x i16> + store <4 x i16> %val, <4 x i16>* %dest + ret void +} + +define void @store_trunc_v2i64i8(<2 x i64>* %ap, <2 x i32>* %dest) vscale_range(2,0) #0 { +; CHECK-LABEL: store_trunc_v2i64i8: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d, vl2 +; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0] +; CHECK-NEXT: st1w { z0.d }, p0, [x1] +; CHECK-NEXT: ret + %a = load <2 x i64>, <2 x i64>* %ap + %val = trunc <2 x i64> %a to <2 x i32> + store <2 x i32> %val, <2 x i32>* %dest + ret void +} + +define void @store_trunc_v2i256i64(<2 x i256>* %ap, <2 x i64>* %dest) vscale_range(2,0) #0 { +; CHECK-LABEL: store_trunc_v2i256i64: +; CHECK: // %bb.0: +; CHECK-NEXT: ldr d0, [x0, #32] +; CHECK-NEXT: ptrue p0.d, vl1 +; CHECK-NEXT: ldr d1, [x0] +; CHECK-NEXT: splice z1.d, p0, z1.d, z0.d +; CHECK-NEXT: str q1, [x1] +; CHECK-NEXT: ret + %a = load <2 x i256>, <2 x i256>* %ap + %val = trunc <2 x i256> %a to <2 x i64> + store <2 x i64> %val, <2 x i64>* %dest + ret void +} + +attributes #0 = { "target-features"="+sve" }