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

Unified Diff: src/hydrogen-instructions.cc

Issue 14471034: Better handling of Phi nodes with constant inputs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cleanup as discussed Created 7 years, 8 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/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index d6710a4fa1f43b9311f416c5e5604c46f4322832..5f0cd9d3176e1327269cc5bdfdd6e47cba7372b5 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -2264,7 +2264,8 @@ Representation HBinaryOperation::RepresentationFromInputs() {
void HBinaryOperation::AssumeRepresentation(Representation r) {
- set_observed_input_representation(r, r);
+ set_observed_input_representation(1, r);
+ set_observed_input_representation(2, r);
HValue::AssumeRepresentation(r);
}
@@ -3462,6 +3463,42 @@ void HBitwise::PrintDataTo(StringStream* stream) {
}
+void HPhi::SimplifyConstantInputs() {
+ // Convert constant inputs to integers when all uses are truncating.
+ // This must happen before representation inference takes place.
+ if (!CheckUsesForFlag(kTruncatingToInt32)) return;
+ for (int i = 0; i < OperandCount(); ++i) {
+ if (!OperandAt(i)->IsConstant()) return;
+ }
+ HGraph* graph = block()->graph();
+ for (int i = 0; i < OperandCount(); ++i) {
+ HConstant* operand = HConstant::cast(OperandAt(i));
+ if (operand->HasInteger32Value()) {
+ continue;
+ } else if (operand->HasDoubleValue()) {
+ HConstant* integer_input =
+ new(graph->zone()) HConstant(DoubleToInt32(operand->DoubleValue()),
+ Representation::Integer32());
+ integer_input->InsertAfter(operand);
+ SetOperandAt(i, integer_input);
+ } else if (operand == graph->GetConstantTrue()) {
+ SetOperandAt(i, graph->GetConstant1());
+ } else {
+ // This catches |false|, |undefined|, strings and objects.
+ SetOperandAt(i, graph->GetConstant0());
+ }
+ }
+ // Overwrite observed input representations because they are likely Tagged.
+ for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
+ HValue* use = it.value();
+ if (use->IsBinaryOperation()) {
+ HBinaryOperation::cast(use)->set_observed_input_representation(
+ it.index(), Representation::Integer32());
+ }
+ }
+}
+
+
void HPhi::InferRepresentation(HInferRepresentation* h_infer) {
ASSERT(CheckFlag(kFlexibleRepresentation));
// If there are non-Phi uses, and all of them have observed the same
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698