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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 2894563002: [turbofan] Eliminate empty string addition. (Closed)
Patch Set: Created 3 years, 7 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/js-typed-lowering.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 02463ae5837318d5bc41000c41c269cdb679517c..64838a1f839c8d2d2d1ba4c8fb55a298c8b0b563 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -488,13 +488,13 @@ JSTypedLowering::JSTypedLowering(Editor* editor,
dependencies_(dependencies),
flags_(flags),
jsgraph_(jsgraph),
- pointer_comparable_type_(Type::Union(
- Type::Oddball(),
- Type::Union(
- Type::SymbolOrReceiver(),
- Type::HeapConstant(factory()->empty_string(), graph()->zone()),
- graph()->zone()),
- graph()->zone())),
+ empty_string_type_(
+ Type::HeapConstant(factory()->empty_string(), graph()->zone())),
+ pointer_comparable_type_(
+ Type::Union(Type::Oddball(),
+ Type::Union(Type::SymbolOrReceiver(), empty_string_type_,
+ graph()->zone()),
+ graph()->zone())),
type_cache_(TypeCache::Get()) {
for (size_t k = 0; k < arraysize(shifted_int32_ranges_); ++k) {
double min = kMinInt / (1 << k);
@@ -535,6 +535,23 @@ Reduction JSTypedLowering::ReduceJSAdd(Node* node) {
if (r.ShouldCreateConsString()) {
return ReduceCreateConsString(node);
}
+ // Eliminate useless concatenation of empty string.
+ if ((flags() & kDeoptimizationEnabled) &&
+ BinaryOperationHintOf(node->op()) == BinaryOperationHint::kString) {
+ Node* effect = NodeProperties::GetEffectInput(node);
+ Node* control = NodeProperties::GetControlInput(node);
+ if (r.LeftInputIs(empty_string_type_)) {
+ Node* value = effect = graph()->NewNode(simplified()->CheckString(),
+ r.right(), effect, control);
+ ReplaceWithValue(node, value, effect, control);
+ return Replace(value);
+ } else if (r.RightInputIs(empty_string_type_)) {
+ Node* value = effect = graph()->NewNode(simplified()->CheckString(),
+ r.left(), effect, control);
+ ReplaceWithValue(node, value, effect, control);
+ return Replace(value);
+ }
+ }
StringAddFlags flags = STRING_ADD_CHECK_NONE;
if (!r.LeftInputIs(Type::String())) {
flags = STRING_ADD_CONVERT_LEFT;
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698