]> granicus.if.org Git - llvm/commitdiff
AMDGPU: Ignore subtarget for InferAddressSpaces
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 17 Jun 2019 14:13:24 +0000 (14:13 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 17 Jun 2019 14:13:24 +0000 (14:13 +0000)
Even if the target doesn't have flat instructions, addrspace(0) is
still flat. It just happens to not work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363561 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
test/Transforms/InferAddressSpaces/AMDGPU/no-flat-addrspace.ll [new file with mode: 0644]

index d1ed6144e54271908ea06e5062be6f85c48376f2..72882c83c01c168421af90dc30cea7a7e47d8cab 100644 (file)
@@ -180,8 +180,7 @@ public:
     // don't use flat addressing.
     if (IsGraphicsShader)
       return -1;
-    return ST->hasFlatAddressSpace() ?
-      AMDGPUAS::FLAT_ADDRESS : AMDGPUAS::UNKNOWN_ADDRESS_SPACE;
+    return AMDGPUAS::FLAT_ADDRESS;
   }
 
   unsigned getVectorSplitCost() { return 0; }
diff --git a/test/Transforms/InferAddressSpaces/AMDGPU/no-flat-addrspace.ll b/test/Transforms/InferAddressSpaces/AMDGPU/no-flat-addrspace.ll
new file mode 100644 (file)
index 0000000..8e04d3c
--- /dev/null
@@ -0,0 +1,13 @@
+; RUN: opt -S -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -infer-address-spaces %s | FileCheck %s
+
+; Make sure addrspace(0) is still treated as flat on targets without
+; flat instructions. It's still flat, it just doesn't work.
+
+; CHECK-LABEL: @load_flat_from_global(
+; CHECK-NEXT: %tmp1 = load float, float addrspace(1)* %ptr
+; CHECK-NEXT: ret float %tmp1
+define float @load_flat_from_global(float addrspace(1)*%ptr) #0 {
+  %tmp0 = addrspacecast float addrspace(1)* %ptr to float*
+  %tmp1 = load float, float* %tmp0
+  ret float %tmp1
+}