From c83fa0a0e43ee6beed430da1da66be72c9b36fc6 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Tue, 29 May 2012 23:40:02 +0000 Subject: [PATCH] Use MCRegUnitIterator to compute regsOverlap(). The register unit lists are typically much shorter than the register overlap lists, and the backing table for register units has better cache locality because it is smaller. This makes llc about 0.5% faster. The regsOverlap() function isn't that hot. llvm-svn: 157651 --- include/llvm/Target/TargetRegisterInfo.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h index 7e73db3a448..949fce84612 100644 --- a/include/llvm/Target/TargetRegisterInfo.h +++ b/include/llvm/Target/TargetRegisterInfo.h @@ -337,9 +337,15 @@ public: if (regA == regB) return true; if (isVirtualRegister(regA) || isVirtualRegister(regB)) return false; - for (const uint16_t *regList = getOverlaps(regA)+1; *regList; ++regList) { - if (*regList == regB) return true; - } + + // Regunits are numerically ordered. Find a common unit. + MCRegUnitIterator RUA(regA, this); + MCRegUnitIterator RUB(regB, this); + do { + if (*RUA == *RUB) return true; + if (*RUA < *RUB) ++RUA; + else ++RUB; + } while (RUA.isValid() && RUB.isValid()); return false; }