[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
Fri Jan 26 20:56:18 PST 2024


================
@@ -7578,6 +7668,10 @@ void PPCDAGToDAGISel::PeepholePPC64() {
     if (isVSXSwap(SDValue(N, 0)))
       reduceVSXSwap(N, CurDAG);
 
+    // This optimization is performed for non-TOC-based local-exec accesses.
+    if (HasAIXSmallLocalExecTLS)
+      foldADDIForLocalExecAccesses(N, CurDAG);
----------------
amy-kwan wrote:

Thanks for the suggestion, Digger. I was initially thinking of keeping the code as is.

However, just so I understand your suggestion, are you suggesting the following or am I mistaken?
```
    if (HasAIXSmallLocalExecTLS) {
      foldADDIForLocalExecAccesses(N, CurDAG);
      continue;
    }
```

In the case where I have something like:
```
SelectionDAG has 9 nodes:
  t0: ch,glue = EntryToken
      t2: i64,ch = CopyFromReg t0, Register:i64 %0
      t22: i64 = ADDI8 Register:i64 $x13, TargetGlobalTLSAddress:i64<ptr @IThreadLocalVarInit> 0 [TF=7]
    t17: ch = STB8<Mem:(store (s8) into %ir.0)> t2, TargetConstant:i64<0>, t22, t0
  t13: ch = BLR8 t17
```
It will visit the `STB8` first, and it will fail the transformation for `foldADDIForLocalExecAccesses()`, but since I have a `continue;` right after, it will not proceed below to optimize the store.

Just wanted to double check if I understood your suggestion correctly, because I think currently as I understand it, it doesn't seem like it would work in this situation.

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


More information about the llvm-commits mailing list