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

Tom Stellard tom at stellard.net
Thu Jan 3 07:14:21 PST 2013


On Wed, Dec 26, 2012 at 05:37:21PM +0100, Vincent Lejeune wrote:
> ---
>  lib/Target/AMDGPU/AMDILISelDAGToDAG.cpp | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
>

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
 
> 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
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list