Index: src/IceInstX86BaseImpl.h |
diff --git a/src/IceInstX86BaseImpl.h b/src/IceInstX86BaseImpl.h |
index cfc36d44a4fb3827d3329385015dc6de47a9631b..8e5f5a602c458114dfa4ed6bb62a736eeafe6dfc 100644 |
--- a/src/IceInstX86BaseImpl.h |
+++ b/src/IceInstX86BaseImpl.h |
@@ -2025,6 +2025,21 @@ template <typename TraitsType> |
void InstImpl<TraitsType>::InstX86Lea::emit(const Cfg *Func) const { |
if (!BuildDefs::dump()) |
return; |
+ |
+ auto *MemOp = llvm::dyn_cast<X86OperandMem>(this->getSrc(0)); |
+ if (MemOp != nullptr && getFlags().getAggressiveLea() && |
+ MemOp->getBase()->getRegNum() == this->getDest()->getRegNum() && |
+ MemOp->getIndex() == nullptr && MemOp->getShift() == 0) { |
+ // Reverts back to Add when the Lea is a 2-address instruction |
+ auto *Add = InstImpl<TraitsType>::InstX86Add::create( |
+ const_cast<Cfg *>(Func), this->getDest(), MemOp->getOffset()); |
+ //TODO: Remove const_cast by emitting code for add directly. |
Jim Stichnoth
2016/08/01 21:08:41
TODO(owner)
also, odd that there's no spaced afte
manasijm
2016/08/01 23:14:58
Done.
|
+ // Using the allocator does not help because the constructor for |
+ // InstX86Lea takes a non-const Cfg * |
+ Add->emit(Func); |
+ return; |
+ } |
+ |
Ostream &Str = Func->getContext()->getStrEmit(); |
assert(this->getSrcSize() == 1); |
assert(this->getDest()->hasReg()); |