summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineRegisterInfo.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-08-09 22:49:46 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-08-09 22:49:46 +0000
commit81a6995243380668e6f991fa4e11dd0a6e37e030 (patch)
tree44dcd3571c6e0280d0ed7fbb9047d71d703ad1a3 /lib/CodeGen/MachineRegisterInfo.cpp
parent46f4c35372062eaf097922b5683bc6639ccf342b (diff)
downloadllvm-81a6995243380668e6f991fa4e11dd0a6e37e030.tar.gz
llvm-81a6995243380668e6f991fa4e11dd0a6e37e030.tar.bz2
llvm-81a6995243380668e6f991fa4e11dd0a6e37e030.tar.xz
Partition use lists so defs always come before uses.
This makes it possible to speed up def_iterator by stopping at the first use. This makes def_empty() and getUniqueVRegDef() much faster when there are many uses. In a +Asserts build, LiveVariables is 100x faster in one case because getVRegDef() has an assertion that would scan to the end of a def_iterator chain. Spill weight calculation is significantly faster (300x in one case) because isTriviallyReMaterializable() calls MRI->isConstantPhysReg(%RIP) which calls def_empty(%RIP). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161634 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineRegisterInfo.cpp')
-rw-r--r--lib/CodeGen/MachineRegisterInfo.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp
index bd826fb7c1..5fb938f340 100644
--- a/lib/CodeGen/MachineRegisterInfo.cpp
+++ b/lib/CodeGen/MachineRegisterInfo.cpp
@@ -144,9 +144,17 @@ void MachineRegisterInfo::addRegOperandToUseList(MachineOperand *MO) {
Head->Contents.Reg.Prev = MO;
MO->Contents.Reg.Prev = Last;
- // Insert at the front.
- MO->Contents.Reg.Next = Head;
- HeadRef = MO;
+ // Def operands always precede uses. This allows def_iterator to stop early.
+ // Insert def operands at the front, and use operands at the back.
+ if (MO->isDef()) {
+ // Insert def at the front.
+ MO->Contents.Reg.Next = Head;
+ HeadRef = MO;
+ } else {
+ // Insert use at the end.
+ MO->Contents.Reg.Next = 0;
+ Last->Contents.Reg.Next = MO;
+ }
}
/// Remove MO from its use-def list.