Index: lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -102,6 +102,7 @@ bool isNoNanSrc(SDValue N) const; bool isInlineImmediate(const SDNode *N) const; bool isVGPRImm(const SDNode *N) const; + bool isScalarLoad(const SDNode *N) const; bool isUniformBr(const SDNode *N) const; MachineSDNode *buildSMovImm64(SDLoc &DL, uint64_t Val, EVT VT) const; @@ -2117,6 +2118,19 @@ return !AllUsesAcceptSReg && (Limit < 10); } +bool AMDGPUDAGToDAGISel::isScalarLoad(const SDNode *N) const { + auto Ld = cast(N); + + return Ld->getAlignment() >= 4 && + (((Ld->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS || + Ld->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT) && + !N->isDivergent()) || + (Subtarget->getScalarizeGlobalBehavior() && + Ld->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS && + !Ld->isVolatile() && !N->isDivergent() && + static_cast(getTargetLowering()) + ->isMemOpHasNoClobberedMemOperand(N))); +} void AMDGPUDAGToDAGISel::PostprocessISelDAG() { const AMDGPUTargetLowering& Lowering = Index: lib/Target/AMDGPU/SMInstructions.td =================================================================== --- lib/Target/AMDGPU/SMInstructions.td +++ lib/Target/AMDGPU/SMInstructions.td @@ -379,14 +379,7 @@ //===----------------------------------------------------------------------===// -def smrd_load : PatFrag <(ops node:$ptr), (load node:$ptr), [{ - auto Ld = cast(N); - return Ld->getAlignment() >= 4 && - ((((Ld->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS) || (Ld->getAddressSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)) && !N->isDivergent()) || - (Subtarget->getScalarizeGlobalBehavior() && Ld->getAddressSpace() == AMDGPUAS::GLOBAL_ADDRESS && - !Ld->isVolatile() && !N->isDivergent() && - static_cast(getTargetLowering())->isMemOpHasNoClobberedMemOperand(N))); -}]>; +def smrd_load : PatFrag <(ops node:$ptr), (load node:$ptr), [{ return isScalarLoad(N);}]>; def SMRDImm : ComplexPattern; def SMRDImm32 : ComplexPattern;