[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 12 14:29:22 PST 2024


================
@@ -7566,6 +7566,100 @@ static void reduceVSXSwap(SDNode *N, SelectionDAG *DAG) {
   DAG->ReplaceAllUsesOfValueWith(SDValue(N, 0), N->getOperand(0));
 }
 
+// Is an ADDI eligible for folding for non-TOC-based local-exec accesses?
+static bool isEligibleToFoldADDIForLocalExecAccesses(SDNode *N,
+                                                     SelectionDAG *DAG,
+                                                     SDValue ADDIToFold) {
+  const PPCSubtarget &Subtarget =
+      DAG->getMachineFunction().getSubtarget<PPCSubtarget>();
+  // This optimization is only performed for non-TOC-based local-exec accesses.
+  if (!Subtarget.hasAIXSmallLocalExecTLS())
+    return false;
+
----------------
diggerlin wrote:

I do not think putting the code in the function `isEligibleToFoldADDIForLocalExecAccesses`  is efficiently 

 ```
    const PPCSubtarget &Subtarget =
      DAG->getMachineFunction().getSubtarget<PPCSubtarget>();
  // This optimization is only performed for non-TOC-based local-exec accesses.
  if (!Subtarget.hasAIXSmallLocalExecTLS())
      return false;
```

I will put the code in front of function as void `PPCDAGToDAGISel::PeepholePPC64() `

as 
void PPCDAGToDAGISel::PeepholePPC64() {
```
const PPCSubtarget &Subtarget =
      DAG->getMachineFunction().getSubtarget<PPCSubtarget>();
  // This optimization is only performed for non-TOC-based local-exec accesses.
bool HasAIXSmallLocalExecTLS = Subtarget.hasAIXSmallLocalExecTLS() ;
.....

if (HasAIXSmallLocalExecTLS) 
   foldADDIForLocalExecAccesses();
   
       } else if (Offset != 0) {
        if (HasAIXSmallLocalExecTLS && isEligibleToFoldADDIForLocalExecAccesses(N, CurDAG, Base)) {
        
```


to avoid multi time get and check Subtarget.hasAIXSmallLocalExecTLS() in the loop of function `PeepholePPC64`

https://github.com/llvm/llvm-project/pull/71485


More information about the llvm-commits mailing list