R600/SI: Add load / store machine optimizer pass.
[oota-llvm.git] / lib / Target / R600 / AMDGPUTargetMachine.cpp
index c95a9410ff6a9776f1c9a444ec9a3074a529babc..1b4fe832f20b80d1867a02160a8398233db0b366 100644 (file)
@@ -148,6 +148,17 @@ bool AMDGPUPassConfig::addPreRegAlloc() {
     // SIFixSGPRCopies can generate a lot of duplicate instructions,
     // so we need to run MachineCSE afterwards.
     addPass(&MachineCSEID);
+
+    if (getOptLevel() > CodeGenOpt::None && ST.loadStoreOptEnabled()) {
+      // Don't do this with no optimizations since it throws away debug info by
+      // merging nonadjacent loads.
+
+      // This should be run after scheduling, but before register allocation. It
+      // also need extra copies to the address operand to be eliminated.
+      initializeSILoadStoreOptimizerPass(*PassRegistry::getPassRegistry());
+      insertPass(&MachineSchedulerID, &SILoadStoreOptimizerID);
+    }
+
     addPass(createSIShrinkInstructionsPass());
     addPass(createSIFixSGPRLiveRangesPass());
   }