Skip to content

Commit 37add91

Browse files
toppercGeorgeARM
authored andcommitted
[SelectionDAG][PowerPC] Remove setTruncatingStore from StoreSDNode. (llvm#137667)
Mutating a node after it has been created isn't a good idea. After e17f07c, we have a version of setStore that can create a truncating indexed store. Use that instead of MorphNodeTo+setTruncatingStore in PowerPC. Unfortunately, if we return the newly created node, DAGCombiner will visit the node and change the constant. To prevent this, we use DCI.CombineTo and avoid adding the new node to the worklist.
1 parent 7d3e2eb commit 37add91

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

llvm/include/llvm/CodeGen/SelectionDAGNodes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,9 +2533,6 @@ class StoreSDNode : public LSBaseSDNode {
25332533
/// For integers this is the same as doing a TRUNCATE and storing the result.
25342534
/// For floats, it is the same as doing an FP_ROUND and storing the result.
25352535
bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; }
2536-
void setTruncatingStore(bool Truncating) {
2537-
StoreSDNodeBits.IsTruncating = Truncating;
2538-
}
25392536

25402537
const SDValue &getValue() const { return getOperand(1); }
25412538
const SDValue &getBasePtr() const { return getOperand(2); }

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16562,13 +16562,16 @@ SDValue PPCTargetLowering::PerformDAGCombine(SDNode *N,
1656216562
MemVT.getSizeInBits());
1656316563
SDValue Const64 = DAG.getConstant(Val64, dl, MVT::i64);
1656416564

16565-
// DAG.getTruncStore() can't be used here because it doesn't accept
16566-
// the general (base + offset) addressing mode.
16567-
// So we use UpdateNodeOperands and setTruncatingStore instead.
16568-
DAG.UpdateNodeOperands(N, N->getOperand(0), Const64, N->getOperand(2),
16569-
N->getOperand(3));
16570-
cast<StoreSDNode>(N)->setTruncatingStore(true);
16571-
return SDValue(N, 0);
16565+
auto *ST = cast<StoreSDNode>(N);
16566+
SDValue NewST = DAG.getStore(ST->getChain(), dl, Const64,
16567+
ST->getBasePtr(), ST->getOffset(), MemVT,
16568+
ST->getMemOperand(), ST->getAddressingMode(),
16569+
/*IsTruncating=*/true);
16570+
// Note we use CombineTo here to prevent DAGCombiner from visiting the
16571+
// new store which will change the constant by removing non-demanded bits.
16572+
return ST->isUnindexed()
16573+
? DCI.CombineTo(N, NewST, /*AddTo=*/false)
16574+
: DCI.CombineTo(N, NewST, NewST.getValue(1), /*AddTo=*/false);
1657216575
}
1657316576

1657416577
// For little endian, VSX stores require generating xxswapd/lxvd2x.

0 commit comments

Comments
 (0)