diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-08-09 22:49:46 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-08-09 22:49:46 +0000 |
commit | df01e00710f1eec6e22a4194b46ee8af5d0a7f29 (patch) | |
tree | 72f3253bbecfd1d6ef6feb001c6d8d6e600710ae /llvm/lib/CodeGen/MachineRegisterInfo.cpp | |
parent | 7d7051ca3ca050eb2d9df850fa7f7db1605a559c (diff) | |
download | bcm5719-llvm-df01e00710f1eec6e22a4194b46ee8af5d0a7f29.tar.gz bcm5719-llvm-df01e00710f1eec6e22a4194b46ee8af5d0a7f29.zip |
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).
llvm-svn: 161634
Diffstat (limited to 'llvm/lib/CodeGen/MachineRegisterInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineRegisterInfo.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineRegisterInfo.cpp b/llvm/lib/CodeGen/MachineRegisterInfo.cpp index bd826fb7c1b..5fb938f3400 100644 --- a/llvm/lib/CodeGen/MachineRegisterInfo.cpp +++ b/llvm/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. |