R600/SI: Insert more NOPs after READLANE on VI, don't use NOPs on CI
authorMarek Olsak <marek.olsak@amd.com>
Tue, 24 Mar 2015 13:40:38 +0000 (13:40 +0000)
committerMarek Olsak <marek.olsak@amd.com>
Tue, 24 Mar 2015 13:40:38 +0000 (13:40 +0000)
This is a candidate for stable.

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

lib/Target/R600/SIRegisterInfo.cpp

index 6030ce8df465241ebccf711c94665cc7be2eb6f9..13a89743677403aeac5ddb2ca1589d97024504f9 100644 (file)
@@ -268,7 +268,22 @@ void SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
                   .addReg(SubReg);
         }
       }
-      TII->insertNOPs(MI, 3);
+
+      // TODO: only do this when it is needed
+      switch (MF->getSubtarget<AMDGPUSubtarget>().getGeneration()) {
+      case AMDGPUSubtarget::SOUTHERN_ISLANDS:
+        // "VALU writes SGPR" -> "SMRD reads that SGPR" needs "S_NOP 3" on SI
+        TII->insertNOPs(MI, 3);
+        break;
+      case AMDGPUSubtarget::SEA_ISLANDS:
+        break;
+      default: // VOLCANIC_ISLANDS and later
+        // "VALU writes SGPR -> VMEM reads that SGPR" needs "S_NOP 4" on VI
+        // and later. This also applies to VALUs which write VCC, but we're
+        // unlikely to see VMEM use VCC.
+        TII->insertNOPs(MI, 4);
+      }
+
       MI->eraseFromParent();
       break;
     }