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

Unified Diff: src/IceTargetLoweringX8632.cpp

Issue 490333003: Subzero: Fix address mode optimization involving phi temporaries. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Clean up and better document the test Created 6 years, 4 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/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 7ed8abff5152680166ca35fe06b044d8211f19c7..a0e440892bf7ef923494b918b3680a18a2d6206e 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -3482,8 +3482,35 @@ bool isAdd(const Inst *Inst) {
return false;
}
-void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift,
- int32_t &Offset) {
+void dumpAddressOpt(const Cfg *Func, const Variable *Base,
+ const Variable *Index, uint16_t Shift, int32_t Offset,
+ const Inst *Reason) {
+ if (!Func->getContext()->isVerbose(IceV_AddrOpt))
+ return;
+ Ostream &Str = Func->getContext()->getStrDump();
+ Str << "Instruction: ";
+ Reason->dumpDecorated(Func);
+ Str << " results in Base=";
+ if (Base)
+ Base->dump(Func);
+ else
+ Str << "<null>";
+ Str << ", Index=";
+ if (Index)
+ Index->dump(Func);
+ else
+ Str << "<null>";
+ Str << ", Shift=" << Shift << ", Offset=" << Offset << "\n";
+}
+
+void computeAddressOpt(Cfg *Func, const Inst *Instr, Variable *&Base,
+ Variable *&Index, uint16_t &Shift, int32_t &Offset) {
+ Func->setCurrentNode(NULL);
+ if (Func->getContext()->isVerbose(IceV_AddrOpt)) {
+ Ostream &Str = Func->getContext()->getStrDump();
+ Str << "\nStarting computeAddressOpt for instruction:\n ";
+ Instr->dumpDecorated(Func);
+ }
(void)Offset; // TODO: pattern-match for non-zero offsets.
if (Base == NULL)
return;
@@ -3506,6 +3533,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift,
// TODO: ensure BaseVariable0 stays single-BB
jvoung (off chromium) 2014/08/27 16:21:07 Does this take care of the TODO? Maybe not the on
Jim Stichnoth 2014/08/27 20:23:14 I don't think so. This needs to be tuned, but my
true) {
Base = BaseVariable0;
+ dumpAddressOpt(Func, Base, Index, Shift, Offset, BaseInst);
continue;
}
@@ -3523,6 +3551,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift,
Base = BaseVariable0;
Index = BaseVariable1;
Shift = 0; // should already have been 0
+ dumpAddressOpt(Func, Base, Index, Shift, Offset, BaseInst);
continue;
}
@@ -3560,6 +3589,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift,
if (Shift + LogMult <= 3) {
Index = IndexVariable0;
Shift += LogMult;
+ dumpAddressOpt(Func, Base, Index, Shift, Offset, IndexInst);
continue;
}
}
@@ -3589,6 +3619,7 @@ void computeAddressOpt(Variable *&Base, Variable *&Index, uint16_t &Shift,
}
Base = Var;
Offset += IsAdd ? Const->getValue() : -Const->getValue();
+ dumpAddressOpt(Func, Base, Index, Shift, Offset, BaseInst);
continue;
}
@@ -3684,7 +3715,7 @@ void TargetX8632::doAddressOptLoad() {
const OperandX8632Mem::SegmentRegisters SegmentReg =
OperandX8632Mem::DefaultSegment;
Variable *Base = llvm::dyn_cast<Variable>(Addr);
- computeAddressOpt(Base, Index, Shift, Offset);
+ computeAddressOpt(Func, Inst, Base, Index, Shift, Offset);
if (Base && Addr != Base) {
Constant *OffsetOp = Ctx->getConstantInt(IceType_i32, Offset);
Addr = OperandX8632Mem::create(Func, Dest->getType(), Base, OffsetOp, Index,
@@ -3866,7 +3897,7 @@ void TargetX8632::doAddressOptStore() {
// registers there either.
const OperandX8632Mem::SegmentRegisters SegmentReg =
OperandX8632Mem::DefaultSegment;
- computeAddressOpt(Base, Index, Shift, Offset);
+ computeAddressOpt(Func, Inst, Base, Index, Shift, Offset);
if (Base && Addr != Base) {
Constant *OffsetOp = Ctx->getConstantInt(IceType_i32, Offset);
Addr = OperandX8632Mem::create(Func, Data->getType(), Base, OffsetOp, Index,

Powered by Google App Engine
This is Rietveld 408576698