[llvm] [AIX][TLS] Optimize the small local-exec access sequence for non-zero offsets (PR #71485)
Amy Kwan via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 22 13:10:06 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)
----------------
amy-kwan wrote:
I think `PPC::LA8` can only be produced at assembly printing time and not during instruction selection. Thus, I think checking for `ADDI8` here is sufficient. This is because I see places in assembly printing where we set the opcode of the `ADDI8` to be `LA8` specifically.
Furthermore, there is a pattern (`(set i64:$RST, (add i64:$RA, (PPClo tglobaladdr:$D, 0)))`) for the `LA8` case but I don't think this pattern is really being used as removing this pattern has no effect.
https://github.com/llvm/llvm-project/pull/71485
More information about the llvm-commits
mailing list