@@ -6256,17 +6256,17 @@ SDValue DAGTypeLegalizer::WidenVecRes_LOAD(SDNode *N) {
6256
6256
// FIXME: Not all targets may support EVL in VP_LOAD. These will have been
6257
6257
// removed from the IR by the ExpandVectorPredication pass but we're
6258
6258
// reintroducing them here.
6259
- EVT LdVT = LD->getMemoryVT ( );
6260
- EVT WideVT = TLI.getTypeToTransformTo (*DAG.getContext (), LdVT );
6261
- EVT WideMaskVT = EVT::getVectorVT (*DAG. getContext (), MVT::i1,
6262
- WideVT. getVectorElementCount ());
6259
+ EVT VT = LD->getValueType ( 0 );
6260
+ EVT WideVT = TLI.getTypeToTransformTo (*DAG.getContext (), VT );
6261
+ EVT WideMaskVT = getSetCCResultType (WideVT);
6262
+
6263
6263
if (ExtType == ISD::NON_EXTLOAD &&
6264
6264
TLI.isOperationLegalOrCustom (ISD::VP_LOAD, WideVT) &&
6265
6265
TLI.isTypeLegal (WideMaskVT)) {
6266
6266
SDLoc DL (N);
6267
6267
SDValue Mask = DAG.getAllOnesConstant (DL, WideMaskVT);
6268
6268
SDValue EVL = DAG.getElementCount (DL, TLI.getVPExplicitVectorLengthTy (),
6269
- LdVT .getVectorElementCount ());
6269
+ VT .getVectorElementCount ());
6270
6270
SDValue NewLoad =
6271
6271
DAG.getLoadVP (LD->getAddressingMode (), ISD::NON_EXTLOAD, WideVT, DL,
6272
6272
LD->getChain (), LD->getBasePtr (), LD->getOffset (), Mask,
@@ -6303,6 +6303,24 @@ SDValue DAGTypeLegalizer::WidenVecRes_LOAD(SDNode *N) {
6303
6303
return Result;
6304
6304
}
6305
6305
6306
+ if (VT.isVector ()) {
6307
+ // If all else fails replace the load with a wide masked load.
6308
+ SDLoc DL (N);
6309
+ EVT IdxVT = TLI.getVectorIdxTy (DAG.getDataLayout ());
6310
+
6311
+ SDValue Len = DAG.getElementCount (DL, IdxVT, VT.getVectorElementCount ());
6312
+ SDValue Mask = DAG.getNode (ISD::GET_ACTIVE_LANE_MASK, DL, WideMaskVT,
6313
+ DAG.getConstant (0 , DL, IdxVT), Len);
6314
+
6315
+ SDValue NewLoad = DAG.getMaskedLoad (
6316
+ WideVT, DL, LD->getChain (), LD->getBasePtr (), LD->getOffset (), Mask,
6317
+ DAG.getPOISON (WideVT), LD->getMemoryVT (), LD->getMemOperand (),
6318
+ LD->getAddressingMode (), LD->getExtensionType ());
6319
+
6320
+ ReplaceValueWith (SDValue (N, 1 ), NewLoad.getValue (1 ));
6321
+ return NewLoad;
6322
+ }
6323
+
6306
6324
report_fatal_error (" Unable to widen vector load" );
6307
6325
}
6308
6326
@@ -7516,8 +7534,7 @@ SDValue DAGTypeLegalizer::WidenVecOp_STORE(SDNode *N) {
7516
7534
SDValue StVal = ST->getValue ();
7517
7535
EVT StVT = StVal.getValueType ();
7518
7536
EVT WideVT = TLI.getTypeToTransformTo (*DAG.getContext (), StVT);
7519
- EVT WideMaskVT = EVT::getVectorVT (*DAG.getContext (), MVT::i1,
7520
- WideVT.getVectorElementCount ());
7537
+ EVT WideMaskVT = getSetCCResultType (WideVT);
7521
7538
7522
7539
if (TLI.isOperationLegalOrCustom (ISD::VP_STORE, WideVT) &&
7523
7540
TLI.isTypeLegal (WideMaskVT)) {
@@ -7540,6 +7557,22 @@ SDValue DAGTypeLegalizer::WidenVecOp_STORE(SDNode *N) {
7540
7557
return DAG.getNode (ISD::TokenFactor, SDLoc (ST), MVT::Other, StChain);
7541
7558
}
7542
7559
7560
+ if (StVT.isVector ()) {
7561
+ // If all else fails replace the store with a wide masked store.
7562
+ SDLoc DL (N);
7563
+ EVT IdxVT = TLI.getVectorIdxTy (DAG.getDataLayout ());
7564
+
7565
+ SDValue WideStVal = GetWidenedVector (StVal);
7566
+ SDValue Len = DAG.getElementCount (DL, IdxVT, StVT.getVectorElementCount ());
7567
+ SDValue Mask = DAG.getNode (ISD::GET_ACTIVE_LANE_MASK, DL, WideMaskVT,
7568
+ DAG.getConstant (0 , DL, IdxVT), Len);
7569
+
7570
+ return DAG.getMaskedStore (ST->getChain (), DL, WideStVal, ST->getBasePtr (),
7571
+ ST->getOffset (), Mask, ST->getMemoryVT (),
7572
+ ST->getMemOperand (), ST->getAddressingMode (),
7573
+ ST->isTruncatingStore ());
7574
+ }
7575
+
7543
7576
report_fatal_error (" Unable to widen vector store" );
7544
7577
}
7545
7578
@@ -8298,8 +8331,7 @@ DAGTypeLegalizer::GenWidenVectorExtLoads(SmallVectorImpl<SDValue> &LdChain,
8298
8331
AAMDNodes AAInfo = LD->getAAInfo ();
8299
8332
8300
8333
if (LdVT.isScalableVector ())
8301
- report_fatal_error (" Generating widen scalable extending vector loads is "
8302
- " not yet supported" );
8334
+ return SDValue ();
8303
8335
8304
8336
EVT EltVT = WidenVT.getVectorElementType ();
8305
8337
EVT LdEltVT = LdVT.getVectorElementType ();
0 commit comments