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

Unified Diff: src/compiler/instruction.cc

Issue 2410673002: [Turbofan] Add concept of FP register aliasing on ARM 32. (Closed)
Patch Set: Add a TODO. 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
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/move-optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/instruction.cc
diff --git a/src/compiler/instruction.cc b/src/compiler/instruction.cc
index 39ea47689c963e1989c5ba7f92269e08c4c64c3c..174ee300fee63348fbf0791801528d628da2b2a2 100644
--- a/src/compiler/instruction.cc
+++ b/src/compiler/instruction.cc
@@ -64,8 +64,35 @@ 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();
+ int index_lo = index_hi - (1 << ElementSizeLog2Of(rep)) / kPointerSize + 1;
+ int other_index_hi = other_loc.index();
+ int other_index_lo =
+ other_index_hi - (1 << ElementSizeLog2Of(other_rep)) / kPointerSize + 1;
+ return other_index_hi >= index_lo && index_hi >= other_index_lo;
+ }
+ return false;
}
void InstructionOperand::Print(const RegisterConfiguration* config) const {
@@ -232,28 +259,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) {
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/move-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698