Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: src/IceInstX86BaseImpl.h

Issue 2135403002: Subzero: Aggressive LEA (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Address Comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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());

Powered by Google App Engine
This is Rietveld 408576698