[llvm] [AArch64] Lower masked.expandload intrinsic using SVE2p2/SME2p2 EXPAND (PR #190999)
Kerry McLaughlin via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 09:00:22 PDT 2026
https://github.com/kmclaughlin-arm created https://github.com/llvm/llvm-project/pull/190999
The masked.expandload intrinsic can be lowered using the EXPAND instruction
when available, where the source vector is the result of a contiguous load
of the number of active elements in the predicate. EXPAND is available with
either feature in non-streaming mode. It is available in streaming-mode
with SME2p2, or with SVE2p2 when SME_FA64 is also enabled.
Intrinsics which return a fixed-width result can also be lowered using SVE
instructions when preferred, otherwise they will be scalarised by falling
back on scalarizeMaskedExpandLoad.
Scalable vectors are not supported when EXPAND is not available. In this
case, the cost model will return an invalid cost for the intrinsic.
>From 5d5cdc7b3bbe77ae110830939749394bd7b64155 Mon Sep 17 00:00:00 2001
From: Kerry McLaughlin <kerry.mclaughlin at arm.com>
Date: Mon, 30 Mar 2026 12:44:51 +0000
Subject: [PATCH] [AArch64] Lower masked.expandload intrinsic using
SVE2p2/SME2p2 EXPAND instruction
The masked.expandload intrinsic can be lowered using the EXPAND instruction
when available, where the source vector is the result of a contiguous load
of the number of active elements in the predicate. EXPAND is available with
either feature in non-streaming mode. It is available in streaming-mode
with SME2p2, or with SVE2p2 when SME_FA64 is also enabled.
Intrinsics which return a fixed-width result can also be lowered using SVE
instructions when preferred, otherwise they will be scalarised by falling
back on scalarizeMaskedExpandLoad.
Scalable vectors are not supported when EXPAND is not available. In this
case, the cost model will return an invalid cost for the intrinsic.
---
.../Target/AArch64/AArch64ISelLowering.cpp | 86 ++-
.../AArch64/AArch64TargetTransformInfo.cpp | 19 +
.../AArch64/AArch64TargetTransformInfo.h | 2 +
.../CostModel/AArch64/masked_expand_load.ll | 281 +++++++++
.../CodeGen/AArch64/fixed-expanding-load.ll | 581 ++++++++++++++++++
.../AArch64/scalable-expanding-load.ll | 66 ++
6 files changed, 1025 insertions(+), 10 deletions(-)
create mode 100644 llvm/test/Analysis/CostModel/AArch64/masked_expand_load.ll
create mode 100644 llvm/test/CodeGen/AArch64/fixed-expanding-load.ll
create mode 100644 llvm/test/CodeGen/AArch64/scalable-expanding-load.ll
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index e1483ca55b7af..0c3401e38a61d 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -7368,14 +7368,50 @@ SDValue AArch64TargetLowering::LowerMLOAD(SDValue Op, SelectionDAG &DAG) const {
if (PassThru->isUndef() || isZerosVector(PassThru.getNode()))
return Op;
+ if (!LoadNode->isExpandingLoad()) {
+ SDValue Load = DAG.getMaskedLoad(
+ VT, DL, LoadNode->getChain(), LoadNode->getBasePtr(),
+ LoadNode->getOffset(), Mask, DAG.getUNDEF(VT), LoadNode->getMemoryVT(),
+ LoadNode->getMemOperand(), LoadNode->getAddressingMode(),
+ LoadNode->getExtensionType());
+
+ SDValue Result = DAG.getSelect(DL, VT, Mask, Load, PassThru);
+ return DAG.getMergeValues({Result, Load.getValue(1)}, DL);
+ }
+
+ // Expand instruction is available with SVE2p2 in streaming mode only
+ // if SMEFA64 is available. Expand is always available with SME2p2.
+ if (!(Subtarget->hasSVE2p2() &&
+ (!Subtarget->isStreaming() || Subtarget->hasSMEFA64())) &&
+ !Subtarget->hasSME2p2())
+ return Op;
+
+ // Create mask using the number of active lanes in the predicate.
+ SDValue CntActive = DAG.getNode(
+ ISD::INTRINSIC_WO_CHAIN, DL, MVT::i64,
+ DAG.getTargetConstant(Intrinsic::aarch64_sve_cntp, DL, MVT::i64), Mask,
+ Mask);
+
+ SDValue ActiveMask =
+ DAG.getNode(ISD::GET_ACTIVE_LANE_MASK, DL, Mask->getValueType(0),
+ DAG.getConstant(0, DL, MVT::i64), CntActive);
+
+ // Contiguous load of elements using the active lane mask above.
SDValue Load = DAG.getMaskedLoad(
VT, DL, LoadNode->getChain(), LoadNode->getBasePtr(),
- LoadNode->getOffset(), Mask, DAG.getUNDEF(VT), LoadNode->getMemoryVT(),
- LoadNode->getMemOperand(), LoadNode->getAddressingMode(),
- LoadNode->getExtensionType());
+ LoadNode->getOffset(), ActiveMask, DAG.getUNDEF(VT),
+ LoadNode->getMemoryVT(), LoadNode->getMemOperand(),
+ LoadNode->getAddressingMode(), LoadNode->getExtensionType());
- SDValue Result = DAG.getSelect(DL, VT, Mask, Load, PassThru);
+ // Expand instruction copies the low-numbered elements to active elements
+ // in the original predicate.
+ SDValue Expand = DAG.getNode(
+ ISD::INTRINSIC_WO_CHAIN, DL, VT,
+ DAG.getTargetConstant(Intrinsic::aarch64_sve_expand, DL, MVT::i64), Mask,
+ Load);
+ // Copy the passthrough value.
+ SDValue Result = DAG.getSelect(DL, VT, Mask, Expand, PassThru);
return DAG.getMergeValues({Result, Load.getValue(1)}, DL);
}
@@ -31627,7 +31663,7 @@ SDValue AArch64TargetLowering::LowerFixedLengthVectorMLoadToSVE(
}
Mask = convertFixedMaskToScalableVector(Mask, DAG);
- SDValue PassThru;
+ SDValue PassThru, NewLoad, Result;
bool IsPassThruZeroOrUndef = false;
if (Load->getPassThru()->isUndef()) {
@@ -31642,12 +31678,42 @@ SDValue AArch64TargetLowering::LowerFixedLengthVectorMLoadToSVE(
IsPassThruZeroOrUndef = true;
}
- SDValue NewLoad = DAG.getMaskedLoad(
- ContainerVT, DL, Load->getChain(), Load->getBasePtr(), Load->getOffset(),
- Mask, PassThru, Load->getMemoryVT(), Load->getMemOperand(),
- Load->getAddressingMode(), Load->getExtensionType());
+ if (!Load->isExpandingLoad()) {
+ NewLoad =
+ DAG.getMaskedLoad(ContainerVT, DL, Load->getChain(), Load->getBasePtr(),
+ Load->getOffset(), Mask, PassThru,
+ Load->getMemoryVT(), Load->getMemOperand(),
+ Load->getAddressingMode(), Load->getExtensionType());
+ Result = NewLoad;
+ } else {
+ // Fixed-length masked.expandload intrinsics should have been scalarised
+ // if the required features are not available to use expand.
+ assert(((Subtarget->hasSVE2p2() &&
+ (!Subtarget->isStreaming() || Subtarget->hasSMEFA64())) ||
+ Subtarget->hasSME2p2()) &&
+ "Expected SVE2p2 or SME2p2");
+
+ SDValue CntActive = DAG.getNode(
+ ISD::INTRINSIC_WO_CHAIN, DL, MVT::i64,
+ DAG.getTargetConstant(Intrinsic::aarch64_sve_cntp, DL, MVT::i64), Mask,
+ Mask);
+
+ SDValue ActiveMask =
+ DAG.getNode(ISD::GET_ACTIVE_LANE_MASK, DL, Mask->getValueType(0),
+ DAG.getConstant(0, DL, MVT::i64), CntActive);
+
+ NewLoad =
+ DAG.getMaskedLoad(ContainerVT, DL, Load->getChain(), Load->getBasePtr(),
+ Load->getOffset(), ActiveMask, PassThru,
+ Load->getMemoryVT(), Load->getMemOperand(),
+ Load->getAddressingMode(), Load->getExtensionType());
+
+ Result = DAG.getNode(
+ ISD::INTRINSIC_WO_CHAIN, DL, ContainerVT,
+ DAG.getTargetConstant(Intrinsic::aarch64_sve_expand, DL, MVT::i64),
+ Mask, NewLoad);
+ }
- SDValue Result = NewLoad;
if (!IsPassThruZeroOrUndef) {
SDValue OldPassThru =
convertToScalableVector(DAG, ContainerVT, Load->getPassThru());
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index 734339e5c7a05..1324ea32488dd 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -4875,6 +4875,7 @@ AArch64TTIImpl::getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA,
case Intrinsic::masked_gather:
return getGatherScatterOpCost(MICA, CostKind);
case Intrinsic::masked_load:
+ case Intrinsic::masked_expandload:
case Intrinsic::masked_store:
return getMaskedMemoryOpCost(MICA, CostKind);
}
@@ -4904,6 +4905,10 @@ AArch64TTIImpl::getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
if (VT->getElementCount() == ElementCount::getScalable(1))
return InstructionCost::getInvalid();
+ if (MICA.getID() == Intrinsic::masked_expandload &&
+ !isLegalMaskedExpandLoad(Src, MICA.getAlignment()))
+ return InstructionCost::getInvalid();
+
return LT.first;
}
@@ -5128,6 +5133,20 @@ AArch64TTIImpl::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const {
return Cost;
}
+bool AArch64TTIImpl::isLegalMaskedExpandLoad(Type *DataTy,
+ Align Alignment) const {
+ EVT VT = TLI->getValueType(DL, DataTy, true);
+
+ // Neon types should be scalarised when we are not choosing to use SVE.
+ if (useNeonVector(DataTy))
+ return false;
+
+ // Return true only if we are able to lower using the SVE2p2/SME2p2
+ // expand instruction.
+ return (ST->hasSVE2p2() && (!ST->isStreaming() || ST->hasSMEFA64())) ||
+ ST->hasSME2p2();
+}
+
unsigned AArch64TTIImpl::getMaxInterleaveFactor(ElementCount VF) const {
return ST->getMaxInterleaveFactor();
}
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index cde391bdcaea8..2136a2141fffb 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -284,6 +284,8 @@ class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
InstructionCost
getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) const override;
+ bool isLegalMaskedExpandLoad(Type *DataTy, Align Alignment) const override;
+
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
TTI::UnrollingPreferences &UP,
OptimizationRemarkEmitter *ORE) const override;
diff --git a/llvm/test/Analysis/CostModel/AArch64/masked_expand_load.ll b/llvm/test/Analysis/CostModel/AArch64/masked_expand_load.ll
new file mode 100644
index 0000000000000..f0b5344803d3e
--- /dev/null
+++ b/llvm/test/Analysis/CostModel/AArch64/masked_expand_load.ll
@@ -0,0 +1,281 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
+; RUN: opt < %s -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output -mtriple=aarch64-linux-gnu -mattr=sve -mattr=+sve2p2 | FileCheck %s --check-prefix=SVE2p2-SME2p2-NON-STREAMING
+; RUN: opt < %s -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output -mtriple=aarch64-linux-gnu -mattr=sve -mattr=+sme2p2 | FileCheck %s --check-prefix=SVE2p2-SME2p2-NON-STREAMING
+; RUN: opt < %s -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output -mtriple=aarch64-linux-gnu -mattr=sve -mattr=+sme2p2 -force-streaming | FileCheck %s --check-prefix=SVE2p2-SME2p2-STREAMING
+; RUN: opt < %s -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output -mtriple=aarch64-linux-gnu -mattr=sve -mattr=+sve2p2 -mattr=+sme-fa64 -force-streaming | FileCheck %s --check-prefix=SVE2p2-SME2p2
+; RUN: opt < %s -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output -mtriple=aarch64-linux-gnu -mattr=sve -mattr=sme -mattr=+sve2p2 -force-streaming | FileCheck %s --check-prefix=SVE-ONLY
+; RUN: opt < %s -passes="print<cost-model>" -cost-kind=all 2>&1 -disable-output -mtriple=aarch64-linux-gnu -mattr=sve -mattr=+sve2p2 -aarch64-sve-vector-bits-min=256 | FileCheck %s --check-prefix=SVE2p2-SME2p2-SVE256
+
+define void @fixed() {
+; SVE2p2-SME2p2-NON-STREAMING-LABEL: 'fixed'
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i8 = call <2 x i8> @llvm.masked.expandload.v2i8(ptr undef, <2 x i1> undef, <2 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i8 = call <4 x i8> @llvm.masked.expandload.v4i8(ptr undef, <4 x i1> undef, <4 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:40 CodeSize:24 Lat:40 SizeLat:40 for: %v8i8 = call <8 x i8> @llvm.masked.expandload.v8i8(ptr undef, <8 x i1> undef, <8 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:80 CodeSize:48 Lat:80 SizeLat:80 for: %v16i8 = call <16 x i8> @llvm.masked.expandload.v16i8(ptr undef, <16 x i1> undef, <16 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i16 = call <2 x i16> @llvm.masked.expandload.v2i16(ptr undef, <2 x i1> undef, <2 x i16> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i16 = call <4 x i16> @llvm.masked.expandload.v4i16(ptr undef, <4 x i1> undef, <4 x i16> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:40 CodeSize:24 Lat:40 SizeLat:40 for: %v8i16 = call <8 x i16> @llvm.masked.expandload.v8i16(ptr undef, <8 x i1> undef, <8 x i16> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i32 = call <2 x i32> @llvm.masked.expandload.v2i32(ptr undef, <2 x i1> undef, <2 x i32> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i32 = call <4 x i32> @llvm.masked.expandload.v4i32(ptr undef, <4 x i1> undef, <4 x i32> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i64 = call <2 x i64> @llvm.masked.expandload.v2i64(ptr undef, <2 x i1> undef, <2 x i64> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:8 CodeSize:5 Lat:8 SizeLat:8 for: %v2f16 = call <2 x half> @llvm.masked.expandload.v2f16(ptr undef, <2 x i1> undef, <2 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:18 CodeSize:11 Lat:18 SizeLat:18 for: %v4f16 = call <4 x half> @llvm.masked.expandload.v4f16(ptr undef, <4 x i1> undef, <4 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:38 CodeSize:23 Lat:38 SizeLat:38 for: %v8f16 = call <8 x half> @llvm.masked.expandload.v8f16(ptr undef, <8 x i1> undef, <8 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:8 CodeSize:5 Lat:8 SizeLat:8 for: %v2f32 = call <2 x float> @llvm.masked.expandload.v2f32(ptr undef, <2 x i1> undef, <2 x float> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:18 CodeSize:11 Lat:18 SizeLat:18 for: %v4f32 = call <4 x float> @llvm.masked.expandload.v4f32(ptr undef, <4 x i1> undef, <4 x float> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:8 CodeSize:5 Lat:8 SizeLat:8 for: %v2f64 = call <2 x double> @llvm.masked.expandload.v2f64(ptr undef, <2 x i1> undef, <2 x double> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i64 = call <4 x i64> @llvm.masked.expandload.v4i64(ptr undef, <4 x i1> undef, <4 x i64> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:152 CodeSize:92 Lat:152 SizeLat:152 for: %v32f16 = call <32 x half> @llvm.masked.expandload.v32f16(ptr undef, <32 x i1> undef, <32 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE2p2-SME2p2-STREAMING-LABEL: 'fixed'
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v2i8 = call <2 x i8> @llvm.masked.expandload.v2i8(ptr undef, <2 x i1> undef, <2 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v4i8 = call <4 x i8> @llvm.masked.expandload.v4i8(ptr undef, <4 x i1> undef, <4 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v8i8 = call <8 x i8> @llvm.masked.expandload.v8i8(ptr undef, <8 x i1> undef, <8 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v16i8 = call <16 x i8> @llvm.masked.expandload.v16i8(ptr undef, <16 x i1> undef, <16 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v2i16 = call <2 x i16> @llvm.masked.expandload.v2i16(ptr undef, <2 x i1> undef, <2 x i16> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v4i16 = call <4 x i16> @llvm.masked.expandload.v4i16(ptr undef, <4 x i1> undef, <4 x i16> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v8i16 = call <8 x i16> @llvm.masked.expandload.v8i16(ptr undef, <8 x i1> undef, <8 x i16> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v2i32 = call <2 x i32> @llvm.masked.expandload.v2i32(ptr undef, <2 x i1> undef, <2 x i32> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v4i32 = call <4 x i32> @llvm.masked.expandload.v4i32(ptr undef, <4 x i1> undef, <4 x i32> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v2i64 = call <2 x i64> @llvm.masked.expandload.v2i64(ptr undef, <2 x i1> undef, <2 x i64> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v2f16 = call <2 x half> @llvm.masked.expandload.v2f16(ptr undef, <2 x i1> undef, <2 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v4f16 = call <4 x half> @llvm.masked.expandload.v4f16(ptr undef, <4 x i1> undef, <4 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v8f16 = call <8 x half> @llvm.masked.expandload.v8f16(ptr undef, <8 x i1> undef, <8 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v2f32 = call <2 x float> @llvm.masked.expandload.v2f32(ptr undef, <2 x i1> undef, <2 x float> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v4f32 = call <4 x float> @llvm.masked.expandload.v4f32(ptr undef, <4 x i1> undef, <4 x float> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %v2f64 = call <2 x double> @llvm.masked.expandload.v2f64(ptr undef, <2 x i1> undef, <2 x double> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 2 for: %v4i64 = call <4 x i64> @llvm.masked.expandload.v4i64(ptr undef, <4 x i1> undef, <4 x i64> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 4 for: %v32f16 = call <32 x half> @llvm.masked.expandload.v32f16(ptr undef, <32 x i1> undef, <32 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE2p2-SME2p2-LABEL: 'fixed'
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i8 = call <2 x i8> @llvm.masked.expandload.v2i8(ptr undef, <2 x i1> undef, <2 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i8 = call <4 x i8> @llvm.masked.expandload.v4i8(ptr undef, <4 x i1> undef, <4 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:40 CodeSize:24 Lat:40 SizeLat:40 for: %v8i8 = call <8 x i8> @llvm.masked.expandload.v8i8(ptr undef, <8 x i1> undef, <8 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:80 CodeSize:48 Lat:80 SizeLat:80 for: %v16i8 = call <16 x i8> @llvm.masked.expandload.v16i8(ptr undef, <16 x i1> undef, <16 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i16 = call <2 x i16> @llvm.masked.expandload.v2i16(ptr undef, <2 x i1> undef, <2 x i16> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i16 = call <4 x i16> @llvm.masked.expandload.v4i16(ptr undef, <4 x i1> undef, <4 x i16> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:40 CodeSize:24 Lat:40 SizeLat:40 for: %v8i16 = call <8 x i16> @llvm.masked.expandload.v8i16(ptr undef, <8 x i1> undef, <8 x i16> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i32 = call <2 x i32> @llvm.masked.expandload.v2i32(ptr undef, <2 x i1> undef, <2 x i32> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i32 = call <4 x i32> @llvm.masked.expandload.v4i32(ptr undef, <4 x i1> undef, <4 x i32> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:10 CodeSize:6 Lat:10 SizeLat:10 for: %v2i64 = call <2 x i64> @llvm.masked.expandload.v2i64(ptr undef, <2 x i1> undef, <2 x i64> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:8 CodeSize:5 Lat:8 SizeLat:8 for: %v2f16 = call <2 x half> @llvm.masked.expandload.v2f16(ptr undef, <2 x i1> undef, <2 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:18 CodeSize:11 Lat:18 SizeLat:18 for: %v4f16 = call <4 x half> @llvm.masked.expandload.v4f16(ptr undef, <4 x i1> undef, <4 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:38 CodeSize:23 Lat:38 SizeLat:38 for: %v8f16 = call <8 x half> @llvm.masked.expandload.v8f16(ptr undef, <8 x i1> undef, <8 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:8 CodeSize:5 Lat:8 SizeLat:8 for: %v2f32 = call <2 x float> @llvm.masked.expandload.v2f32(ptr undef, <2 x i1> undef, <2 x float> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:18 CodeSize:11 Lat:18 SizeLat:18 for: %v4f32 = call <4 x float> @llvm.masked.expandload.v4f32(ptr undef, <4 x i1> undef, <4 x float> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:8 CodeSize:5 Lat:8 SizeLat:8 for: %v2f64 = call <2 x double> @llvm.masked.expandload.v2f64(ptr undef, <2 x i1> undef, <2 x double> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:20 CodeSize:12 Lat:20 SizeLat:20 for: %v4i64 = call <4 x i64> @llvm.masked.expandload.v4i64(ptr undef, <4 x i1> undef, <4 x i64> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:152 CodeSize:92 Lat:152 SizeLat:152 for: %v32f16 = call <32 x half> @llvm.masked.expandload.v32f16(ptr undef, <32 x i1> undef, <32 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE-ONLY-LABEL: 'fixed'
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v2i8 = call <2 x i8> @llvm.masked.expandload.v2i8(ptr undef, <2 x i1> undef, <2 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v4i8 = call <4 x i8> @llvm.masked.expandload.v4i8(ptr undef, <4 x i1> undef, <4 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v8i8 = call <8 x i8> @llvm.masked.expandload.v8i8(ptr undef, <8 x i1> undef, <8 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v16i8 = call <16 x i8> @llvm.masked.expandload.v16i8(ptr undef, <16 x i1> undef, <16 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v2i16 = call <2 x i16> @llvm.masked.expandload.v2i16(ptr undef, <2 x i1> undef, <2 x i16> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v4i16 = call <4 x i16> @llvm.masked.expandload.v4i16(ptr undef, <4 x i1> undef, <4 x i16> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v8i16 = call <8 x i16> @llvm.masked.expandload.v8i16(ptr undef, <8 x i1> undef, <8 x i16> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v2i32 = call <2 x i32> @llvm.masked.expandload.v2i32(ptr undef, <2 x i1> undef, <2 x i32> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v4i32 = call <4 x i32> @llvm.masked.expandload.v4i32(ptr undef, <4 x i1> undef, <4 x i32> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v2i64 = call <2 x i64> @llvm.masked.expandload.v2i64(ptr undef, <2 x i1> undef, <2 x i64> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v2f16 = call <2 x half> @llvm.masked.expandload.v2f16(ptr undef, <2 x i1> undef, <2 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v4f16 = call <4 x half> @llvm.masked.expandload.v4f16(ptr undef, <4 x i1> undef, <4 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v8f16 = call <8 x half> @llvm.masked.expandload.v8f16(ptr undef, <8 x i1> undef, <8 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v2f32 = call <2 x float> @llvm.masked.expandload.v2f32(ptr undef, <2 x i1> undef, <2 x float> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v4f32 = call <4 x float> @llvm.masked.expandload.v4f32(ptr undef, <4 x i1> undef, <4 x float> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v2f64 = call <2 x double> @llvm.masked.expandload.v2f64(ptr undef, <2 x i1> undef, <2 x double> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v4i64 = call <4 x i64> @llvm.masked.expandload.v4i64(ptr undef, <4 x i1> undef, <4 x i64> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %v32f16 = call <32 x half> @llvm.masked.expandload.v32f16(ptr undef, <32 x i1> undef, <32 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE2p2-SME2p2-SVE256-LABEL: 'fixed'
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v2i8 = call <2 x i8> @llvm.masked.expandload.v2i8(ptr undef, <2 x i1> undef, <2 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v4i8 = call <4 x i8> @llvm.masked.expandload.v4i8(ptr undef, <4 x i1> undef, <4 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v8i8 = call <8 x i8> @llvm.masked.expandload.v8i8(ptr undef, <8 x i1> undef, <8 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v16i8 = call <16 x i8> @llvm.masked.expandload.v16i8(ptr undef, <16 x i1> undef, <16 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v2i16 = call <2 x i16> @llvm.masked.expandload.v2i16(ptr undef, <2 x i1> undef, <2 x i16> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v4i16 = call <4 x i16> @llvm.masked.expandload.v4i16(ptr undef, <4 x i1> undef, <4 x i16> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v8i16 = call <8 x i16> @llvm.masked.expandload.v8i16(ptr undef, <8 x i1> undef, <8 x i16> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v2i32 = call <2 x i32> @llvm.masked.expandload.v2i32(ptr undef, <2 x i1> undef, <2 x i32> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v4i32 = call <4 x i32> @llvm.masked.expandload.v4i32(ptr undef, <4 x i1> undef, <4 x i32> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v2i64 = call <2 x i64> @llvm.masked.expandload.v2i64(ptr undef, <2 x i1> undef, <2 x i64> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v2f16 = call <2 x half> @llvm.masked.expandload.v2f16(ptr undef, <2 x i1> undef, <2 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v4f16 = call <4 x half> @llvm.masked.expandload.v4f16(ptr undef, <4 x i1> undef, <4 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v8f16 = call <8 x half> @llvm.masked.expandload.v8f16(ptr undef, <8 x i1> undef, <8 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v2f32 = call <2 x float> @llvm.masked.expandload.v2f32(ptr undef, <2 x i1> undef, <2 x float> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v4f32 = call <4 x float> @llvm.masked.expandload.v4f32(ptr undef, <4 x i1> undef, <4 x float> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v2f64 = call <2 x double> @llvm.masked.expandload.v2f64(ptr undef, <2 x i1> undef, <2 x double> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %v4i64 = call <4 x i64> @llvm.masked.expandload.v4i64(ptr undef, <4 x i1> undef, <4 x i64> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 2 for: %v32f16 = call <32 x half> @llvm.masked.expandload.v32f16(ptr undef, <32 x i1> undef, <32 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+entry:
+ ; Legal fixed-width integer types
+ %v2i8 = call <2 x i8> @llvm.masked.expandload.v2i8.p0(ptr undef, <2 x i1> undef, <2 x i8> undef)
+ %v4i8 = call <4 x i8> @llvm.masked.expandload.v4i8.p0(ptr undef, <4 x i1> undef, <4 x i8> undef)
+ %v8i8 = call <8 x i8> @llvm.masked.expandload.v8i8.p0(ptr undef, <8 x i1> undef, <8 x i8> undef)
+ %v16i8 = call <16 x i8> @llvm.masked.expandload.v16i8.p0(ptr undef, <16 x i1> undef, <16 x i8> undef)
+ %v2i16 = call <2 x i16> @llvm.masked.expandload.v2i16.p0(ptr undef, <2 x i1> undef, <2 x i16> undef)
+ %v4i16 = call <4 x i16> @llvm.masked.expandload.v4i16.p0(ptr undef, <4 x i1> undef, <4 x i16> undef)
+ %v8i16 = call <8 x i16> @llvm.masked.expandload.v8i16.p0(ptr undef, <8 x i1> undef, <8 x i16> undef)
+ %v2i32 = call <2 x i32> @llvm.masked.expandload.v2i32.p0(ptr undef, <2 x i1> undef, <2 x i32> undef)
+ %v4i32 = call <4 x i32> @llvm.masked.expandload.v4i32.p0(ptr undef, <4 x i1> undef, <4 x i32> undef)
+ %v2i64 = call <2 x i64> @llvm.masked.expandload.v2i64.p0(ptr undef, <2 x i1> undef, <2 x i64> undef)
+
+ ; Legal fixed-width floating point types
+ %v2f16 = call <2 x half> @llvm.masked.expandload.v2f16.p0(ptr undef, <2 x i1> undef, <2 x half> undef)
+ %v4f16 = call <4 x half> @llvm.masked.expandload.v4f16.p0(ptr undef, <4 x i1> undef, <4 x half> undef)
+ %v8f16 = call <8 x half> @llvm.masked.expandload.v8f16.p0(ptr undef, <8 x i1> undef, <8 x half> undef)
+ %v2f32 = call <2 x float> @llvm.masked.expandload.v2f32.p0(ptr undef, <2 x i1> undef, <2 x float> undef)
+ %v4f32 = call <4 x float> @llvm.masked.expandload.v4f32.p0(ptr undef, <4 x i1> undef, <4 x float> undef)
+ %v2f64 = call <2 x double> @llvm.masked.expandload.v2f64.p0(ptr undef, <2 x i1> undef, <2 x double> undef)
+
+ ; Examples of illegal fixed-width types
+ %v4i64 = call <4 x i64> @llvm.masked.expandload.v4i64.p0(ptr undef, <4 x i1> undef, <4 x i64> undef)
+ %v32f16 = call <32 x half> @llvm.masked.expandload.v32f16.p0(ptr undef, <32 x i1> undef, <32 x half> undef)
+
+ ret void
+}
+
+define void @scalable() {
+; SVE2p2-SME2p2-NON-STREAMING-LABEL: 'scalable'
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i8 = call <vscale x 2 x i8> @llvm.masked.expandload.nxv2i8(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4i8 = call <vscale x 4 x i8> @llvm.masked.expandload.nxv4i8(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv8i8 = call <vscale x 8 x i8> @llvm.masked.expandload.nxv8i8(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv16i8 = call <vscale x 16 x i8> @llvm.masked.expandload.nxv16i8(ptr undef, <vscale x 16 x i1> undef, <vscale x 16 x i8> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i16 = call <vscale x 2 x i16> @llvm.masked.expandload.nxv2i16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i16> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4i16 = call <vscale x 4 x i16> @llvm.masked.expandload.nxv4i16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i16> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv8i16 = call <vscale x 8 x i16> @llvm.masked.expandload.nxv8i16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i16> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i32 = call <vscale x 2 x i32> @llvm.masked.expandload.nxv2i32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i32> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4i32 = call <vscale x 4 x i32> @llvm.masked.expandload.nxv4i32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i32> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i64 = call <vscale x 2 x i64> @llvm.masked.expandload.nxv2i64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i64> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2f16 = call <vscale x 2 x half> @llvm.masked.expandload.nxv2f16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4f16 = call <vscale x 4 x half> @llvm.masked.expandload.nxv4f16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv8f16 = call <vscale x 8 x half> @llvm.masked.expandload.nxv8f16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2f32 = call <vscale x 2 x float> @llvm.masked.expandload.nxv2f32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x float> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4f32 = call <vscale x 4 x float> @llvm.masked.expandload.nxv4f32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x float> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2f64 = call <vscale x 2 x double> @llvm.masked.expandload.nxv2f64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x double> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of Invalid for: %nxv1i64 = call <vscale x 1 x i64> @llvm.masked.expandload.nxv1i64(ptr undef, <vscale x 1 x i1> undef, <vscale x 1 x i64> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 2 for: %nxv4i64 = call <vscale x 4 x i64> @llvm.masked.expandload.nxv4i64(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i64> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of 4 for: %nxv32f16 = call <vscale x 32 x half> @llvm.masked.expandload.nxv32f16(ptr undef, <vscale x 32 x i1> undef, <vscale x 32 x half> undef)
+; SVE2p2-SME2p2-NON-STREAMING-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE2p2-SME2p2-STREAMING-LABEL: 'scalable'
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i8 = call <vscale x 2 x i8> @llvm.masked.expandload.nxv2i8(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4i8 = call <vscale x 4 x i8> @llvm.masked.expandload.nxv4i8(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv8i8 = call <vscale x 8 x i8> @llvm.masked.expandload.nxv8i8(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv16i8 = call <vscale x 16 x i8> @llvm.masked.expandload.nxv16i8(ptr undef, <vscale x 16 x i1> undef, <vscale x 16 x i8> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i16 = call <vscale x 2 x i16> @llvm.masked.expandload.nxv2i16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i16> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4i16 = call <vscale x 4 x i16> @llvm.masked.expandload.nxv4i16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i16> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv8i16 = call <vscale x 8 x i16> @llvm.masked.expandload.nxv8i16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i16> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i32 = call <vscale x 2 x i32> @llvm.masked.expandload.nxv2i32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i32> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4i32 = call <vscale x 4 x i32> @llvm.masked.expandload.nxv4i32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i32> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2i64 = call <vscale x 2 x i64> @llvm.masked.expandload.nxv2i64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i64> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2f16 = call <vscale x 2 x half> @llvm.masked.expandload.nxv2f16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4f16 = call <vscale x 4 x half> @llvm.masked.expandload.nxv4f16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv8f16 = call <vscale x 8 x half> @llvm.masked.expandload.nxv8f16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2f32 = call <vscale x 2 x float> @llvm.masked.expandload.nxv2f32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x float> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv4f32 = call <vscale x 4 x float> @llvm.masked.expandload.nxv4f32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x float> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 1 for: %nxv2f64 = call <vscale x 2 x double> @llvm.masked.expandload.nxv2f64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x double> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of Invalid for: %nxv1i64 = call <vscale x 1 x i64> @llvm.masked.expandload.nxv1i64(ptr undef, <vscale x 1 x i1> undef, <vscale x 1 x i64> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 2 for: %nxv4i64 = call <vscale x 4 x i64> @llvm.masked.expandload.nxv4i64(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i64> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of 4 for: %nxv32f16 = call <vscale x 32 x half> @llvm.masked.expandload.nxv32f16(ptr undef, <vscale x 32 x i1> undef, <vscale x 32 x half> undef)
+; SVE2p2-SME2p2-STREAMING-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE2p2-SME2p2-LABEL: 'scalable'
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv2i8 = call <vscale x 2 x i8> @llvm.masked.expandload.nxv2i8(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv4i8 = call <vscale x 4 x i8> @llvm.masked.expandload.nxv4i8(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv8i8 = call <vscale x 8 x i8> @llvm.masked.expandload.nxv8i8(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv16i8 = call <vscale x 16 x i8> @llvm.masked.expandload.nxv16i8(ptr undef, <vscale x 16 x i1> undef, <vscale x 16 x i8> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv2i16 = call <vscale x 2 x i16> @llvm.masked.expandload.nxv2i16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i16> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv4i16 = call <vscale x 4 x i16> @llvm.masked.expandload.nxv4i16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i16> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv8i16 = call <vscale x 8 x i16> @llvm.masked.expandload.nxv8i16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i16> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv2i32 = call <vscale x 2 x i32> @llvm.masked.expandload.nxv2i32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i32> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv4i32 = call <vscale x 4 x i32> @llvm.masked.expandload.nxv4i32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i32> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv2i64 = call <vscale x 2 x i64> @llvm.masked.expandload.nxv2i64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i64> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv2f16 = call <vscale x 2 x half> @llvm.masked.expandload.nxv2f16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv4f16 = call <vscale x 4 x half> @llvm.masked.expandload.nxv4f16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv8f16 = call <vscale x 8 x half> @llvm.masked.expandload.nxv8f16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv2f32 = call <vscale x 2 x float> @llvm.masked.expandload.nxv2f32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x float> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv4f32 = call <vscale x 4 x float> @llvm.masked.expandload.nxv4f32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x float> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 1 for: %nxv2f64 = call <vscale x 2 x double> @llvm.masked.expandload.nxv2f64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x double> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of Invalid for: %nxv1i64 = call <vscale x 1 x i64> @llvm.masked.expandload.nxv1i64(ptr undef, <vscale x 1 x i1> undef, <vscale x 1 x i64> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 2 for: %nxv4i64 = call <vscale x 4 x i64> @llvm.masked.expandload.nxv4i64(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i64> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of 4 for: %nxv32f16 = call <vscale x 32 x half> @llvm.masked.expandload.nxv32f16(ptr undef, <vscale x 32 x i1> undef, <vscale x 32 x half> undef)
+; SVE2p2-SME2p2-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE-ONLY-LABEL: 'scalable'
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv2i8 = call <vscale x 2 x i8> @llvm.masked.expandload.nxv2i8(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv4i8 = call <vscale x 4 x i8> @llvm.masked.expandload.nxv4i8(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv8i8 = call <vscale x 8 x i8> @llvm.masked.expandload.nxv8i8(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv16i8 = call <vscale x 16 x i8> @llvm.masked.expandload.nxv16i8(ptr undef, <vscale x 16 x i1> undef, <vscale x 16 x i8> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv2i16 = call <vscale x 2 x i16> @llvm.masked.expandload.nxv2i16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i16> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv4i16 = call <vscale x 4 x i16> @llvm.masked.expandload.nxv4i16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i16> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv8i16 = call <vscale x 8 x i16> @llvm.masked.expandload.nxv8i16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i16> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv2i32 = call <vscale x 2 x i32> @llvm.masked.expandload.nxv2i32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i32> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv4i32 = call <vscale x 4 x i32> @llvm.masked.expandload.nxv4i32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i32> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv2i64 = call <vscale x 2 x i64> @llvm.masked.expandload.nxv2i64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i64> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv2f16 = call <vscale x 2 x half> @llvm.masked.expandload.nxv2f16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv4f16 = call <vscale x 4 x half> @llvm.masked.expandload.nxv4f16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv8f16 = call <vscale x 8 x half> @llvm.masked.expandload.nxv8f16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv2f32 = call <vscale x 2 x float> @llvm.masked.expandload.nxv2f32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x float> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv4f32 = call <vscale x 4 x float> @llvm.masked.expandload.nxv4f32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x float> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv2f64 = call <vscale x 2 x double> @llvm.masked.expandload.nxv2f64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x double> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv1i64 = call <vscale x 1 x i64> @llvm.masked.expandload.nxv1i64(ptr undef, <vscale x 1 x i1> undef, <vscale x 1 x i64> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv4i64 = call <vscale x 4 x i64> @llvm.masked.expandload.nxv4i64(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i64> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of Invalid for: %nxv32f16 = call <vscale x 32 x half> @llvm.masked.expandload.nxv32f16(ptr undef, <vscale x 32 x i1> undef, <vscale x 32 x half> undef)
+; SVE-ONLY-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+; SVE2p2-SME2p2-SVE256-LABEL: 'scalable'
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv2i8 = call <vscale x 2 x i8> @llvm.masked.expandload.nxv2i8(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv4i8 = call <vscale x 4 x i8> @llvm.masked.expandload.nxv4i8(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv8i8 = call <vscale x 8 x i8> @llvm.masked.expandload.nxv8i8(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv16i8 = call <vscale x 16 x i8> @llvm.masked.expandload.nxv16i8(ptr undef, <vscale x 16 x i1> undef, <vscale x 16 x i8> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv2i16 = call <vscale x 2 x i16> @llvm.masked.expandload.nxv2i16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i16> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv4i16 = call <vscale x 4 x i16> @llvm.masked.expandload.nxv4i16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i16> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv8i16 = call <vscale x 8 x i16> @llvm.masked.expandload.nxv8i16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i16> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv2i32 = call <vscale x 2 x i32> @llvm.masked.expandload.nxv2i32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i32> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv4i32 = call <vscale x 4 x i32> @llvm.masked.expandload.nxv4i32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i32> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv2i64 = call <vscale x 2 x i64> @llvm.masked.expandload.nxv2i64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i64> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv2f16 = call <vscale x 2 x half> @llvm.masked.expandload.nxv2f16(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv4f16 = call <vscale x 4 x half> @llvm.masked.expandload.nxv4f16(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv8f16 = call <vscale x 8 x half> @llvm.masked.expandload.nxv8f16(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv2f32 = call <vscale x 2 x float> @llvm.masked.expandload.nxv2f32(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x float> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv4f32 = call <vscale x 4 x float> @llvm.masked.expandload.nxv4f32(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x float> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 1 for: %nxv2f64 = call <vscale x 2 x double> @llvm.masked.expandload.nxv2f64(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x double> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of Invalid for: %nxv1i64 = call <vscale x 1 x i64> @llvm.masked.expandload.nxv1i64(ptr undef, <vscale x 1 x i1> undef, <vscale x 1 x i64> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 2 for: %nxv4i64 = call <vscale x 4 x i64> @llvm.masked.expandload.nxv4i64(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i64> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of 4 for: %nxv32f16 = call <vscale x 32 x half> @llvm.masked.expandload.nxv32f16(ptr undef, <vscale x 32 x i1> undef, <vscale x 32 x half> undef)
+; SVE2p2-SME2p2-SVE256-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret void
+;
+entry:
+ ; Legal scalable integer types
+ %nxv2i8 = call <vscale x 2 x i8> @llvm.masked.expandload.nxv2i8.p0(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i8> undef)
+ %nxv4i8 = call <vscale x 4 x i8> @llvm.masked.expandload.nxv4i8.p0(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i8> undef)
+ %nxv8i8 = call <vscale x 8 x i8> @llvm.masked.expandload.nxv8i8.p0(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i8> undef)
+ %nxv16i8 = call <vscale x 16 x i8> @llvm.masked.expandload.nxv16i8.p0(ptr undef, <vscale x 16 x i1> undef, <vscale x 16 x i8> undef)
+ %nxv2i16 = call <vscale x 2 x i16> @llvm.masked.expandload.nxv2i16.p0(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i16> undef)
+ %nxv4i16 = call <vscale x 4 x i16> @llvm.masked.expandload.nxv4i16.p0(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i16> undef)
+ %nxv8i16 = call <vscale x 8 x i16> @llvm.masked.expandload.nxv8i16.p0(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x i16> undef)
+ %nxv2i32 = call <vscale x 2 x i32> @llvm.masked.expandload.nxv2i32.p0(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i32> undef)
+ %nxv4i32 = call <vscale x 4 x i32> @llvm.masked.expandload.nxv4i32.p0(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i32> undef)
+ %nxv2i64 = call <vscale x 2 x i64> @llvm.masked.expandload.nxv2i64.p0(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x i64> undef)
+
+ ; Legal scalable floating point types
+ %nxv2f16 = call <vscale x 2 x half> @llvm.masked.expandload.nxv2f16.p0(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x half> undef)
+ %nxv4f16 = call <vscale x 4 x half> @llvm.masked.expandload.nxv4f16.p0(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x half> undef)
+ %nxv8f16 = call <vscale x 8 x half> @llvm.masked.expandload.nxv8f16.p0(ptr undef, <vscale x 8 x i1> undef, <vscale x 8 x half> undef)
+ %nxv2f32 = call <vscale x 2 x float> @llvm.masked.expandload.nxv2f32.p0(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x float> undef)
+ %nxv4f32 = call <vscale x 4 x float> @llvm.masked.expandload.nxv4f32.p0(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x float> undef)
+ %nxv2f64 = call <vscale x 2 x double> @llvm.masked.expandload.nxv2f64.p0(ptr undef, <vscale x 2 x i1> undef, <vscale x 2 x double> undef)
+
+ ; Examples of illegal scalable types
+ %nxv1i64 = call <vscale x 1 x i64> @llvm.masked.expandload.nxv1i64.p0(ptr undef, <vscale x 1 x i1> undef, <vscale x 1 x i64> undef)
+ %nxv4i64 = call <vscale x 4 x i64> @llvm.masked.expandload.nxv4i64.p0(ptr undef, <vscale x 4 x i1> undef, <vscale x 4 x i64> undef)
+ %nxv32f16 = call <vscale x 32 x half> @llvm.masked.expandload.nxv32f16.p0(ptr undef, <vscale x 32 x i1> undef, <vscale x 32 x half> undef)
+
+ ret void
+}
diff --git a/llvm/test/CodeGen/AArch64/fixed-expanding-load.ll b/llvm/test/CodeGen/AArch64/fixed-expanding-load.ll
new file mode 100644
index 0000000000000..81565137298da
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/fixed-expanding-load.ll
@@ -0,0 +1,581 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -mattr=+sve2p2 -enable-subreg-liveness -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s --check-prefix=CHECK-EXPAND
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -mattr=+sme2p2 -enable-subreg-liveness -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s --check-prefix=CHECK-EXPAND
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -mattr=+sme2p2 -force-streaming -enable-subreg-liveness -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s --check-prefix=CHECK-EXPAND-STREAMING
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve2p2 -mattr=+sme-fa64 -force-streaming -enable-subreg-liveness -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s --check-prefix=CHECK-EXPAND
+
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve2p2 -mattr=+sme -force-streaming -enable-subreg-liveness -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s --check-prefix=CHECK-NO-EXPAND-STREAMING
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sme2p2 -enable-subreg-liveness -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s --check-prefix=CHECK-NO-SVE
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -mattr=+sve2p2 -enable-subreg-liveness < %s | FileCheck %s --check-prefix=CHECK-USE-NEON
+
+define <2 x i64> @test_fixed_expandload(ptr %base, <2 x i64> %passthru, <2 x i1> %pred) {
+; CHECK-EXPAND-LABEL: test_fixed_expandload:
+; CHECK-EXPAND: // %bb.0:
+; CHECK-EXPAND-NEXT: ushll v1.2d, v1.2s, #0
+; CHECK-EXPAND-NEXT: ptrue p0.d, vl2
+; CHECK-EXPAND-NEXT: shl v1.2d, v1.2d, #63
+; CHECK-EXPAND-NEXT: cmpne p0.d, p0/z, z1.d, #0
+; CHECK-EXPAND-NEXT: cntp x8, p0, p0.d
+; CHECK-EXPAND-NEXT: whilelo p1.d, xzr, x8
+; CHECK-EXPAND-NEXT: ld1d { z1.d }, p1/z, [x0]
+; CHECK-EXPAND-NEXT: expand z1.d, p0, z1.d
+; CHECK-EXPAND-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-EXPAND-NEXT: ret
+;
+; CHECK-EXPAND-STREAMING-LABEL: test_fixed_expandload:
+; CHECK-EXPAND-STREAMING: // %bb.0:
+; CHECK-EXPAND-STREAMING-NEXT: uunpklo z1.d, z1.s
+; CHECK-EXPAND-STREAMING-NEXT: ptrue p0.d, vl2
+; CHECK-EXPAND-STREAMING-NEXT: lsl z1.d, z1.d, #63
+; CHECK-EXPAND-STREAMING-NEXT: asr z1.d, z1.d, #63
+; CHECK-EXPAND-STREAMING-NEXT: cmpne p0.d, p0/z, z1.d, #0
+; CHECK-EXPAND-STREAMING-NEXT: cntp x8, p0, p0.d
+; CHECK-EXPAND-STREAMING-NEXT: whilelo p1.d, xzr, x8
+; CHECK-EXPAND-STREAMING-NEXT: ld1d { z1.d }, p1/z, [x0]
+; CHECK-EXPAND-STREAMING-NEXT: expand z1.d, p0, z1.d
+; CHECK-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-EXPAND-STREAMING-NEXT: ret
+;
+; CHECK-NO-EXPAND-STREAMING-LABEL: test_fixed_expandload:
+; CHECK-NO-EXPAND-STREAMING: // %bb.0:
+; CHECK-NO-EXPAND-STREAMING-NEXT: sub sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NO-EXPAND-STREAMING-NEXT: lsl z1.s, z1.s, #31
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z2.s, #1, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.s, vl2
+; CHECK-NO-EXPAND-STREAMING-NEXT: asr z1.s, z1.s, #31
+; CHECK-NO-EXPAND-STREAMING-NEXT: and z1.d, z1.d, z2.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: uaddv d1, p0, z1.s
+; CHECK-NO-EXPAND-STREAMING-NEXT: str b1, [sp, #12]
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldrb w8, [sp, #12]
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #0, .LBB0_3
+; CHECK-NO-EXPAND-STREAMING-NEXT: // %bb.1: // %else
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #1, .LBB0_4
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB0_2: // %else2
+; CHECK-NO-EXPAND-STREAMING-NEXT: add sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: ret
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB0_3: // %cond.load
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr x9, [x0], #8
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.d, vl1
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, x9
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #1, .LBB0_2
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB0_4: // %cond.load1
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov w8, #1 // =0x1
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z1.d, #0, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z2.d, x8
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr x8, [x0]
+; CHECK-NO-EXPAND-STREAMING-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, x8
+; CHECK-NO-EXPAND-STREAMING-NEXT: add sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: ret
+;
+; CHECK-NO-SVE-LABEL: test_fixed_expandload:
+; CHECK-NO-SVE: // %bb.0:
+; CHECK-NO-SVE-NEXT: shl v1.2s, v1.2s, #31
+; CHECK-NO-SVE-NEXT: mov x8, #1 // =0x1
+; CHECK-NO-SVE-NEXT: movk x8, #2, lsl #32
+; CHECK-NO-SVE-NEXT: fmov d2, x8
+; CHECK-NO-SVE-NEXT: cmlt v1.2s, v1.2s, #0
+; CHECK-NO-SVE-NEXT: and v1.8b, v1.8b, v2.8b
+; CHECK-NO-SVE-NEXT: addp v1.2s, v1.2s, v1.2s
+; CHECK-NO-SVE-NEXT: fmov w8, s1
+; CHECK-NO-SVE-NEXT: tbnz w8, #0, .LBB0_3
+; CHECK-NO-SVE-NEXT: // %bb.1: // %else
+; CHECK-NO-SVE-NEXT: tbnz w8, #1, .LBB0_4
+; CHECK-NO-SVE-NEXT: .LBB0_2: // %else2
+; CHECK-NO-SVE-NEXT: ret
+; CHECK-NO-SVE-NEXT: .LBB0_3: // %cond.load
+; CHECK-NO-SVE-NEXT: ld1 { v0.d }[0], [x0], #8
+; CHECK-NO-SVE-NEXT: tbz w8, #1, .LBB0_2
+; CHECK-NO-SVE-NEXT: .LBB0_4: // %cond.load1
+; CHECK-NO-SVE-NEXT: ld1 { v0.d }[1], [x0]
+; CHECK-NO-SVE-NEXT: ret
+;
+; CHECK-USE-NEON-LABEL: test_fixed_expandload:
+; CHECK-USE-NEON: // %bb.0:
+; CHECK-USE-NEON-NEXT: shl v1.2s, v1.2s, #31
+; CHECK-USE-NEON-NEXT: index z2.s, #1, #1
+; CHECK-USE-NEON-NEXT: cmlt v1.2s, v1.2s, #0
+; CHECK-USE-NEON-NEXT: and v1.8b, v1.8b, v2.8b
+; CHECK-USE-NEON-NEXT: addp v1.2s, v1.2s, v1.2s
+; CHECK-USE-NEON-NEXT: fmov w8, s1
+; CHECK-USE-NEON-NEXT: tbnz w8, #0, .LBB0_3
+; CHECK-USE-NEON-NEXT: // %bb.1: // %else
+; CHECK-USE-NEON-NEXT: tbnz w8, #1, .LBB0_4
+; CHECK-USE-NEON-NEXT: .LBB0_2: // %else2
+; CHECK-USE-NEON-NEXT: ret
+; CHECK-USE-NEON-NEXT: .LBB0_3: // %cond.load
+; CHECK-USE-NEON-NEXT: ld1 { v0.d }[0], [x0], #8
+; CHECK-USE-NEON-NEXT: tbz w8, #1, .LBB0_2
+; CHECK-USE-NEON-NEXT: .LBB0_4: // %cond.load1
+; CHECK-USE-NEON-NEXT: ld1 { v0.d }[1], [x0]
+; CHECK-USE-NEON-NEXT: ret
+ %res = call <2 x i64> @llvm.masked.expandload(ptr align 1 %base, <2 x i1> %pred, <2 x i64> %passthru)
+ ret <2 x i64> %res
+}
+
+define <4 x double> @test_split_fixed_expandload(ptr %base, <4 x double> %passthru, <4 x i1> %pred) {
+; CHECK-EXPAND-LABEL: test_split_fixed_expandload:
+; CHECK-EXPAND: // %bb.0:
+; CHECK-EXPAND-NEXT: uunpklo z2.s, z2.h
+; CHECK-EXPAND-NEXT: ptrue p0.d, vl4
+; CHECK-EXPAND-NEXT: ptrue p1.d, vl2
+; CHECK-EXPAND-NEXT: splice z0.d, p1, { z0.d, z1.d }
+; CHECK-EXPAND-NEXT: uunpklo z2.d, z2.s
+; CHECK-EXPAND-NEXT: lsl z2.d, z2.d, #63
+; CHECK-EXPAND-NEXT: asr z2.d, z2.d, #63
+; CHECK-EXPAND-NEXT: cmpne p0.d, p0/z, z2.d, #0
+; CHECK-EXPAND-NEXT: cntp x8, p0, p0.d
+; CHECK-EXPAND-NEXT: whilelo p2.d, xzr, x8
+; CHECK-EXPAND-NEXT: ld1d { z1.d }, p2/z, [x0]
+; CHECK-EXPAND-NEXT: expand z1.d, p0, z1.d
+; CHECK-EXPAND-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-EXPAND-NEXT: movprfx z1, z0
+; CHECK-EXPAND-NEXT: ext z1.b, z1.b, z0.b, #16
+; CHECK-EXPAND-NEXT: ret
+;
+; CHECK-EXPAND-STREAMING-LABEL: test_split_fixed_expandload:
+; CHECK-EXPAND-STREAMING: // %bb.0:
+; CHECK-EXPAND-STREAMING-NEXT: uunpklo z2.s, z2.h
+; CHECK-EXPAND-STREAMING-NEXT: ptrue p0.d, vl4
+; CHECK-EXPAND-STREAMING-NEXT: ptrue p1.d, vl2
+; CHECK-EXPAND-STREAMING-NEXT: splice z0.d, p1, { z0.d, z1.d }
+; CHECK-EXPAND-STREAMING-NEXT: uunpklo z2.d, z2.s
+; CHECK-EXPAND-STREAMING-NEXT: lsl z2.d, z2.d, #63
+; CHECK-EXPAND-STREAMING-NEXT: asr z2.d, z2.d, #63
+; CHECK-EXPAND-STREAMING-NEXT: cmpne p0.d, p0/z, z2.d, #0
+; CHECK-EXPAND-STREAMING-NEXT: cntp x8, p0, p0.d
+; CHECK-EXPAND-STREAMING-NEXT: whilelo p2.d, xzr, x8
+; CHECK-EXPAND-STREAMING-NEXT: ld1d { z1.d }, p2/z, [x0]
+; CHECK-EXPAND-STREAMING-NEXT: expand z1.d, p0, z1.d
+; CHECK-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-EXPAND-STREAMING-NEXT: movprfx z1, z0
+; CHECK-EXPAND-STREAMING-NEXT: ext z1.b, z1.b, z0.b, #16
+; CHECK-EXPAND-STREAMING-NEXT: ret
+;
+; CHECK-NO-EXPAND-STREAMING-LABEL: test_split_fixed_expandload:
+; CHECK-NO-EXPAND-STREAMING: // %bb.0:
+; CHECK-NO-EXPAND-STREAMING-NEXT: sub sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NO-EXPAND-STREAMING-NEXT: lsl z2.h, z2.h, #15
+; CHECK-NO-EXPAND-STREAMING-NEXT: adrp x8, .LCPI1_0
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.h, vl4
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr d3, [x8, :lo12:.LCPI1_0]
+; CHECK-NO-EXPAND-STREAMING-NEXT: asr z2.h, z2.h, #15
+; CHECK-NO-EXPAND-STREAMING-NEXT: and z2.d, z2.d, z3.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: uaddv d2, p0, z2.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.d, vl2
+; CHECK-NO-EXPAND-STREAMING-NEXT: splice z0.d, p0, { z0.d, z1.d }
+; CHECK-NO-EXPAND-STREAMING-NEXT: str b2, [sp, #12]
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldrb w8, [sp, #12]
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #0, .LBB1_6
+; CHECK-NO-EXPAND-STREAMING-NEXT: // %bb.1: // %else
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #1, .LBB1_7
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB1_2: // %else2
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #2, .LBB1_8
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB1_3: // %else6
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #3, .LBB1_5
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB1_4: // %cond.load9
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov w8, #3 // =0x3
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z1.d, #0, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z2.d, x8
+; CHECK-NO-EXPAND-STREAMING-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr d1, [x0]
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, d1
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB1_5: // %else10
+; CHECK-NO-EXPAND-STREAMING-NEXT: movprfx z1, z0
+; CHECK-NO-EXPAND-STREAMING-NEXT: ext z1.b, z1.b, z0.b, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: add sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: ret
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB1_6: // %cond.load
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr d1, [x0], #8
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.d, vl1
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #1, .LBB1_2
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB1_7: // %cond.load1
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov w9, #1 // =0x1
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z1.d, #0, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z2.d, x9
+; CHECK-NO-EXPAND-STREAMING-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr d1, [x0], #8
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, d1
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #2, .LBB1_3
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB1_8: // %cond.load5
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov w9, #2 // =0x2
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z1.d, #0, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z2.d, x9
+; CHECK-NO-EXPAND-STREAMING-NEXT: cmpeq p0.d, p0/z, z1.d, z2.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr d1, [x0], #8
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.d, p0/m, d1
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #3, .LBB1_4
+; CHECK-NO-EXPAND-STREAMING-NEXT: b .LBB1_5
+;
+; CHECK-NO-SVE-LABEL: test_split_fixed_expandload:
+; CHECK-NO-SVE: // %bb.0:
+; CHECK-NO-SVE-NEXT: shl v2.4h, v2.4h, #15
+; CHECK-NO-SVE-NEXT: adrp x8, .LCPI1_0
+; CHECK-NO-SVE-NEXT: ldr d3, [x8, :lo12:.LCPI1_0]
+; CHECK-NO-SVE-NEXT: cmlt v2.4h, v2.4h, #0
+; CHECK-NO-SVE-NEXT: and v2.8b, v2.8b, v3.8b
+; CHECK-NO-SVE-NEXT: addv h2, v2.4h
+; CHECK-NO-SVE-NEXT: fmov w8, s2
+; CHECK-NO-SVE-NEXT: tbnz w8, #0, .LBB1_5
+; CHECK-NO-SVE-NEXT: // %bb.1: // %else
+; CHECK-NO-SVE-NEXT: tbnz w8, #1, .LBB1_6
+; CHECK-NO-SVE-NEXT: .LBB1_2: // %else2
+; CHECK-NO-SVE-NEXT: tbnz w8, #2, .LBB1_7
+; CHECK-NO-SVE-NEXT: .LBB1_3: // %else6
+; CHECK-NO-SVE-NEXT: tbnz w8, #3, .LBB1_8
+; CHECK-NO-SVE-NEXT: .LBB1_4: // %else10
+; CHECK-NO-SVE-NEXT: ret
+; CHECK-NO-SVE-NEXT: .LBB1_5: // %cond.load
+; CHECK-NO-SVE-NEXT: ld1 { v0.d }[0], [x0], #8
+; CHECK-NO-SVE-NEXT: tbz w8, #1, .LBB1_2
+; CHECK-NO-SVE-NEXT: .LBB1_6: // %cond.load1
+; CHECK-NO-SVE-NEXT: ld1 { v0.d }[1], [x0], #8
+; CHECK-NO-SVE-NEXT: tbz w8, #2, .LBB1_3
+; CHECK-NO-SVE-NEXT: .LBB1_7: // %cond.load5
+; CHECK-NO-SVE-NEXT: ld1 { v1.d }[0], [x0], #8
+; CHECK-NO-SVE-NEXT: tbz w8, #3, .LBB1_4
+; CHECK-NO-SVE-NEXT: .LBB1_8: // %cond.load9
+; CHECK-NO-SVE-NEXT: ld1 { v1.d }[1], [x0]
+; CHECK-NO-SVE-NEXT: ret
+;
+; CHECK-USE-NEON-LABEL: test_split_fixed_expandload:
+; CHECK-USE-NEON: // %bb.0:
+; CHECK-USE-NEON-NEXT: shl v2.4h, v2.4h, #15
+; CHECK-USE-NEON-NEXT: adrp x8, .LCPI1_0
+; CHECK-USE-NEON-NEXT: ldr d3, [x8, :lo12:.LCPI1_0]
+; CHECK-USE-NEON-NEXT: cmlt v2.4h, v2.4h, #0
+; CHECK-USE-NEON-NEXT: and v2.8b, v2.8b, v3.8b
+; CHECK-USE-NEON-NEXT: addv h2, v2.4h
+; CHECK-USE-NEON-NEXT: fmov w8, s2
+; CHECK-USE-NEON-NEXT: tbnz w8, #0, .LBB1_5
+; CHECK-USE-NEON-NEXT: // %bb.1: // %else
+; CHECK-USE-NEON-NEXT: tbnz w8, #1, .LBB1_6
+; CHECK-USE-NEON-NEXT: .LBB1_2: // %else2
+; CHECK-USE-NEON-NEXT: tbnz w8, #2, .LBB1_7
+; CHECK-USE-NEON-NEXT: .LBB1_3: // %else6
+; CHECK-USE-NEON-NEXT: tbnz w8, #3, .LBB1_8
+; CHECK-USE-NEON-NEXT: .LBB1_4: // %else10
+; CHECK-USE-NEON-NEXT: ret
+; CHECK-USE-NEON-NEXT: .LBB1_5: // %cond.load
+; CHECK-USE-NEON-NEXT: ld1 { v0.d }[0], [x0], #8
+; CHECK-USE-NEON-NEXT: tbz w8, #1, .LBB1_2
+; CHECK-USE-NEON-NEXT: .LBB1_6: // %cond.load1
+; CHECK-USE-NEON-NEXT: ld1 { v0.d }[1], [x0], #8
+; CHECK-USE-NEON-NEXT: tbz w8, #2, .LBB1_3
+; CHECK-USE-NEON-NEXT: .LBB1_7: // %cond.load5
+; CHECK-USE-NEON-NEXT: ld1 { v1.d }[0], [x0], #8
+; CHECK-USE-NEON-NEXT: tbz w8, #3, .LBB1_4
+; CHECK-USE-NEON-NEXT: .LBB1_8: // %cond.load9
+; CHECK-USE-NEON-NEXT: ld1 { v1.d }[1], [x0]
+; CHECK-USE-NEON-NEXT: ret
+ %res = call <4 x double> @llvm.masked.expandload(ptr align 1 %base, <4 x i1> %pred, <4 x double> %passthru)
+ ret <4 x double> %res
+}
+
+define <3 x i32> @test_widen_fixed_expandload(ptr %base, <3 x i32> %passthru, <3 x i1> %pred) {
+; CHECK-EXPAND-LABEL: test_widen_fixed_expandload:
+; CHECK-EXPAND: // %bb.0:
+; CHECK-EXPAND-NEXT: movi v1.2d, #0000000000000000
+; CHECK-EXPAND-NEXT: ptrue p0.s, vl4
+; CHECK-EXPAND-NEXT: mov v1.h[0], w1
+; CHECK-EXPAND-NEXT: mov v1.h[1], w2
+; CHECK-EXPAND-NEXT: mov v1.h[2], w3
+; CHECK-EXPAND-NEXT: ushll v1.4s, v1.4h, #0
+; CHECK-EXPAND-NEXT: shl v1.4s, v1.4s, #31
+; CHECK-EXPAND-NEXT: cmpne p0.s, p0/z, z1.s, #0
+; CHECK-EXPAND-NEXT: cntp x8, p0, p0.s
+; CHECK-EXPAND-NEXT: whilelo p1.s, xzr, x8
+; CHECK-EXPAND-NEXT: ld1w { z1.s }, p1/z, [x0]
+; CHECK-EXPAND-NEXT: expand z1.s, p0, z1.s
+; CHECK-EXPAND-NEXT: mov z0.s, p0/m, z1.s
+; CHECK-EXPAND-NEXT: ret
+;
+; CHECK-EXPAND-STREAMING-LABEL: test_widen_fixed_expandload:
+; CHECK-EXPAND-STREAMING: // %bb.0:
+; CHECK-EXPAND-STREAMING-NEXT: fmov s1, w2
+; CHECK-EXPAND-STREAMING-NEXT: fmov s2, w1
+; CHECK-EXPAND-STREAMING-NEXT: adrp x8, .LCPI2_0
+; CHECK-EXPAND-STREAMING-NEXT: ptrue p0.s, vl4
+; CHECK-EXPAND-STREAMING-NEXT: zip1 z1.h, z2.h, z1.h
+; CHECK-EXPAND-STREAMING-NEXT: fmov s2, w3
+; CHECK-EXPAND-STREAMING-NEXT: zip1 z1.s, z1.s, z2.s
+; CHECK-EXPAND-STREAMING-NEXT: ldr d2, [x8, :lo12:.LCPI2_0]
+; CHECK-EXPAND-STREAMING-NEXT: and z1.d, z1.d, z2.d
+; CHECK-EXPAND-STREAMING-NEXT: uunpklo z1.s, z1.h
+; CHECK-EXPAND-STREAMING-NEXT: lsl z1.s, z1.s, #31
+; CHECK-EXPAND-STREAMING-NEXT: asr z1.s, z1.s, #31
+; CHECK-EXPAND-STREAMING-NEXT: cmpne p0.s, p0/z, z1.s, #0
+; CHECK-EXPAND-STREAMING-NEXT: cntp x8, p0, p0.s
+; CHECK-EXPAND-STREAMING-NEXT: whilelo p1.s, xzr, x8
+; CHECK-EXPAND-STREAMING-NEXT: ld1w { z1.s }, p1/z, [x0]
+; CHECK-EXPAND-STREAMING-NEXT: expand z1.s, p0, z1.s
+; CHECK-EXPAND-STREAMING-NEXT: mov z0.s, p0/m, z1.s
+; CHECK-EXPAND-STREAMING-NEXT: ret
+;
+; CHECK-NO-EXPAND-STREAMING-LABEL: test_widen_fixed_expandload:
+; CHECK-NO-EXPAND-STREAMING: // %bb.0:
+; CHECK-NO-EXPAND-STREAMING-NEXT: sub sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NO-EXPAND-STREAMING-NEXT: and w8, w1, #0x1
+; CHECK-NO-EXPAND-STREAMING-NEXT: bfi w8, w2, #1, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: bfi w8, w3, #2, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #0, .LBB2_4
+; CHECK-NO-EXPAND-STREAMING-NEXT: // %bb.1: // %else
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #1, .LBB2_5
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB2_2: // %else2
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #2, .LBB2_6
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB2_3: // %else6
+; CHECK-NO-EXPAND-STREAMING-NEXT: add sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: ret
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB2_4: // %cond.load
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr w9, [x0], #4
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z1.s, z0.s[1]
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.s, z0.s[2]
+; CHECK-NO-EXPAND-STREAMING-NEXT: fmov s2, w9
+; CHECK-NO-EXPAND-STREAMING-NEXT: zip1 z1.s, z2.s, z1.s
+; CHECK-NO-EXPAND-STREAMING-NEXT: zip1 z0.d, z1.d, z0.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #1, .LBB2_2
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB2_5: // %cond.load1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr w9, [x0], #4
+; CHECK-NO-EXPAND-STREAMING-NEXT: fmov s1, w9
+; CHECK-NO-EXPAND-STREAMING-NEXT: zip1 z1.s, z0.s, z1.s
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.s, z0.s[2]
+; CHECK-NO-EXPAND-STREAMING-NEXT: zip1 z0.d, z1.d, z0.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #2, .LBB2_3
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB2_6: // %cond.load5
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z1.s, z0.s[1]
+; CHECK-NO-EXPAND-STREAMING-NEXT: zip1 z0.s, z0.s, z1.s
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr s1, [x0]
+; CHECK-NO-EXPAND-STREAMING-NEXT: zip1 z0.d, z0.d, z1.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: add sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: ret
+;
+; CHECK-NO-SVE-LABEL: test_widen_fixed_expandload:
+; CHECK-NO-SVE: // %bb.0:
+; CHECK-NO-SVE-NEXT: sub sp, sp, #16
+; CHECK-NO-SVE-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NO-SVE-NEXT: and w8, w1, #0x1
+; CHECK-NO-SVE-NEXT: bfi w8, w2, #1, #1
+; CHECK-NO-SVE-NEXT: bfi w8, w3, #2, #1
+; CHECK-NO-SVE-NEXT: tbnz w8, #0, .LBB2_4
+; CHECK-NO-SVE-NEXT: // %bb.1: // %else
+; CHECK-NO-SVE-NEXT: tbnz w8, #1, .LBB2_5
+; CHECK-NO-SVE-NEXT: .LBB2_2: // %else2
+; CHECK-NO-SVE-NEXT: tbnz w8, #2, .LBB2_6
+; CHECK-NO-SVE-NEXT: .LBB2_3: // %else6
+; CHECK-NO-SVE-NEXT: add sp, sp, #16
+; CHECK-NO-SVE-NEXT: ret
+; CHECK-NO-SVE-NEXT: .LBB2_4: // %cond.load
+; CHECK-NO-SVE-NEXT: ldr w9, [x0], #4
+; CHECK-NO-SVE-NEXT: fmov s1, w9
+; CHECK-NO-SVE-NEXT: mov v1.s[1], v0.s[1]
+; CHECK-NO-SVE-NEXT: mov v1.s[2], v0.s[2]
+; CHECK-NO-SVE-NEXT: mov v0.16b, v1.16b
+; CHECK-NO-SVE-NEXT: tbz w8, #1, .LBB2_2
+; CHECK-NO-SVE-NEXT: .LBB2_5: // %cond.load1
+; CHECK-NO-SVE-NEXT: mov v1.16b, v0.16b
+; CHECK-NO-SVE-NEXT: ld1 { v1.s }[1], [x0], #4
+; CHECK-NO-SVE-NEXT: mov v1.s[2], v0.s[2]
+; CHECK-NO-SVE-NEXT: mov v0.16b, v1.16b
+; CHECK-NO-SVE-NEXT: tbz w8, #2, .LBB2_3
+; CHECK-NO-SVE-NEXT: .LBB2_6: // %cond.load5
+; CHECK-NO-SVE-NEXT: ld1 { v0.s }[2], [x0]
+; CHECK-NO-SVE-NEXT: add sp, sp, #16
+; CHECK-NO-SVE-NEXT: ret
+;
+; CHECK-USE-NEON-LABEL: test_widen_fixed_expandload:
+; CHECK-USE-NEON: // %bb.0:
+; CHECK-USE-NEON-NEXT: sub sp, sp, #16
+; CHECK-USE-NEON-NEXT: .cfi_def_cfa_offset 16
+; CHECK-USE-NEON-NEXT: and w8, w1, #0x1
+; CHECK-USE-NEON-NEXT: bfi w8, w2, #1, #1
+; CHECK-USE-NEON-NEXT: bfi w8, w3, #2, #1
+; CHECK-USE-NEON-NEXT: tbnz w8, #0, .LBB2_4
+; CHECK-USE-NEON-NEXT: // %bb.1: // %else
+; CHECK-USE-NEON-NEXT: tbnz w8, #1, .LBB2_5
+; CHECK-USE-NEON-NEXT: .LBB2_2: // %else2
+; CHECK-USE-NEON-NEXT: tbnz w8, #2, .LBB2_6
+; CHECK-USE-NEON-NEXT: .LBB2_3: // %else6
+; CHECK-USE-NEON-NEXT: add sp, sp, #16
+; CHECK-USE-NEON-NEXT: ret
+; CHECK-USE-NEON-NEXT: .LBB2_4: // %cond.load
+; CHECK-USE-NEON-NEXT: ldr w9, [x0], #4
+; CHECK-USE-NEON-NEXT: fmov s1, w9
+; CHECK-USE-NEON-NEXT: mov v1.s[1], v0.s[1]
+; CHECK-USE-NEON-NEXT: mov v1.s[2], v0.s[2]
+; CHECK-USE-NEON-NEXT: mov v0.16b, v1.16b
+; CHECK-USE-NEON-NEXT: tbz w8, #1, .LBB2_2
+; CHECK-USE-NEON-NEXT: .LBB2_5: // %cond.load1
+; CHECK-USE-NEON-NEXT: mov v1.16b, v0.16b
+; CHECK-USE-NEON-NEXT: ld1 { v1.s }[1], [x0], #4
+; CHECK-USE-NEON-NEXT: mov v1.s[2], v0.s[2]
+; CHECK-USE-NEON-NEXT: mov v0.16b, v1.16b
+; CHECK-USE-NEON-NEXT: tbz w8, #2, .LBB2_3
+; CHECK-USE-NEON-NEXT: .LBB2_6: // %cond.load5
+; CHECK-USE-NEON-NEXT: ld1 { v0.s }[2], [x0]
+; CHECK-USE-NEON-NEXT: add sp, sp, #16
+; CHECK-USE-NEON-NEXT: ret
+ %res = call <3 x i32> @llvm.masked.expandload(ptr align 1 %base, <3 x i1> %pred, <3 x i32> %passthru)
+ ret <3 x i32> %res
+}
+
+define <4 x i8> @test_promote_fixed_expandload(ptr %base, <4 x i8> %passthru, <4 x i1> %pred) {
+; CHECK-EXPAND-LABEL: test_promote_fixed_expandload:
+; CHECK-EXPAND: // %bb.0:
+; CHECK-EXPAND-NEXT: shl v1.4h, v1.4h, #15
+; CHECK-EXPAND-NEXT: ptrue p0.h, vl4
+; CHECK-EXPAND-NEXT: cmpne p0.h, p0/z, z1.h, #0
+; CHECK-EXPAND-NEXT: cntp x8, p0, p0.h
+; CHECK-EXPAND-NEXT: whilelo p1.h, xzr, x8
+; CHECK-EXPAND-NEXT: ld1b { z1.h }, p1/z, [x0]
+; CHECK-EXPAND-NEXT: expand z1.h, p0, z1.h
+; CHECK-EXPAND-NEXT: mov z0.h, p0/m, z1.h
+; CHECK-EXPAND-NEXT: ret
+;
+; CHECK-EXPAND-STREAMING-LABEL: test_promote_fixed_expandload:
+; CHECK-EXPAND-STREAMING: // %bb.0:
+; CHECK-EXPAND-STREAMING-NEXT: lsl z1.h, z1.h, #15
+; CHECK-EXPAND-STREAMING-NEXT: ptrue p0.h, vl4
+; CHECK-EXPAND-STREAMING-NEXT: asr z1.h, z1.h, #15
+; CHECK-EXPAND-STREAMING-NEXT: cmpne p0.h, p0/z, z1.h, #0
+; CHECK-EXPAND-STREAMING-NEXT: cntp x8, p0, p0.h
+; CHECK-EXPAND-STREAMING-NEXT: whilelo p1.h, xzr, x8
+; CHECK-EXPAND-STREAMING-NEXT: ld1b { z1.h }, p1/z, [x0]
+; CHECK-EXPAND-STREAMING-NEXT: expand z1.h, p0, z1.h
+; CHECK-EXPAND-STREAMING-NEXT: mov z0.h, p0/m, z1.h
+; CHECK-EXPAND-STREAMING-NEXT: ret
+;
+; CHECK-NO-EXPAND-STREAMING-LABEL: test_promote_fixed_expandload:
+; CHECK-NO-EXPAND-STREAMING: // %bb.0:
+; CHECK-NO-EXPAND-STREAMING-NEXT: sub sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NO-EXPAND-STREAMING-NEXT: lsl z1.h, z1.h, #15
+; CHECK-NO-EXPAND-STREAMING-NEXT: adrp x8, .LCPI3_0
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.h, vl4
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldr d2, [x8, :lo12:.LCPI3_0]
+; CHECK-NO-EXPAND-STREAMING-NEXT: asr z1.h, z1.h, #15
+; CHECK-NO-EXPAND-STREAMING-NEXT: and z1.d, z1.d, z2.d
+; CHECK-NO-EXPAND-STREAMING-NEXT: uaddv d1, p0, z1.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: str b1, [sp, #12]
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldrb w8, [sp, #12]
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #0, .LBB3_5
+; CHECK-NO-EXPAND-STREAMING-NEXT: // %bb.1: // %else
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #1, .LBB3_6
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB3_2: // %else2
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #2, .LBB3_7
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB3_3: // %else6
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbnz w8, #3, .LBB3_8
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB3_4: // %else10
+; CHECK-NO-EXPAND-STREAMING-NEXT: add sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: ret
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB3_5: // %cond.load
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldrb w9, [x0], #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.h, vl1
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.h, p0/m, w9
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #1, .LBB3_2
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB3_6: // %cond.load1
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov w9, #1 // =0x1
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z1.h, #0, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z2.h, w9
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldrb w9, [x0], #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: cmpeq p0.h, p0/z, z1.h, z2.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.h, p0/m, w9
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #2, .LBB3_3
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB3_7: // %cond.load5
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov w9, #2 // =0x2
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z1.h, #0, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z2.h, w9
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldrb w9, [x0], #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: cmpeq p0.h, p0/z, z1.h, z2.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.h, p0/m, w9
+; CHECK-NO-EXPAND-STREAMING-NEXT: tbz w8, #3, .LBB3_4
+; CHECK-NO-EXPAND-STREAMING-NEXT: .LBB3_8: // %cond.load9
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov w8, #3 // =0x3
+; CHECK-NO-EXPAND-STREAMING-NEXT: index z1.h, #0, #1
+; CHECK-NO-EXPAND-STREAMING-NEXT: ptrue p0.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z2.h, w8
+; CHECK-NO-EXPAND-STREAMING-NEXT: ldrb w8, [x0]
+; CHECK-NO-EXPAND-STREAMING-NEXT: cmpeq p0.h, p0/z, z1.h, z2.h
+; CHECK-NO-EXPAND-STREAMING-NEXT: mov z0.h, p0/m, w8
+; CHECK-NO-EXPAND-STREAMING-NEXT: add sp, sp, #16
+; CHECK-NO-EXPAND-STREAMING-NEXT: ret
+;
+; CHECK-NO-SVE-LABEL: test_promote_fixed_expandload:
+; CHECK-NO-SVE: // %bb.0:
+; CHECK-NO-SVE-NEXT: shl v1.4h, v1.4h, #15
+; CHECK-NO-SVE-NEXT: adrp x8, .LCPI3_0
+; CHECK-NO-SVE-NEXT: ldr d2, [x8, :lo12:.LCPI3_0]
+; CHECK-NO-SVE-NEXT: cmlt v1.4h, v1.4h, #0
+; CHECK-NO-SVE-NEXT: and v1.8b, v1.8b, v2.8b
+; CHECK-NO-SVE-NEXT: addv h1, v1.4h
+; CHECK-NO-SVE-NEXT: fmov w8, s1
+; CHECK-NO-SVE-NEXT: tbnz w8, #0, .LBB3_5
+; CHECK-NO-SVE-NEXT: // %bb.1: // %else
+; CHECK-NO-SVE-NEXT: tbnz w8, #1, .LBB3_6
+; CHECK-NO-SVE-NEXT: .LBB3_2: // %else2
+; CHECK-NO-SVE-NEXT: tbnz w8, #2, .LBB3_7
+; CHECK-NO-SVE-NEXT: .LBB3_3: // %else6
+; CHECK-NO-SVE-NEXT: tbnz w8, #3, .LBB3_8
+; CHECK-NO-SVE-NEXT: .LBB3_4: // %else10
+; CHECK-NO-SVE-NEXT: ret
+; CHECK-NO-SVE-NEXT: .LBB3_5: // %cond.load
+; CHECK-NO-SVE-NEXT: ldrb w9, [x0], #1
+; CHECK-NO-SVE-NEXT: mov v0.h[0], w9
+; CHECK-NO-SVE-NEXT: tbz w8, #1, .LBB3_2
+; CHECK-NO-SVE-NEXT: .LBB3_6: // %cond.load1
+; CHECK-NO-SVE-NEXT: ldrb w9, [x0], #1
+; CHECK-NO-SVE-NEXT: mov v0.h[1], w9
+; CHECK-NO-SVE-NEXT: tbz w8, #2, .LBB3_3
+; CHECK-NO-SVE-NEXT: .LBB3_7: // %cond.load5
+; CHECK-NO-SVE-NEXT: ldrb w9, [x0], #1
+; CHECK-NO-SVE-NEXT: mov v0.h[2], w9
+; CHECK-NO-SVE-NEXT: tbz w8, #3, .LBB3_4
+; CHECK-NO-SVE-NEXT: .LBB3_8: // %cond.load9
+; CHECK-NO-SVE-NEXT: ld1 { v0.b }[6], [x0]
+; CHECK-NO-SVE-NEXT: ret
+;
+; CHECK-USE-NEON-LABEL: test_promote_fixed_expandload:
+; CHECK-USE-NEON: // %bb.0:
+; CHECK-USE-NEON-NEXT: shl v1.4h, v1.4h, #15
+; CHECK-USE-NEON-NEXT: adrp x8, .LCPI3_0
+; CHECK-USE-NEON-NEXT: ldr d2, [x8, :lo12:.LCPI3_0]
+; CHECK-USE-NEON-NEXT: cmlt v1.4h, v1.4h, #0
+; CHECK-USE-NEON-NEXT: and v1.8b, v1.8b, v2.8b
+; CHECK-USE-NEON-NEXT: addv h1, v1.4h
+; CHECK-USE-NEON-NEXT: fmov w8, s1
+; CHECK-USE-NEON-NEXT: tbnz w8, #0, .LBB3_5
+; CHECK-USE-NEON-NEXT: // %bb.1: // %else
+; CHECK-USE-NEON-NEXT: tbnz w8, #1, .LBB3_6
+; CHECK-USE-NEON-NEXT: .LBB3_2: // %else2
+; CHECK-USE-NEON-NEXT: tbnz w8, #2, .LBB3_7
+; CHECK-USE-NEON-NEXT: .LBB3_3: // %else6
+; CHECK-USE-NEON-NEXT: tbnz w8, #3, .LBB3_8
+; CHECK-USE-NEON-NEXT: .LBB3_4: // %else10
+; CHECK-USE-NEON-NEXT: ret
+; CHECK-USE-NEON-NEXT: .LBB3_5: // %cond.load
+; CHECK-USE-NEON-NEXT: ldrb w9, [x0], #1
+; CHECK-USE-NEON-NEXT: mov v0.h[0], w9
+; CHECK-USE-NEON-NEXT: tbz w8, #1, .LBB3_2
+; CHECK-USE-NEON-NEXT: .LBB3_6: // %cond.load1
+; CHECK-USE-NEON-NEXT: ldrb w9, [x0], #1
+; CHECK-USE-NEON-NEXT: mov v0.h[1], w9
+; CHECK-USE-NEON-NEXT: tbz w8, #2, .LBB3_3
+; CHECK-USE-NEON-NEXT: .LBB3_7: // %cond.load5
+; CHECK-USE-NEON-NEXT: ldrb w9, [x0], #1
+; CHECK-USE-NEON-NEXT: mov v0.h[2], w9
+; CHECK-USE-NEON-NEXT: tbz w8, #3, .LBB3_4
+; CHECK-USE-NEON-NEXT: .LBB3_8: // %cond.load9
+; CHECK-USE-NEON-NEXT: ld1 { v0.b }[6], [x0]
+; CHECK-USE-NEON-NEXT: ret
+ %res = call <4 x i8> @llvm.masked.expandload(ptr align 1 %base, <4 x i1> %pred, <4 x i8> %passthru)
+ ret <4 x i8> %res
+}
diff --git a/llvm/test/CodeGen/AArch64/scalable-expanding-load.ll b/llvm/test/CodeGen/AArch64/scalable-expanding-load.ll
new file mode 100644
index 0000000000000..7c7075c05c33e
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/scalable-expanding-load.ll
@@ -0,0 +1,66 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve2p2 < %s | FileCheck %s
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -mattr=+sme2p2 < %s | FileCheck %s
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -mattr=+sme2p2 -force-streaming < %s | FileCheck %s
+; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve2p2 -mattr=+sme-fa64 -force-streaming < %s | FileCheck %s
+
+define <vscale x 2 x i64> @test_expandload(ptr %base, <vscale x 2 x i64> %passthru, <vscale x 2 x i1> %pred) {
+; CHECK-LABEL: test_expandload:
+; CHECK: // %bb.0:
+; CHECK-NEXT: cntp x8, p0, p0.d
+; CHECK-NEXT: whilelo p1.d, xzr, x8
+; CHECK-NEXT: ld1d { z1.d }, p1/z, [x0]
+; CHECK-NEXT: expand z1.d, p0, z1.d
+; CHECK-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-NEXT: ret
+ %res = call <vscale x 2 x i64> @llvm.masked.expandload(ptr align 1 %base, <vscale x 2 x i1> %pred, <vscale x 2 x i64> %passthru)
+ ret <vscale x 2 x i64> %res
+}
+
+define <vscale x 8 x float> @test_split_expandload(ptr %base, <vscale x 8 x float> %passthru, <vscale x 8 x i1> %pred) {
+; CHECK-LABEL: test_split_expandload:
+; CHECK: // %bb.0:
+; CHECK-NEXT: punpklo p1.h, p0.b
+; CHECK-NEXT: punpkhi p0.h, p0.b
+; CHECK-NEXT: cntp x8, p1, p1.s
+; CHECK-NEXT: cntp x9, p0, p0.s
+; CHECK-NEXT: whilelo p2.s, xzr, x8
+; CHECK-NEXT: whilelo p3.s, xzr, x9
+; CHECK-NEXT: ld1w { z2.s }, p2/z, [x0]
+; CHECK-NEXT: ld1w { z3.s }, p3/z, [x0, x8, lsl #2]
+; CHECK-NEXT: expand z2.s, p1, z2.s
+; CHECK-NEXT: expand z3.s, p0, z3.s
+; CHECK-NEXT: mov z0.s, p1/m, z2.s
+; CHECK-NEXT: mov z1.s, p0/m, z3.s
+; CHECK-NEXT: ret
+ %res = call <vscale x 8 x float> @llvm.masked.expandload(ptr align 1 %base, <vscale x 8 x i1> %pred, <vscale x 8 x float> %passthru)
+ ret <vscale x 8 x float> %res
+}
+
+define <vscale x 1 x i64> @test_promote_expandload(ptr %base, <vscale x 1 x i64> %passthru, <vscale x 1 x i1> %pred) {
+; CHECK-LABEL: test_promote_expandload:
+; CHECK: // %bb.0:
+; CHECK-NEXT: pfalse p1.b
+; CHECK-NEXT: uzp1 p0.d, p0.d, p1.d
+; CHECK-NEXT: cntp x8, p0, p0.d
+; CHECK-NEXT: whilelo p1.d, xzr, x8
+; CHECK-NEXT: ld1d { z1.d }, p1/z, [x0]
+; CHECK-NEXT: expand z1.d, p0, z1.d
+; CHECK-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-NEXT: ret
+ %res = call <vscale x 1 x i64> @llvm.masked.expandload(ptr align 1 %base, <vscale x 1 x i1> %pred, <vscale x 1 x i64> %passthru)
+ ret <vscale x 1 x i64> %res
+}
+
+define <vscale x 4 x i8> @test_widen_expandload(ptr %base, <vscale x 4 x i1> %pred, <vscale x 4 x i8> %passthru) {
+; CHECK-LABEL: test_widen_expandload:
+; CHECK: // %bb.0:
+; CHECK-NEXT: cntp x8, p0, p0.s
+; CHECK-NEXT: whilelo p1.s, xzr, x8
+; CHECK-NEXT: ld1b { z1.s }, p1/z, [x0]
+; CHECK-NEXT: expand z1.s, p0, z1.s
+; CHECK-NEXT: mov z0.s, p0/m, z1.s
+; CHECK-NEXT: ret
+ %res = call <vscale x 4 x i8> @llvm.masked.expandload(ptr align 1 %base, <vscale x 4 x i1> %pred, <vscale x 4 x i8> %passthru)
+ ret <vscale x 4 x i8> %res
+}
More information about the llvm-commits
mailing list