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

Unified Diff: src/compiler/value-numbering-reducer.cc

Issue 2251833002: [turbofan] Only do value numbering when types are compatible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments Created 4 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
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-633497.js » ('j') | test/mjsunit/compiler/regress-633497.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/value-numbering-reducer.cc
diff --git a/src/compiler/value-numbering-reducer.cc b/src/compiler/value-numbering-reducer.cc
index 2746529e9b7a0b7649a4ae85cf30714bdbea0887..4769cb0c8b02fc436f94e1cd241c633fab940b09 100644
--- a/src/compiler/value-numbering-reducer.cc
+++ b/src/compiler/value-numbering-reducer.cc
@@ -132,8 +132,17 @@ Reduction ValueNumberingReducer::Reduce(Node* node) {
Type* entry_type = NodeProperties::GetType(entry);
Type* node_type = NodeProperties::GetType(node);
if (!entry_type->Is(node_type)) {
- NodeProperties::SetType(
- entry, Type::Intersect(entry_type, node_type, graph_zone()));
+ // Ideally, we would set an intersection of {entry_type} and
+ // {node_type} here. However, typing of NumberConstants assigns
+ // different types to constants with the same value (it creates
+ // a fresh heap number), which would make the intersection empty.
+ // To be safe, we use the smaller type if the types are comparable.
+ if (node_type->Is(entry_type)) {
+ NodeProperties::SetType(entry, node_type);
+ } else {
+ // Types are not comparable => do not replace.
+ return NoChange();
+ }
}
}
return Replace(entry);
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-633497.js » ('j') | test/mjsunit/compiler/regress-633497.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698