[Mesa-dev] [PATCH 4/4] R600: Fold CONST_ADDRESS when possible

Vincent Lejeune vljn at ovi.com
Wed Dec 26 08:37:21 PST 2012


---
 lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp b/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp
index 6f156df..6e07734 100644
--- a/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp
+++ b/lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp
@@ -261,7 +261,32 @@ SDNode *AMDGPUDAGToDAGISel::Select(SDNode *N) {
     break;
   }
   }
-  return SelectCode(N);
+  SDNode *Result = SelectCode(N);
+
+  const AMDGPUSubtarget &ST = TM.getSubtarget<AMDGPUSubtarget>();
+  if (ST.device()->getGeneration() <= AMDGPUDeviceInfo::HD6XXX) {
+    const R600InstrInfo *TII =
+        static_cast<const R600InstrInfo*>(TM.getInstrInfo());
+    if (Result && TII->isALUInstr(Result->getMachineOpcode())) {
+      std::vector<SDValue> Ops;
+      for(SDNode::op_iterator I = Result->op_begin(), E = Result->op_end();
+          I != E; ++I) {
+        SDValue Value = *I;
+        SDValue PotentialTGA;
+        if (Value.getOpcode() == AMDGPUISD::CONST_ADDRESS &&
+           !Value.getValueType().isVector() &&
+           SelectGlobalValueConstantOffset(Value.getOperand(0), PotentialTGA)) {
+          Ops.push_back(PotentialTGA);
+        } else {
+          Ops.push_back(Value);
+        }
+      }
+      CurDAG->MorphNodeTo(Result, Result->getOpcode(), Result->getVTList(),
+          Ops.data(), Ops.size());
+    }
+  }
+
+  return Result;
 }
 
 bool AMDGPUDAGToDAGISel::checkType(const Value *ptr, unsigned int addrspace) {
-- 
1.8.0.1



More information about the mesa-dev mailing list