[llvm] [PowerPC] Peephole address calculation in TOC memops (PR #76488)
Sean Fertile via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 12:48:47 PST 2024
================
@@ -7662,241 +7662,212 @@ static void foldADDIForLocalExecAccesses(SDNode *N, SelectionDAG *DAG) {
DAG->RemoveDeadNode(InitialADDI.getNode());
}
-void PPCDAGToDAGISel::PeepholePPC64() {
- SelectionDAG::allnodes_iterator Position = CurDAG->allnodes_end();
- bool HasAIXSmallLocalExecTLS = Subtarget->hasAIXSmallLocalExecTLS();
-
- while (Position != CurDAG->allnodes_begin()) {
- SDNode *N = &*--Position;
- // Skip dead nodes and any non-machine opcodes.
- if (N->use_empty() || !N->isMachineOpcode())
- continue;
-
- if (isVSXSwap(SDValue(N, 0)))
- reduceVSXSwap(N, CurDAG);
-
- // This optimization is performed for non-TOC-based local-exec accesses.
- if (HasAIXSmallLocalExecTLS)
- foldADDIForLocalExecAccesses(N, CurDAG);
+static bool isValidOffsetMemOp(SDNode *N, bool &IsLoad,
----------------
mandlebug wrote:
We seems to be doing multiple things with this helper function:
1) Determine if the current machine node is a valid memory operation that we could forward a tac-operand to.
2) Determine if said memory operation is a load or a store
3) Determine if the memory operation has a stricter requirement on the offset that can be encoded - FWIW I belive changing the name from `RequiresMod4Offset` to `ExtraAlign` now obfuscates the fact it an encoding limitation and really an alignment limitation.
4) Determine if the toc operation that feeds the memory operation is a valid one to forward from.
While it will make the code bigger and likely duplicate the switch statement, I think if we split this into separate appropriately named helpers it will make this code easier to understand.
We could use
- `isValidMemoryOperation(N->getOpcode())` that returns true or false,
- `encodingModulous(N->getOpcode())` that returns either 4 or 1 as an unsigned value.
- can we reliably use `MachineInstr::mayLoad()` to determine if the node is a load or a store?
- `isValidForwardingTocoperation(Base->getOpcode())` to determine if the feeding operation is one that can be forwarded from.
https://github.com/llvm/llvm-project/pull/76488
More information about the llvm-commits
mailing list