aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineCSE.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-08-11 19:05:13 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-08-11 19:05:13 +0000
commitef6494f24dcc01be9db78c827bdc320e672a510f (patch)
treeddab413a8b7b9bbdc3c95eff8650c2c7ea5aa697 /llvm/lib/CodeGen/MachineCSE.cpp
parent490c45c06c59c386cd72d9e32c048e7367b1d49b (diff)
downloadllvm-ef6494f24dcc01be9db78c827bdc320e672a510f.zip
llvm-ef6494f24dcc01be9db78c827bdc320e672a510f.tar.gz
llvm-ef6494f24dcc01be9db78c827bdc320e672a510f.tar.bz2
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. llvm-svn: 161728
Diffstat (limited to 'llvm/lib/CodeGen/MachineCSE.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCSE.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp
index 5153abb..993975e 100644
--- a/llvm/lib/CodeGen/MachineCSE.cpp
+++ b/llvm/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);
}