Index: src/IceInst.cpp |
diff --git a/src/IceInst.cpp b/src/IceInst.cpp |
index b06f6dfa12449039c441670c016b7641ed0672ba..0e6be75ffd8b6a3dd34aa2427c5eada0ff106461 100644 |
--- a/src/IceInst.cpp |
+++ b/src/IceInst.cpp |
@@ -873,4 +873,20 @@ void InstTarget::dump(const Cfg *Func) const { |
Inst::dump(Func); |
} |
+bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { |
+ const auto SrcVar = llvm::dyn_cast<const Variable>(Source); |
+ if (!SrcVar) |
+ return false; |
+ if (Dest->hasReg() && Dest->getRegNum() == SrcVar->getRegNum()) { |
+ // TODO: On x86-64, instructions like "mov eax, eax" are used to |
+ // clear the upper 32 bits of rax. We need to recognize and |
+ // preserve these. |
+ return true; |
+ } |
+ if (!Dest->hasReg() && !SrcVar->hasReg() && |
+ Dest->getStackOffset() == SrcVar->getStackOffset()) |
+ return true; |
+ return false; |
+} |
+ |
} // end of namespace Ice |