diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-10 12:50:44 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-10 12:50:44 +0000 |
commit | 1e8db1a4faac5c9fdd486a6ddcdec1909f12e789 (patch) | |
tree | a9096eb70d85cb50d833173d58803d9ec22bbf4b | |
parent | 84dfc32ff906271c373819595e60a173624e1184 (diff) | |
download | external_llvm-1e8db1a4faac5c9fdd486a6ddcdec1909f12e789.zip external_llvm-1e8db1a4faac5c9fdd486a6ddcdec1909f12e789.tar.gz external_llvm-1e8db1a4faac5c9fdd486a6ddcdec1909f12e789.tar.bz2 |
Microoptimize getVRegDef. def_begin isn't free, don't compute it twice.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152492 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/MachineRegisterInfo.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp index 7d40e66..f140dec 100644 --- a/lib/CodeGen/MachineRegisterInfo.cpp +++ b/lib/CodeGen/MachineRegisterInfo.cpp @@ -161,9 +161,8 @@ void MachineRegisterInfo::replaceRegWith(unsigned FromReg, unsigned ToReg) { /// form, so there should only be one definition. MachineInstr *MachineRegisterInfo::getVRegDef(unsigned Reg) const { // Since we are in SSA form, we can use the first definition. - if (!def_empty(Reg)) - return &*def_begin(Reg); - return 0; + def_iterator I = def_begin(Reg); + return !I.atEnd() ? &*I : 0; } bool MachineRegisterInfo::hasOneUse(unsigned RegNo) const { |