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

Unified Diff: src/compiler/instruction.cc

Issue 2410673002: [Turbofan] Add concept of FP register aliasing on ARM 32. (Closed)
Patch Set: Move helper fn / macro into OperandSet class. Created 4 years, 2 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/compiler/instruction.cc
diff --git a/src/compiler/instruction.cc b/src/compiler/instruction.cc
index 39ea47689c963e1989c5ba7f92269e08c4c64c3c..42527c1636092d01df8f2ec296052f8d6fb5f502 100644
--- a/src/compiler/instruction.cc
+++ b/src/compiler/instruction.cc
@@ -64,8 +64,36 @@ FlagsCondition CommuteFlagsCondition(FlagsCondition condition) {
return condition;
}
-bool InstructionOperand::InterferesWith(const InstructionOperand& that) const {
- return EqualsCanonicalized(that);
+bool InstructionOperand::InterferesWith(const InstructionOperand& other) const {
+ if (kSimpleFPAliasing || !this->IsFPLocationOperand() ||
+ !other.IsFPLocationOperand())
+ return EqualsCanonicalized(other);
+ // Aliasing is complex and both operands are fp locations.
+ const LocationOperand& loc = *LocationOperand::cast(this);
+ const LocationOperand& other_loc = LocationOperand::cast(other);
+ LocationOperand::LocationKind kind = loc.location_kind();
+ LocationOperand::LocationKind other_kind = other_loc.location_kind();
+ if (kind != other_kind) return false;
+ MachineRepresentation rep = loc.representation();
+ MachineRepresentation other_rep = other_loc.representation();
+ if (rep == other_rep) return EqualsCanonicalized(other);
+ if (kind == LocationOperand::REGISTER) {
+ // FP register-register interference.
+ return GetRegConfig()->AreAliases(rep, loc.register_code(), other_rep,
+ other_loc.register_code());
+ } else {
+ // FP slot-slot interference. Slots of different FP reps can alias because
+ // the gap resolver may break a move into 2 or 4 equivalent smaller moves.
+ DCHECK_EQ(LocationOperand::STACK_SLOT, kind);
+ int index_hi = loc.index();
+ const int kBaseRep = static_cast<int>(MachineRepresentation::kFloat32);
+ int index_lo = index_hi - (1 << (static_cast<int>(rep) - kBaseRep)) + 1;
Jarin 2016/10/18 11:44:28 Could we express this in terms of ElementSizeLog2O
bbudge 2016/10/19 00:32:21 Done. (both places)
+ int other_index_hi = other_loc.index();
+ int other_index_lo =
+ other_index_hi - (1 << (static_cast<int>(other_rep) - kBaseRep)) + 1;
+ return !(other_index_hi < index_lo || index_hi < other_index_lo);
bbudge 2016/10/19 00:32:21 I also De-morgan'ed this boolean expression.
+ }
+ return false;
}
void InstructionOperand::Print(const RegisterConfiguration* config) const {
@@ -232,28 +260,31 @@ bool ParallelMove::IsRedundant() const {
return true;
}
-
-MoveOperands* ParallelMove::PrepareInsertAfter(MoveOperands* move) const {
+void ParallelMove::PrepareInsertAfter(
+ MoveOperands* move, ZoneVector<MoveOperands*>* to_eliminate) const {
+ bool no_aliasing =
+ kSimpleFPAliasing || !move->destination().IsFPLocationOperand();
MoveOperands* replacement = nullptr;
- MoveOperands* to_eliminate = nullptr;
+ MoveOperands* eliminated = nullptr;
for (MoveOperands* curr : *this) {
if (curr->IsEliminated()) continue;
if (curr->destination().EqualsCanonicalized(move->source())) {
+ // We must replace move's source with curr's destination in order to
+ // insert it into this ParallelMove.
DCHECK(!replacement);
replacement = curr;
- if (to_eliminate != nullptr) break;
- } else if (curr->destination().EqualsCanonicalized(move->destination())) {
- DCHECK(!to_eliminate);
- to_eliminate = curr;
- if (replacement != nullptr) break;
+ if (no_aliasing && eliminated != nullptr) break;
+ } else if (curr->destination().InterferesWith(move->destination())) {
+ // We can eliminate curr, since move overwrites at least a part of its
+ // destination, implying its value is no longer live.
+ eliminated = curr;
+ to_eliminate->push_back(curr);
+ if (no_aliasing && replacement != nullptr) break;
}
}
- DCHECK_IMPLIES(replacement == to_eliminate, replacement == nullptr);
if (replacement != nullptr) move->set_source(replacement->source());
- return to_eliminate;
}
-
ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep,
int index)
: LocationOperand(EXPLICIT, kind, rep, index) {

Powered by Google App Engine
This is Rietveld 408576698