[llvm] [AMDGPU] Allow casts between the Global and Constant Addr Spaces in isValidAddrSpaceCast (PR #112493)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 01:04:59 PDT 2024


================
@@ -187,9 +187,12 @@ class GCNTTIImpl final : public BasicTTIImplBase<GCNTTIImpl> {
       }
       return false;
     }
-    if ((FromAS == AMDGPUAS::CONSTANT_ADDRESS_32BIT &&
-         ToAS == AMDGPUAS::CONSTANT_ADDRESS) ||
-        (FromAS == AMDGPUAS::CONSTANT_ADDRESS &&
+    if (FromAS != ToAS &&
+        (FromAS == AMDGPUAS::GLOBAL_ADDRESS ||
+         FromAS == AMDGPUAS::CONSTANT_ADDRESS ||
+         FromAS == AMDGPUAS::CONSTANT_ADDRESS_32BIT) &&
+        (ToAS == AMDGPUAS::GLOBAL_ADDRESS ||
+         ToAS == AMDGPUAS::CONSTANT_ADDRESS ||
          ToAS == AMDGPUAS::CONSTANT_ADDRESS_32BIT))
----------------
arsenm wrote:

The whole function should match isExtendedGlobalAddrSpace. We should accept arbitrary 64-bit address spaces as an alias for global. The part above under ToAS == AMDGPUAS::FLAT_ADDRESS is also too strict.

The only illegal cases involve region and anything, fat pointers and anything, or any of the 32-bit address spaces between each other.

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


More information about the llvm-commits mailing list