[llvm] [AIX][TLS] Optimize the -maix-small-local-exec-tls local-exec access sequence for non-zero offsets (PR #71485)
Amy Kwan via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 22 12:18:08 PST 2023
================
@@ -7567,8 +7567,63 @@ static void reduceVSXSwap(SDNode *N, SelectionDAG *DAG) {
DAG->ReplaceAllUsesOfValueWith(SDValue(N, 0), N->getOperand(0));
}
+// For non-TOC-based local-exec access where an addi is feeding into another
+// addi, fold this sequence into a single addi if possible.
+static void foldADDIForLocalExecAccesses(SDNode *N, SelectionDAG *DAG) {
+ const PPCSubtarget &Subtarget =
+ DAG->getMachineFunction().getSubtarget<PPCSubtarget>();
+ // This optimization is only performed for non-TOC-based local-exec accesses.
+ if (!Subtarget.hasAIXSmallLocalExecTLS())
+ return;
+
+ if (N->getMachineOpcode() != PPC::ADDI8)
+ return;
+
+ // InitialADDI is the addi feeding into N (also an addi), and the addi that
+ // we want optimized out.
+ SDValue InitialADDI = N->getOperand(0);
+ if (!InitialADDI.isMachineOpcode() ||
----------------
amy-kwan wrote:
Might be better to separate the checks into a separate function so we can check it in the load/store case, too.
https://github.com/llvm/llvm-project/pull/71485
More information about the llvm-commits
mailing list