[llvm] [AMDGPU] Infer amdgpu-no-flat-scratch-init attribute in AMDGPUAttributor (PR #94647)

Jun Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 10:48:59 PDT 2024


================
@@ -433,6 +433,13 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
       indicatePessimisticFixpoint();
       return;
     }
+
+    for (Instruction &I : instructions(F)) {
+      if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
----------------
jwanggit86 wrote:

Did you mean this:
```diff
@@ -435,7 +435,7 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
     }

     for (Instruction &I : instructions(F)) {
-      if (isa<AllocaInst>(I) || isa<AddrSpaceCastInst>(I)) {
+      if (isa<AddrSpaceCastInst>(I) && static_cast<AddrSpaceCastInst&>(I).getSrcAddressSpace() == AMDGPUAS::PRIVATE_ADDRESS) {
         removeAssumedBits(FLAT_SCRATCH_INIT);
         return;
       }
```

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


More information about the llvm-commits mailing list