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

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 2078423002: [turbofan] More efficient truncation analysis for add, sub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/type-cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/address-map.h" 9 #include "src/address-map.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 Node* overflow = graph()->NewNode(common()->Projection(1), arith); 1097 Node* overflow = graph()->NewNode(common()->Projection(1), arith);
1098 effect = 1098 effect =
1099 graph()->NewNode(simplified()->CheckIf(), overflow, effect, control); 1099 graph()->NewNode(simplified()->CheckIf(), overflow, effect, control);
1100 Node* value = graph()->NewNode(common()->Projection(0), arith); 1100 Node* value = graph()->NewNode(common()->Projection(0), arith);
1101 ReplaceEffectControlUses(node, effect, control); 1101 ReplaceEffectControlUses(node, effect, control);
1102 DeferReplacement(node, value); 1102 DeferReplacement(node, value);
1103 } 1103 }
1104 1104
1105 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation, 1105 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation,
1106 SimplifiedLowering* lowering) { 1106 SimplifiedLowering* lowering) {
1107 if (BothInputsAre(node, Type::Signed32()) && 1107 if (BothInputsAre(node, type_cache_.kSigned32OrMinusZero) &&
1108 NodeProperties::GetType(node)->Is(Type::Signed32())) { 1108 NodeProperties::GetType(node)->Is(Type::Signed32())) {
1109 // int32 + int32 = int32 ==> signed Int32Add/Sub 1109 // int32 + int32 = int32 ==> signed Int32Add/Sub
1110 VisitInt32Binop(node); 1110 VisitInt32Binop(node);
1111 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1111 if (lower()) ChangeToPureOp(node, Int32Op(node));
1112 return; 1112 return;
1113 } 1113 }
1114 1114
1115 // Use truncation if available. 1115 // Use truncation if available.
1116 if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) && 1116 if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
1117 truncation.TruncatesToWord32()) { 1117 truncation.TruncatesToWord32()) {
1118 // safe-int + safe-int = x (truncated to int32) 1118 // safe-int + safe-int = x (truncated to int32)
1119 // => signed Int32Add/Sub (truncated) 1119 // => signed Int32Add/Sub (truncated)
1120 VisitWord32TruncatingBinop(node); 1120 VisitWord32TruncatingBinop(node);
1121 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1121 if (lower()) ChangeToPureOp(node, Int32Op(node));
1122 return; 1122 return;
1123 } 1123 }
1124 1124
1125 // Try to use type feedback. 1125 // Try to use type feedback.
1126 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); 1126 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
1127 1127
1128 // TODO(jarin) This might not be necessary (covered by the next case). 1128 // Handle the case when no int32 checks on inputs are necessary
1129 // The only real difference is that this one actually treats the 1129 // (but an overflow check is needed on the output).
1130 // inputs as truncated to word32. 1130 if (BothInputsAre(node, Type::Signed32()) ||
1131 if (BothInputsAre(node, Type::Signed32())) { 1131 (BothInputsAre(node, type_cache_.kSigned32OrMinusZero) &&
1132 NodeProperties::GetType(node)->Is(type_cache_.kSafeInteger))) {
1132 // If both the inputs the feedback are int32, use the overflow op. 1133 // If both the inputs the feedback are int32, use the overflow op.
1133 if (hint == BinaryOperationHints::kSignedSmall || 1134 if (hint == BinaryOperationHints::kSignedSmall ||
1134 hint == BinaryOperationHints::kSigned32) { 1135 hint == BinaryOperationHints::kSigned32) {
1135 VisitBinop(node, UseInfo::TruncatingWord32(), 1136 VisitBinop(node, UseInfo::TruncatingWord32(),
1136 MachineRepresentation::kWord32, TypeCheckKind::kSigned32); 1137 MachineRepresentation::kWord32, TypeCheckKind::kSigned32);
1137 if (lower()) { 1138 if (lower()) {
1138 ChangeToInt32OverflowOp(node, Int32OverflowOp(node)); 1139 ChangeToInt32OverflowOp(node, Int32OverflowOp(node));
1139 } 1140 }
1140 return; 1141 return;
1141 } 1142 }
(...skipping 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3034 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3034 Operator::kNoProperties); 3035 Operator::kNoProperties);
3035 to_number_operator_.set(common()->Call(desc)); 3036 to_number_operator_.set(common()->Call(desc));
3036 } 3037 }
3037 return to_number_operator_.get(); 3038 return to_number_operator_.get();
3038 } 3039 }
3039 3040
3040 } // namespace compiler 3041 } // namespace compiler
3041 } // namespace internal 3042 } // namespace internal
3042 } // namespace v8 3043 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/type-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698