@@ -9439,26 +9439,51 @@ SDValue SelectionDAG::getStore(SDValue Chain, const SDLoc &dl, SDValue Val,
9439
9439
9440
9440
SDValue SelectionDAG::getStore(SDValue Chain, const SDLoc &dl, SDValue Val,
9441
9441
SDValue Ptr, MachineMemOperand *MMO) {
9442
- assert(Chain.getValueType() == MVT::Other &&
9443
- "Invalid chain type");
9444
- EVT VT = Val.getValueType();
9445
- SDVTList VTs = getVTList(MVT::Other);
9446
9442
SDValue Undef = getUNDEF(Ptr.getValueType());
9447
- SDValue Ops[] = { Chain, Val, Ptr, Undef };
9443
+ return getStore(Chain, dl, Val, Ptr, Undef, Val.getValueType(), MMO,
9444
+ ISD::UNINDEXED);
9445
+ }
9446
+
9447
+ SDValue SelectionDAG::getStore(SDValue Chain, const SDLoc &dl, SDValue Val,
9448
+ SDValue Ptr, SDValue Offset, EVT SVT,
9449
+ MachineMemOperand *MMO, ISD::MemIndexedMode AM,
9450
+ bool IsTruncating) {
9451
+ assert(Chain.getValueType() == MVT::Other && "Invalid chain type");
9452
+ EVT VT = Val.getValueType();
9453
+ if (VT == SVT) {
9454
+ IsTruncating = false;
9455
+ } else if (!IsTruncating) {
9456
+ assert(VT == SVT && "No-truncating store from different memory type!");
9457
+ } else {
9458
+ assert(SVT.getScalarType().bitsLT(VT.getScalarType()) &&
9459
+ "Should only be a truncating store, not extending!");
9460
+ assert(VT.isInteger() == SVT.isInteger() && "Can't do FP-INT conversion!");
9461
+ assert(VT.isVector() == SVT.isVector() &&
9462
+ "Cannot use trunc store to convert to or from a vector!");
9463
+ assert((!VT.isVector() ||
9464
+ VT.getVectorElementCount() == SVT.getVectorElementCount()) &&
9465
+ "Cannot use trunc store to change the number of vector elements!");
9466
+ }
9467
+
9468
+ bool Indexed = AM != ISD::UNINDEXED;
9469
+ assert((Indexed || Offset.isUndef()) && "Unindexed store with an offset!");
9470
+ SDVTList VTs = Indexed ? getVTList(Ptr.getValueType(), MVT::Other)
9471
+ : getVTList(MVT::Other);
9472
+ SDValue Ops[] = {Chain, Val, Ptr, Offset};
9448
9473
FoldingSetNodeID ID;
9449
9474
AddNodeIDNode(ID, ISD::STORE, VTs, Ops);
9450
- ID.AddInteger(VT .getRawBits());
9475
+ ID.AddInteger(SVT .getRawBits());
9451
9476
ID.AddInteger(getSyntheticNodeSubclassData<StoreSDNode>(
9452
- dl.getIROrder(), VTs, ISD::UNINDEXED, false, VT , MMO));
9477
+ dl.getIROrder(), VTs, AM, IsTruncating, SVT , MMO));
9453
9478
ID.AddInteger(MMO->getPointerInfo().getAddrSpace());
9454
9479
ID.AddInteger(MMO->getFlags());
9455
9480
void *IP = nullptr;
9456
9481
if (SDNode *E = FindNodeOrInsertPos(ID, dl, IP)) {
9457
9482
cast<StoreSDNode>(E)->refineAlignment(MMO);
9458
9483
return SDValue(E, 0);
9459
9484
}
9460
- auto *N = newSDNode<StoreSDNode>(dl.getIROrder(), dl.getDebugLoc(), VTs,
9461
- ISD::UNINDEXED, false, VT , MMO);
9485
+ auto *N = newSDNode<StoreSDNode>(dl.getIROrder(), dl.getDebugLoc(), VTs, AM,
9486
+ IsTruncating, SVT , MMO);
9462
9487
createOperands(N, Ops);
9463
9488
9464
9489
CSEMap.InsertNode(N, IP);
@@ -9491,76 +9516,18 @@ SDValue SelectionDAG::getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
9491
9516
SDValue SelectionDAG::getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
9492
9517
SDValue Ptr, EVT SVT,
9493
9518
MachineMemOperand *MMO) {
9494
- EVT VT = Val.getValueType();
9495
-
9496
- assert(Chain.getValueType() == MVT::Other &&
9497
- "Invalid chain type");
9498
- if (VT == SVT)
9499
- return getStore(Chain, dl, Val, Ptr, MMO);
9500
-
9501
- assert(SVT.getScalarType().bitsLT(VT.getScalarType()) &&
9502
- "Should only be a truncating store, not extending!");
9503
- assert(VT.isInteger() == SVT.isInteger() &&
9504
- "Can't do FP-INT conversion!");
9505
- assert(VT.isVector() == SVT.isVector() &&
9506
- "Cannot use trunc store to convert to or from a vector!");
9507
- assert((!VT.isVector() ||
9508
- VT.getVectorElementCount() == SVT.getVectorElementCount()) &&
9509
- "Cannot use trunc store to change the number of vector elements!");
9510
-
9511
- SDVTList VTs = getVTList(MVT::Other);
9512
9519
SDValue Undef = getUNDEF(Ptr.getValueType());
9513
- SDValue Ops[] = { Chain, Val, Ptr, Undef };
9514
- FoldingSetNodeID ID;
9515
- AddNodeIDNode(ID, ISD::STORE, VTs, Ops);
9516
- ID.AddInteger(SVT.getRawBits());
9517
- ID.AddInteger(getSyntheticNodeSubclassData<StoreSDNode>(
9518
- dl.getIROrder(), VTs, ISD::UNINDEXED, true, SVT, MMO));
9519
- ID.AddInteger(MMO->getPointerInfo().getAddrSpace());
9520
- ID.AddInteger(MMO->getFlags());
9521
- void *IP = nullptr;
9522
- if (SDNode *E = FindNodeOrInsertPos(ID, dl, IP)) {
9523
- cast<StoreSDNode>(E)->refineAlignment(MMO);
9524
- return SDValue(E, 0);
9525
- }
9526
- auto *N = newSDNode<StoreSDNode>(dl.getIROrder(), dl.getDebugLoc(), VTs,
9527
- ISD::UNINDEXED, true, SVT, MMO);
9528
- createOperands(N, Ops);
9529
-
9530
- CSEMap.InsertNode(N, IP);
9531
- InsertNode(N);
9532
- SDValue V(N, 0);
9533
- NewSDValueDbgMsg(V, "Creating new node: ", this);
9534
- return V;
9520
+ return getStore(Chain, dl, Val, Ptr, Undef, SVT, MMO, ISD::UNINDEXED, true);
9535
9521
}
9536
9522
9537
9523
SDValue SelectionDAG::getIndexedStore(SDValue OrigStore, const SDLoc &dl,
9538
9524
SDValue Base, SDValue Offset,
9539
9525
ISD::MemIndexedMode AM) {
9540
9526
StoreSDNode *ST = cast<StoreSDNode>(OrigStore);
9541
9527
assert(ST->getOffset().isUndef() && "Store is already a indexed store!");
9542
- SDVTList VTs = getVTList(Base.getValueType(), MVT::Other);
9543
- SDValue Ops[] = { ST->getChain(), ST->getValue(), Base, Offset };
9544
- FoldingSetNodeID ID;
9545
- AddNodeIDNode(ID, ISD::STORE, VTs, Ops);
9546
- ID.AddInteger(ST->getMemoryVT().getRawBits());
9547
- ID.AddInteger(ST->getRawSubclassData());
9548
- ID.AddInteger(ST->getPointerInfo().getAddrSpace());
9549
- ID.AddInteger(ST->getMemOperand()->getFlags());
9550
- void *IP = nullptr;
9551
- if (SDNode *E = FindNodeOrInsertPos(ID, dl, IP))
9552
- return SDValue(E, 0);
9553
-
9554
- auto *N = newSDNode<StoreSDNode>(dl.getIROrder(), dl.getDebugLoc(), VTs, AM,
9555
- ST->isTruncatingStore(), ST->getMemoryVT(),
9556
- ST->getMemOperand());
9557
- createOperands(N, Ops);
9558
-
9559
- CSEMap.InsertNode(N, IP);
9560
- InsertNode(N);
9561
- SDValue V(N, 0);
9562
- NewSDValueDbgMsg(V, "Creating new node: ", this);
9563
- return V;
9528
+ return getStore(ST->getChain(), dl, ST->getValue(), Base, Offset,
9529
+ ST->getMemoryVT(), ST->getMemOperand(), AM,
9530
+ ST->isTruncatingStore());
9564
9531
}
9565
9532
9566
9533
SDValue SelectionDAG::getLoadVP(
0 commit comments