[llvm] [AIX][TLS] Optimize the small local-exec access sequence for non-zero offsets (PR #71485)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 26 08:15:08 PST 2024
================
@@ -1504,12 +1513,72 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
// Verify alignment is legal, so we don't create relocations
// that can't be supported.
unsigned OpNum = (MI->getOpcode() == PPC::STD) ? 2 : 1;
+ // For non-TOC-based local-exec TLS accesses with non-zero offsets, the
+ // machine operand (which is a TargetGlobalTLSAddress) is expected to be
+ // the same operand for both loads and stores.
+ for (const MachineOperand &TempMO : MI->operands()) {
+ if (((TempMO.getTargetFlags() == PPCII::MO_TPREL_FLAG)) &&
+ TempMO.getOperandNo() == 1)
+ OpNum = 1;
+ }
const MachineOperand &MO = MI->getOperand(OpNum);
if (MO.isGlobal()) {
const DataLayout &DL = MO.getGlobal()->getParent()->getDataLayout();
if (MO.getGlobal()->getPointerAlignment(DL) < 4)
llvm_unreachable("Global must be word-aligned for LD, STD, LWA!");
}
+ // As these load/stores share common code with the following load/stores,
+ // fall through to the subsequent cases in order to either process the
+ // non-TOC-based local-exec sequence or to process the instruction normally.
+ [[fallthrough]];
+ }
+ case PPC::LBZ:
+ case PPC::LBZ8:
+ case PPC::LHA:
+ case PPC::LHA8:
+ case PPC::LHZ:
+ case PPC::LHZ8:
+ case PPC::LWZ:
+ case PPC::LWZ8:
+ case PPC::STB:
+ case PPC::STB8:
+ case PPC::STH:
+ case PPC::STH8:
+ case PPC::STW:
+ case PPC::STW8:
+ case PPC::LFS:
+ case PPC::STFS:
+ case PPC::LFD:
+ case PPC::STFD:
+ case PPC::ADDI8: {
+ // A faster non-TOC-based local-exec sequence is represented by `addi`
----------------
diggerlin wrote:
Nit: for performance, I will suggest that put following code here.
```
if(!HasAIXSmallLocalExecTLS)
break;
```
instead of assert later
```
assert(HasAIXSmallLocalExecTLS &&
"addi, or load/stores with thread-pointer only expected with "
"local-exec small TLS");
```
https://github.com/llvm/llvm-project/pull/71485
More information about the llvm-commits
mailing list