@@ -44446,23 +44446,26 @@ static int getOneTrueElt(SDValue V) {
44446
44446
/// scalar element, and the alignment for the scalar memory access.
44447
44447
static bool getParamsForOneTrueMaskedElt(MaskedLoadStoreSDNode *MaskedOp,
44448
44448
SelectionDAG &DAG, SDValue &Addr,
44449
- SDValue &Index, unsigned &Alignment) {
44449
+ SDValue &Index, Align &Alignment,
44450
+ unsigned &Offset) {
44450
44451
int TrueMaskElt = getOneTrueElt(MaskedOp->getMask());
44451
44452
if (TrueMaskElt < 0)
44452
44453
return false;
44453
44454
44454
44455
// Get the address of the one scalar element that is specified by the mask
44455
44456
// using the appropriate offset from the base pointer.
44456
44457
EVT EltVT = MaskedOp->getMemoryVT().getVectorElementType();
44458
+ Offset = 0;
44457
44459
Addr = MaskedOp->getBasePtr();
44458
44460
if (TrueMaskElt != 0) {
44459
- unsigned Offset = TrueMaskElt * EltVT.getStoreSize();
44461
+ Offset = TrueMaskElt * EltVT.getStoreSize();
44460
44462
Addr = DAG.getMemBasePlusOffset(Addr, TypeSize::Fixed(Offset),
44461
44463
SDLoc(MaskedOp));
44462
44464
}
44463
44465
44464
44466
Index = DAG.getIntPtrConstant(TrueMaskElt, SDLoc(MaskedOp));
44465
- Alignment = MinAlign(MaskedOp->getAlignment(), EltVT.getStoreSize());
44467
+ Alignment = commonAlignment(MaskedOp->getOriginalAlign(),
44468
+ EltVT.getStoreSize());
44466
44469
return true;
44467
44470
}
44468
44471
@@ -44479,8 +44482,9 @@ reduceMaskedLoadToScalarLoad(MaskedLoadSDNode *ML, SelectionDAG &DAG,
44479
44482
// is profitable. Endianness would also have to be considered.
44480
44483
44481
44484
SDValue Addr, VecIndex;
44482
- unsigned Alignment;
44483
- if (!getParamsForOneTrueMaskedElt(ML, DAG, Addr, VecIndex, Alignment))
44485
+ Align Alignment;
44486
+ unsigned Offset;
44487
+ if (!getParamsForOneTrueMaskedElt(ML, DAG, Addr, VecIndex, Alignment, Offset))
44484
44488
return SDValue();
44485
44489
44486
44490
// Load the one scalar element that is specified by the mask using the
@@ -44489,7 +44493,8 @@ reduceMaskedLoadToScalarLoad(MaskedLoadSDNode *ML, SelectionDAG &DAG,
44489
44493
EVT VT = ML->getValueType(0);
44490
44494
EVT EltVT = VT.getVectorElementType();
44491
44495
SDValue Load =
44492
- DAG.getLoad(EltVT, DL, ML->getChain(), Addr, ML->getPointerInfo(),
44496
+ DAG.getLoad(EltVT, DL, ML->getChain(), Addr,
44497
+ ML->getPointerInfo().getWithOffset(Offset),
44493
44498
Alignment, ML->getMemOperand()->getFlags());
44494
44499
44495
44500
// Insert the loaded element into the appropriate place in the vector.
@@ -44600,8 +44605,9 @@ static SDValue reduceMaskedStoreToScalarStore(MaskedStoreSDNode *MS,
44600
44605
// is profitable. Endianness would also have to be considered.
44601
44606
44602
44607
SDValue Addr, VecIndex;
44603
- unsigned Alignment;
44604
- if (!getParamsForOneTrueMaskedElt(MS, DAG, Addr, VecIndex, Alignment))
44608
+ Align Alignment;
44609
+ unsigned Offset;
44610
+ if (!getParamsForOneTrueMaskedElt(MS, DAG, Addr, VecIndex, Alignment, Offset))
44605
44611
return SDValue();
44606
44612
44607
44613
// Extract the one scalar element that is actually being stored.
@@ -44612,7 +44618,8 @@ static SDValue reduceMaskedStoreToScalarStore(MaskedStoreSDNode *MS,
44612
44618
MS->getValue(), VecIndex);
44613
44619
44614
44620
// Store that element at the appropriate offset from the base pointer.
44615
- return DAG.getStore(MS->getChain(), DL, Extract, Addr, MS->getPointerInfo(),
44621
+ return DAG.getStore(MS->getChain(), DL, Extract, Addr,
44622
+ MS->getPointerInfo().getWithOffset(Offset),
44616
44623
Alignment, MS->getMemOperand()->getFlags());
44617
44624
}
44618
44625
0 commit comments