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

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

Issue 2035383003: [turbofan] Type feedback for numeric comparisons. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase, pure ops 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 | « src/compiler/representation-change.cc ('k') | src/compiler/simplified-operator.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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1033 }
1034 } 1034 }
1035 1035
1036 void ChangeToInt32OverflowOp(Node* node, const Operator* op) { 1036 void ChangeToInt32OverflowOp(Node* node, const Operator* op) {
1037 Node* effect = NodeProperties::GetEffectInput(node); 1037 Node* effect = NodeProperties::GetEffectInput(node);
1038 Node* control = NodeProperties::GetControlInput(node); 1038 Node* control = NodeProperties::GetControlInput(node);
1039 Node* arith = graph()->NewNode(op, node->InputAt(0), node->InputAt(1)); 1039 Node* arith = graph()->NewNode(op, node->InputAt(0), node->InputAt(1));
1040 Node* overflow = graph()->NewNode(common()->Projection(1), arith); 1040 Node* overflow = graph()->NewNode(common()->Projection(1), arith);
1041 effect = 1041 effect =
1042 graph()->NewNode(simplified()->CheckIf(), overflow, effect, control); 1042 graph()->NewNode(simplified()->CheckIf(), overflow, effect, control);
1043
1044 Node* value = graph()->NewNode(common()->Projection(0), arith); 1043 Node* value = graph()->NewNode(common()->Projection(0), arith);
1045 ReplaceEffectControlUses(node, effect, control); 1044 ReplaceEffectControlUses(node, effect, control);
1046 DeferReplacement(node, value); 1045 DeferReplacement(node, value);
1047 } 1046 }
1048 1047
1049 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation, 1048 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation,
1050 SimplifiedLowering* lowering) { 1049 SimplifiedLowering* lowering) {
1051 if (BothInputsAre(node, Type::Signed32()) && 1050 if (BothInputsAre(node, Type::Signed32()) &&
1052 NodeProperties::GetType(node)->Is(Type::Signed32())) { 1051 NodeProperties::GetType(node)->Is(Type::Signed32())) {
1053 // int32 + int32 = int32 ==> signed Int32Add/Sub 1052 // int32 + int32 = int32 ==> signed Int32Add/Sub
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 // No input representation requirement; adapt during lowering. 1211 // No input representation requirement; adapt during lowering.
1213 ProcessInput(node, 0, UseInfo::AnyTruncatingToBool()); 1212 ProcessInput(node, 0, UseInfo::AnyTruncatingToBool());
1214 SetOutput(node, MachineRepresentation::kWord32); 1213 SetOutput(node, MachineRepresentation::kWord32);
1215 } 1214 }
1216 return; 1215 return;
1217 } 1216 }
1218 case IrOpcode::kNumberEqual: 1217 case IrOpcode::kNumberEqual:
1219 case IrOpcode::kNumberLessThan: 1218 case IrOpcode::kNumberLessThan:
1220 case IrOpcode::kNumberLessThanOrEqual: { 1219 case IrOpcode::kNumberLessThanOrEqual: {
1221 // Number comparisons reduce to integer comparisons for integer inputs. 1220 // Number comparisons reduce to integer comparisons for integer inputs.
1222 if (BothInputsAreSigned32(node)) { 1221 if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
1222 TypeOf(node->InputAt(1))->Is(Type::Signed32())) {
1223 // => signed Int32Cmp 1223 // => signed Int32Cmp
1224 VisitInt32Cmp(node); 1224 VisitInt32Cmp(node);
1225 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); 1225 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
1226 } else if (BothInputsAreUnsigned32(node)) { 1226 } else if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
1227 TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) {
1227 // => unsigned Int32Cmp 1228 // => unsigned Int32Cmp
1228 VisitUint32Cmp(node); 1229 VisitUint32Cmp(node);
1229 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node)); 1230 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
1230 } else { 1231 } else {
1231 // => Float64Cmp 1232 // => Float64Cmp
1232 VisitFloat64Cmp(node); 1233 VisitFloat64Cmp(node);
1233 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); 1234 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
1234 } 1235 }
1235 return; 1236 return;
1236 } 1237 }
1237 1238
1238 case IrOpcode::kSpeculativeNumberAdd: 1239 case IrOpcode::kSpeculativeNumberAdd:
1239 case IrOpcode::kSpeculativeNumberSubtract: 1240 case IrOpcode::kSpeculativeNumberSubtract:
1240 return VisitSpeculativeAdditiveOp(node, truncation, lowering); 1241 return VisitSpeculativeAdditiveOp(node, truncation, lowering);
1241 1242
1243 case IrOpcode::kSpeculativeNumberLessThan:
1244 case IrOpcode::kSpeculativeNumberLessThanOrEqual:
1245 case IrOpcode::kSpeculativeNumberEqual: {
1246 // Number comparisons reduce to integer comparisons for integer inputs.
1247 if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
1248 TypeOf(node->InputAt(1))->Is(Type::Signed32())) {
1249 // => signed Int32Cmp
1250 VisitInt32Cmp(node);
1251 if (lower()) ChangeToPureOp(node, Int32Op(node));
1252 return;
1253 } else if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
1254 TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) {
1255 // => unsigned Int32Cmp
1256 VisitUint32Cmp(node);
1257 if (lower()) ChangeToPureOp(node, Uint32Op(node));
1258 return;
1259 }
1260 // Try to use type feedback.
1261 CompareOperationHints::Hint hint = CompareOperationHintOf(node->op());
1262
1263 if (hint == CompareOperationHints::kSignedSmall) {
1264 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1265 MachineRepresentation::kBit);
1266 if (lower()) ChangeToPureOp(node, Int32Op(node));
1267 return;
1268 }
1269 DCHECK_EQ(CompareOperationHints::kNumber, hint);
1270 // default case => Float64 comparison
1271 VisitBinop(node, UseInfo::CheckedNumberOrUndefinedAsFloat64(),
1272 MachineRepresentation::kBit);
1273 if (lower()) ChangeToPureOp(node, Float64Op(node));
1274 return;
1275 }
1276
1242 case IrOpcode::kNumberAdd: 1277 case IrOpcode::kNumberAdd:
1243 case IrOpcode::kNumberSubtract: { 1278 case IrOpcode::kNumberSubtract: {
1244 if (BothInputsAre(node, Type::Signed32()) && 1279 if (BothInputsAre(node, Type::Signed32()) &&
1245 NodeProperties::GetType(node)->Is(Type::Signed32())) { 1280 NodeProperties::GetType(node)->Is(Type::Signed32())) {
1246 // int32 + int32 = int32 1281 // int32 + int32 = int32
1247 // => signed Int32Add/Sub 1282 // => signed Int32Add/Sub
1248 VisitInt32Binop(node); 1283 VisitInt32Binop(node);
1249 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); 1284 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
1250 } else if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) && 1285 } else if (BothInputsAre(node, type_cache_.kAdditiveSafeInteger) &&
1251 truncation.TruncatesToWord32()) { 1286 truncation.TruncatesToWord32()) {
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 2922 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
2888 Operator::kNoProperties); 2923 Operator::kNoProperties);
2889 to_number_operator_.set(common()->Call(desc)); 2924 to_number_operator_.set(common()->Call(desc));
2890 } 2925 }
2891 return to_number_operator_.get(); 2926 return to_number_operator_.get();
2892 } 2927 }
2893 2928
2894 } // namespace compiler 2929 } // namespace compiler
2895 } // namespace internal 2930 } // namespace internal
2896 } // namespace v8 2931 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/representation-change.cc ('k') | src/compiler/simplified-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698