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

Unified Diff: src/compiler/simplified-lowering.cc

Issue 641713002: Smarter representation selection for phis. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index b86837d244c0e880e667a9574b885bbae095d52a..fa044593b7904e2e37cd00ce3656cc432a3e5289 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -273,62 +273,62 @@ class RepresentationSelector {
// Helper for handling phis.
void VisitPhi(Node* node, MachineTypeUnion use,
SimplifiedLowering* lowering) {
- // First, propagate the usage information to inputs of the phi.
- if (!lower()) {
- int values = OperatorProperties::GetValueInputCount(node->op());
- // Propagate {use} of the phi to value inputs, and 0 to control.
- Node::Inputs inputs = node->inputs();
- for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end();
- ++iter, --values) {
- // TODO(titzer): it'd be nice to have distinguished edge kinds here.
- ProcessInput(node, iter.index(), values > 0 ? use : 0);
- }
- }
- // Phis adapt to whatever output representation their uses demand,
- // pushing representation changes to their inputs.
- MachineTypeUnion use_rep = GetUseInfo(node) & kRepMask;
+ // Phis adapt to the output representation their uses demand, pushing
+ // representation changes to their inputs.
Type* upper = NodeProperties::GetBounds(node).upper;
- MachineTypeUnion phi_type = changer_->TypeFromUpperBound(upper);
- MachineTypeUnion rep = 0;
- if (use_rep & kRepTagged) {
- rep = kRepTagged; // Tagged overrides everything.
- } else if (use_rep & kRepFloat32) {
- rep = kRepFloat32;
- } else if (use_rep & kRepFloat64) {
- rep = kRepFloat64;
- } else if (use_rep & kRepWord64) {
- rep = kRepWord64;
- } else if (use_rep & kRepWord32) {
- if (phi_type & kTypeNumber) {
- rep = kRepFloat64;
+ MachineType output = kMachNone;
+ MachineType prop = kMachNone;
Jarin 2014/10/08 15:12:03 How about expanding to {propagate}?
titzer 2014/10/15 11:51:49 Done.
+
+ if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) {
+ // legal = kRepTagged | kRepFloat64 | kRepWord32;
+ if ((use & kRepMask) == kRepTagged) {
+ // only tagged uses.
+ output = kRepTagged;
+ prop = kRepTagged;
+ } else if ((use & kRepMask) == kRepFloat64) {
+ // only float64 uses.
+ output = kRepFloat64;
+ prop = kRepFloat64;
} else {
- rep = kRepWord32;
+ // multiple uses.
+ output = kRepWord32;
+ prop = kRepWord32;
}
- } else if (use_rep & kRepBit) {
- rep = kRepBit;
- } else {
- // There was no representation associated with any of the uses.
- if (phi_type & kTypeAny) {
- rep = kRepTagged;
- } else if (phi_type & kTypeNumber) {
- rep = kRepFloat64;
- } else if (phi_type & kTypeInt64 || phi_type & kTypeUint64) {
- rep = kRepWord64;
- } else if (phi_type & kTypeInt32 || phi_type & kTypeUint32) {
- rep = kRepWord32;
- } else if (phi_type & kTypeBool) {
- rep = kRepBit;
+ } else if (upper->Is(Type::Boolean())) {
+ // legal = kRepTagged | kRepBit;
+ if ((use & kRepMask) == kRepTagged) {
+ // only tagged uses.
+ output = kRepTagged;
+ prop = kRepTagged;
} else {
- UNREACHABLE(); // should have at least a usage type!
+ // multiple uses.
+ output = kRepBit;
+ prop = kRepBit;
}
+ } else if (upper->Is(Type::Number())) {
+ // legal = kRepTagged | kRepFloat64;
+ if ((use & kRepMask) == kRepTagged) {
+ // only tagged uses.
+ output = kRepTagged;
+ prop = kRepTagged;
+ } else {
+ // multiple uses.
+ output = kRepFloat64;
+ prop = kRepFloat64;
+ }
+ } else {
+ // legal = kRepTagged;
+ output = kRepTagged;
+ prop = kRepTagged;
}
- // Preserve the usage type, but set the representation.
- MachineTypeUnion output_type = rep | phi_type;
+
+ MachineType output_type =
+ static_cast<MachineType>(changer_->TypeFromUpperBound(upper) | output);
SetOutput(node, output_type);
- if (lower()) {
- int values = OperatorProperties::GetValueInputCount(node->op());
+ int values = OperatorProperties::GetValueInputCount(node->op());
+ if (lower()) {
// Update the phi operator.
MachineType type = static_cast<MachineType>(output_type);
if (type != OpParameter<MachineType>(node)) {
@@ -342,6 +342,15 @@ class RepresentationSelector {
// TODO(titzer): it'd be nice to have distinguished edge kinds here.
ProcessInput(node, iter.index(), values > 0 ? output_type : 0);
}
+ } else {
+ // Propagate {use} of the phi to value inputs, and 0 to control.
+ Node::Inputs inputs = node->inputs();
+ MachineType use_type = static_cast<MachineType>((use & kTypeMask) | prop);
+ for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end();
+ ++iter, --values) {
+ // TODO(titzer): it'd be nice to have distinguished edge kinds here.
+ ProcessInput(node, iter.index(), values > 0 ? use_type : 0);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698