aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2022-02-26 20:29:16 +0100
committerBenjamin Kramer <benny.kra@googlemail.com>2022-02-26 20:32:12 +0100
commit1de11fe3600052d0cbc6c1f7c0ebd157348cc613 (patch)
tree8405b213ebd2ef4d43e4dbbea76c990a602d8fd0
parentb474ca1d5a445cdfa924d794439013bea1599f92 (diff)
downloadllvm-1de11fe3600052d0cbc6c1f7c0ebd157348cc613.zip
llvm-1de11fe3600052d0cbc6c1f7c0ebd157348cc613.tar.gz
llvm-1de11fe3600052d0cbc6c1f7c0ebd157348cc613.tar.bz2
Use RegisterInfo::regsOverlaps instead of checking aliases
This is both less code and faster since it doesn't have to expand all the sub & superreg sets. NFCI.
-rw-r--r--llvm/lib/CodeGen/CallingConvLower.cpp12
-rw-r--r--llvm/lib/CodeGen/ReachingDefAnalysis.cpp14
-rw-r--r--llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp21
3 files changed, 11 insertions, 36 deletions
diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp b/llvm/lib/CodeGen/CallingConvLower.cpp
index c9246f6..d51b354 100644
--- a/llvm/lib/CodeGen/CallingConvLower.cpp
+++ b/llvm/lib/CodeGen/CallingConvLower.cpp
@@ -72,15 +72,9 @@ bool CCState::IsShadowAllocatedReg(MCRegister Reg) const {
if (!isAllocated(Reg))
return false;
- for (auto const &ValAssign : Locs) {
- if (ValAssign.isRegLoc()) {
- for (MCRegAliasIterator AI(ValAssign.getLocReg(), &TRI, true);
- AI.isValid(); ++AI) {
- if (*AI == Reg)
- return false;
- }
- }
- }
+ for (auto const &ValAssign : Locs)
+ if (ValAssign.isRegLoc() && TRI.regsOverlap(ValAssign.getLocReg(), Reg))
+ return false;
return true;
}
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index 1264e60..69db8ba 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -34,12 +34,7 @@ static bool isValidRegUseOf(const MachineOperand &MO, MCRegister PhysReg,
const TargetRegisterInfo *TRI) {
if (!isValidRegUse(MO))
return false;
- if (MO.getReg() == PhysReg)
- return true;
- for (MCRegAliasIterator R(PhysReg, TRI, false); R.isValid(); ++R)
- if (MO.getReg() == *R)
- return true;
- return false;
+ return TRI->regsOverlap(MO.getReg(), PhysReg);
}
static bool isValidRegDef(const MachineOperand &MO) {
@@ -50,12 +45,7 @@ static bool isValidRegDefOf(const MachineOperand &MO, MCRegister PhysReg,
const TargetRegisterInfo *TRI) {
if (!isValidRegDef(MO))
return false;
- if (MO.getReg() == PhysReg)
- return true;
- for (MCRegAliasIterator R(PhysReg, TRI, false); R.isValid(); ++R)
- if (MO.getReg() == *R)
- return true;
- return false;
+ return TRI->regsOverlap(MO.getReg(), PhysReg);
}
void ReachingDefAnalysis::enterBasicBlock(MachineBasicBlock *MBB) {
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index ff99d1f..0e4574c 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -5345,18 +5345,12 @@ bool AMDGPUAsmParser::ParseDirective(AsmToken DirectiveID) {
bool AMDGPUAsmParser::subtargetHasRegister(const MCRegisterInfo &MRI,
unsigned RegNo) {
- for (MCRegAliasIterator R(AMDGPU::TTMP12_TTMP13_TTMP14_TTMP15, &MRI, true);
- R.isValid(); ++R) {
- if (*R == RegNo)
- return isGFX9Plus();
- }
+ if (MRI.regsOverlap(AMDGPU::TTMP12_TTMP13_TTMP14_TTMP15, RegNo))
+ return isGFX9Plus();
// GFX10 has 2 more SGPRs 104 and 105.
- for (MCRegAliasIterator R(AMDGPU::SGPR104_SGPR105, &MRI, true);
- R.isValid(); ++R) {
- if (*R == RegNo)
- return hasSGPR104_SGPR105();
- }
+ if (MRI.regsOverlap(AMDGPU::SGPR104_SGPR105, RegNo))
+ return hasSGPR104_SGPR105();
switch (RegNo) {
case AMDGPU::SRC_SHARED_BASE:
@@ -5401,11 +5395,8 @@ bool AMDGPUAsmParser::subtargetHasRegister(const MCRegisterInfo &MRI,
// VI only has 102 SGPRs, so make sure we aren't trying to use the 2 more that
// SI/CI have.
- for (MCRegAliasIterator R(AMDGPU::SGPR102_SGPR103, &MRI, true);
- R.isValid(); ++R) {
- if (*R == RegNo)
- return hasSGPR102_SGPR103();
- }
+ if (MRI.regsOverlap(AMDGPU::SGPR102_SGPR103, RegNo))
+ return hasSGPR102_SGPR103();
return true;
}