]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Prevent too large store merges in AMDGPU Subtargets. NFCI.
authorNirav Dave <niravd@google.com>
Wed, 24 May 2017 15:59:09 +0000 (15:59 +0000)
committerNirav Dave <niravd@google.com>
Wed, 24 May 2017 15:59:09 +0000 (15:59 +0000)
Various address spaces on the SI and R600 subtargets have stricter
limits on memory access size that other address spaces. Use
canMergeStoresTo predicate to prevent the DAGCombiner from creating
these stores as they will be split up during legalization.

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

lib/Target/AMDGPU/R600ISelLowering.cpp
lib/Target/AMDGPU/R600ISelLowering.h
lib/Target/AMDGPU/SIISelLowering.cpp
lib/Target/AMDGPU/SIISelLowering.h

index 3590a9b05e1d04773bc6cb8d08e5cb319801cb52..60b913cfd39af64d4b0f8cfa0e13e54b0599d0ec 100644 (file)
@@ -1618,6 +1618,14 @@ EVT R600TargetLowering::getSetCCResultType(const DataLayout &DL, LLVMContext &,
    return VT.changeVectorElementTypeToInteger();
 }
 
+bool R600TargetLowering::canMergeStoresTo(unsigned AS, EVT MemVT) const {
+  // Local and Private addresses do not handle vectors. Limit to i32
+  if ((AS == AMDGPUASI.LOCAL_ADDRESS || AS == AMDGPUASI.PRIVATE_ADDRESS)) {
+    return (MemVT.getSizeInBits() <= 32);
+  }
+  return true;
+}
+
 bool R600TargetLowering::allowsMisalignedMemoryAccesses(EVT VT,
                                                         unsigned AddrSpace,
                                                         unsigned Align,
index 9700ce14c6f3179595a00d135662e4a34adb4d30..d6a0876a6ee7d9f31295940d84749a8e52ca590e 100644 (file)
@@ -44,6 +44,8 @@ public:
   EVT getSetCCResultType(const DataLayout &DL, LLVMContext &,
                          EVT VT) const override;
 
+  bool canMergeStoresTo(unsigned AS, EVT MemVT) const override;
+
   bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
                                       unsigned Align,
                                       bool *IsFast) const override;
index 8c939f4bf003a8fcdf440c969de2931ac9ee82d9..76c2644867aa1f2d05c56dc2a7f3eade9e2c5dcd 100644 (file)
@@ -698,6 +698,18 @@ bool SITargetLowering::isLegalAddressingMode(const DataLayout &DL,
   }
 }
 
+bool SITargetLowering::canMergeStoresTo(unsigned AS, EVT MemVT) const {
+  if (AS == AMDGPUASI.GLOBAL_ADDRESS || AS == AMDGPUASI.FLAT_ADDRESS) {
+    return (MemVT.getSizeInBits() <= 4 * 32);
+  } else if (AS == AMDGPUASI.PRIVATE_ADDRESS) {
+    unsigned MaxPrivateBits = 8 * getSubtarget()->getMaxPrivateElementSize();
+    return (MemVT.getSizeInBits() <= MaxPrivateBits);
+  } else if (AS == AMDGPUASI.LOCAL_ADDRESS) {
+    return (MemVT.getSizeInBits() <= 2 * 32);
+  }
+  return true;
+}
+
 bool SITargetLowering::allowsMisalignedMemoryAccesses(EVT VT,
                                                       unsigned AddrSpace,
                                                       unsigned Align,
index e68837747491d4844c6ac51912d161e5691d227f..8e2ec40b224cd63e73e21703c179377bdf1e2187 100644 (file)
@@ -150,6 +150,8 @@ public:
   bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
                              unsigned AS) const override;
 
+  bool canMergeStoresTo(unsigned AS, EVT MemVT) const override;
+
   bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS,
                                       unsigned Align,
                                       bool *IsFast) const override;