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

Unified Diff: src/IceInstX86Base.h

Issue 2135403002: Subzero: Aggressive LEA (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Put duplicate logic into protected method 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/IceInstX86Base.h
diff --git a/src/IceInstX86Base.h b/src/IceInstX86Base.h
index 655b38d36831fe47acf75e14ca419eedc11f6e9b..0beb0ad3fb73e43598361d503cbabe945aad369f 100644
--- a/src/IceInstX86Base.h
+++ b/src/IceInstX86Base.h
@@ -587,6 +587,7 @@ template <typename TraitsType> struct InstImpl {
};
/// Instructions of the form x := op(y).
+ class InstX86Add;
template <typename InstX86Base::InstKindX86 K>
class InstX86BaseUnaryopGPR : public InstX86Base {
InstX86BaseUnaryopGPR() = delete;
@@ -620,6 +621,13 @@ template <typename TraitsType> struct InstImpl {
Type Ty = Var->getType();
const Operand *Src = this->getSrc(0);
constexpr bool IsLea = K == InstX86Base::Lea;
+
+ if (IsLea) {
+ if (auto *Add = deoptLeaToAddOrNull(Func)) {
+ Add->emitIAS(Func);
+ return;
+ }
+ }
emitIASRegOpTyGPR(Func, IsLea, Ty, Var, Src, Emitter);
}
void dump(const Cfg *Func) const override {
@@ -630,6 +638,7 @@ template <typename TraitsType> struct InstImpl {
Str << " = " << Opcode << "." << this->getSrc(0)->getType() << " ";
this->dumpSources(Func);
}
+
static bool classof(const Inst *Instr) {
return InstX86Base::isClassof(Instr, InstX86Base::K);
}
@@ -640,6 +649,21 @@ template <typename TraitsType> struct InstImpl {
this->addSource(Src);
}
+ InstX86Add *deoptLeaToAddOrNull(const Cfg *Func) const {
Jim Stichnoth 2016/08/02 03:43:52 I think you could just declare this to return Inst
manasijm 2016/08/02 16:08:36 Done.
+ // Revert back to Add when the Lea is a 2-address instruction.
+ // Caller has to emit, this just produces the add instruction.
+ auto *MemOp = llvm::dyn_cast<X86OperandMem>(this->getSrc(0));
Jim Stichnoth 2016/08/02 03:43:52 if (auto *MemOp = llvm::dyn_cast<X86OperandMem>(th
manasijm 2016/08/02 16:08:36 Done.
+ if (MemOp != nullptr && getFlags().getAggressiveLea() &&
+ MemOp->getBase()->getRegNum() == this->getDest()->getRegNum() &&
+ MemOp->getIndex() == nullptr && MemOp->getShift() == 0) {
+ auto *Add = InstImpl<TraitsType>::InstX86Add::create(
+ const_cast<Cfg *>(Func), this->getDest(), MemOp->getOffset());
+ // TODO(manasijm): Remove const_cast by emitting code for add directly.
+ return Add;
+ }
+ return nullptr;
+ }
+
static const char *Opcode;
static const GPREmitterRegOp Emitter;
};
« no previous file with comments | « src/IceClFlags.def ('k') | src/IceInstX86BaseImpl.h » ('j') | src/IceInstX86BaseImpl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698