From 0c2192db7bfa1a8255009a8aea2b6ebd218a8c3c Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 15 Aug 2015 02:58:49 +0000 Subject: [PATCH] AMDGPU/SI: Only look at live out SGPR defs When trying to fix SGPR live ranges, skip defs that are killed in the same block as the def. I don't think we need to worry about these cases as long as the live ranges of the SGPRs in dominating blocks are correct. This reduces the number of elements the second loop over the function needs to look at, and makes it generally easier to understand. The second loop also only considers if the live range is live in to a block, which logically means it must have been live out from another. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245150 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp b/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp index 016e2c8c886..3dda827b671 100644 --- a/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp +++ b/lib/Target/AMDGPU/SIFixSGPRLiveRanges.cpp @@ -128,9 +128,13 @@ bool SIFixSGPRLiveRanges::runOnMachineFunction(MachineFunction &MF) { 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))); -- 2.34.1