Index: lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp =================================================================== --- lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp +++ lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp @@ -135,9 +135,13 @@ continue; unsigned Def = MO.getReg(); if (TargetRegisterInfo::isVirtualRegister(Def)) { - if (TRI->isSGPRClass(MRI.getRegClass(Def))) - SGPRLiveRanges.push_back( - std::make_pair(Def, &LIS->getInterval(Def))); + if (TRI->isSGPRClass(MRI.getRegClass(Def))) { + // Only consider defs that are live outs. We don't care about def / + // use within the same block. + LiveRange &LR = LIS->getInterval(Def); + if (LIS->isLiveOutOfMBB(LR, &MBB)) + SGPRLiveRanges.push_back(std::make_pair(Def, &LR)); + } } else if (TRI->isSGPRClass(TRI->getPhysRegClass(Def))) { SGPRLiveRanges.push_back( std::make_pair(Def, &LIS->getRegUnit(Def)));