Index: lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -73,8 +73,6 @@ bool FoldOperands(unsigned, const R600InstrInfo *, std::vector &); bool FoldDotOperands(unsigned, const R600InstrInfo *, std::vector &); - static bool checkType(const Value *ptr, unsigned int addrspace); - static bool isGlobalStore(const MemSDNode *N); static bool isFlatStore(const MemSDNode *N); static bool isLocalStore(const StoreSDNode *N); @@ -227,8 +225,7 @@ SDNode *AMDGPUDAGToDAGISel::glueCopyToM0(SDNode *N) const { if (Subtarget->getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS || - !checkType(cast(N)->getMemOperand()->getValue(), - AMDGPUAS::LOCAL_ADDRESS)) + cast(N)->getAddressSpace() != AMDGPUAS::LOCAL_ADDRESS) return N; const SITargetLowering& Lowering = @@ -492,38 +489,25 @@ SelectCode(N); } -bool AMDGPUDAGToDAGISel::checkType(const Value *Ptr, unsigned AS) { - assert(AS != 0 && "Use checkPrivateAddress instead."); - if (!Ptr) - return false; - - return Ptr->getType()->getPointerAddressSpace() == AS; -} - bool AMDGPUDAGToDAGISel::isGlobalStore(const MemSDNode *N) { - if (!N->writeMem()) - return false; - return checkType(N->getMemOperand()->getValue(), AMDGPUAS::GLOBAL_ADDRESS); + return N->writeMem() && N->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS; } bool AMDGPUDAGToDAGISel::isLocalStore(const StoreSDNode *N) { - return checkType(N->getMemOperand()->getValue(), AMDGPUAS::LOCAL_ADDRESS); + return N->writeMem() && N->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS; } bool AMDGPUDAGToDAGISel::isFlatStore(const MemSDNode *N) { - if (!N->writeMem()) - return false; - return checkType(N->getMemOperand()->getValue(), AMDGPUAS::FLAT_ADDRESS); + return N->writeMem() && N->getAddressSpace() == AMDGPUAS::FLAT_ADDRESS; } bool AMDGPUDAGToDAGISel::isConstantLoad(const MemSDNode *N, int CbId) const { if (!N->readMem()) return false; - const Value *MemVal = N->getMemOperand()->getValue(); if (CbId == -1) - return checkType(MemVal, AMDGPUAS::CONSTANT_ADDRESS); + return N->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS; - return checkType(MemVal, AMDGPUAS::CONSTANT_BUFFER_0 + CbId); + return N->getAddressSpace() == AMDGPUAS::CONSTANT_BUFFER_0 + CbId; } bool AMDGPUDAGToDAGISel::isGlobalLoad(const MemSDNode *N) const { @@ -539,17 +523,15 @@ return true; } - return checkType(N->getMemOperand()->getValue(), AMDGPUAS::GLOBAL_ADDRESS); + return N->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS; } bool AMDGPUDAGToDAGISel::isLocalLoad(const LoadSDNode *N) const { - return checkType(N->getMemOperand()->getValue(), AMDGPUAS::LOCAL_ADDRESS); + return N->readMem() && N->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS; } bool AMDGPUDAGToDAGISel::isFlatLoad(const MemSDNode *N) const { - if (!N->readMem()) - return false; - return checkType(N->getMemOperand()->getValue(), AMDGPUAS::FLAT_ADDRESS); + return N->readMem() && N->getAddressSpace() == AMDGPUAS::FLAT_ADDRESS; } bool AMDGPUDAGToDAGISel::isUniformBr(const SDNode *N) const {