diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-11 19:05:13 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-11 19:05:13 +0000 |
commit | cfc0ad6e48fcbb5d9d7d97307e5b5df6bba53a97 (patch) | |
tree | 24730fa558c42c12dd366c493121db779c3f2845 /lib/CodeGen/MachineCSE.cpp | |
parent | f4cfc4423cd48fd673e1de17aafe4db21e52f876 (diff) | |
download | llvm-cfc0ad6e48fcbb5d9d7d97307e5b5df6bba53a97.tar.gz llvm-cfc0ad6e48fcbb5d9d7d97307e5b5df6bba53a97.tar.bz2 llvm-cfc0ad6e48fcbb5d9d7d97307e5b5df6bba53a97.tar.xz |
PR13578: Teach MachineCSE that instructions that use a constant register can be CSE'd safely.
This is common e.g. when doing rip-relative addressing on x86_64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161728 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineCSE.cpp')
-rw-r--r-- | lib/CodeGen/MachineCSE.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/MachineCSE.cpp b/lib/CodeGen/MachineCSE.cpp index 5153abbc4e..993975ef0e 100644 --- a/lib/CodeGen/MachineCSE.cpp +++ b/lib/CodeGen/MachineCSE.cpp @@ -215,8 +215,11 @@ bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI, if (MO.isDef() && (MO.isDead() || isPhysDefTriviallyDead(Reg, I, MBB->end()))) continue; - for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) - PhysRefs.insert(*AI); + for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) { + // Reading constant physregs is ok. + if (!MRI->isConstantPhysReg(*AI, *MBB->getParent())) + PhysRefs.insert(*AI); + } if (MO.isDef()) PhysDefs.push_back(Reg); } |