[PATCH] D40344: AMDGPU: Re-organize the outer loop of SILoadStoreOptimizer

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 22 04:24:58 PST 2017


nhaehnle created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, wdng, kzhuravl.

The entire algorithm operates per basic-block, so for cache locality
it should be better to re-optimize a basic-block immediately rather than
in a separate loop.

I don't have performance measurements.

Change-Id: I85106570bd623c4ff277faaa50ee43258e1ddcc5


https://reviews.llvm.org/D40344

Files:
  lib/Target/AMDGPU/SILoadStoreOptimizer.cpp


Index: lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
===================================================================
--- lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
+++ lib/Target/AMDGPU/SILoadStoreOptimizer.cpp
@@ -14,7 +14,7 @@
 // ==>
 //   ds_read2_b32 v[0:1], v2, offset0:4 offset1:8
 //
-// The same is done for certain SMEM opcodes, e.g.:
+// The same is done for certain SMEM and VMEM opcodes, e.g.:
 //  s_buffer_load_dword s4, s[0:3], 4
 //  s_buffer_load_dword s5, s[0:3], 8
 // ==>
@@ -891,14 +891,13 @@
   DEBUG(dbgs() << "Running SILoadStoreOptimizer\n");
 
   bool Modified = false;
-  CreatedX2 = 0;
 
-  for (MachineBasicBlock &MBB : MF)
+  for (MachineBasicBlock &MBB : MF) {
+    CreatedX2 = 0;
     Modified |= optimizeBlock(MBB);
 
-  // Run again to convert x2 to x4.
-  if (CreatedX2 >= 1) {
-    for (MachineBasicBlock &MBB : MF)
+    // Run again to convert x2 to x4.
+    if (CreatedX2 >= 1)
       Modified |= optimizeBlock(MBB);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40344.123907.patch
Type: text/x-patch
Size: 964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171122/dacce3f6/attachment.bin>


More information about the llvm-commits mailing list