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

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

Issue 2141953002: [Turbofan]: Add integer multiplication with overflow to typed lowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@multiply
Patch Set: Code comments. Created 4 years, 5 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 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 // => signed Int32Add/Sub (truncated) 1306 // => signed Int32Add/Sub (truncated)
1307 VisitWord32TruncatingBinop(node); 1307 VisitWord32TruncatingBinop(node);
1308 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node)); 1308 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
1309 } else { 1309 } else {
1310 // => Float64Add/Sub 1310 // => Float64Add/Sub
1311 VisitFloat64Binop(node); 1311 VisitFloat64Binop(node);
1312 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node)); 1312 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
1313 } 1313 }
1314 return; 1314 return;
1315 } 1315 }
1316 case IrOpcode::kSpeculativeNumberMultiply: 1316 case IrOpcode::kSpeculativeNumberMultiply: {
1317 case IrOpcode::kNumberMultiply: {
1318 if (BothInputsAre(node, Type::Integral32()) && 1317 if (BothInputsAre(node, Type::Integral32()) &&
1319 (NodeProperties::GetType(node)->Is(Type::Signed32()) || 1318 (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
1320 NodeProperties::GetType(node)->Is(Type::Unsigned32()) || 1319 NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
1321 (truncation.TruncatesToWord32() && 1320 (truncation.TruncatesToWord32() &&
1322 NodeProperties::GetType(node)->Is( 1321 NodeProperties::GetType(node)->Is(
1323 type_cache_.kSafeIntegerOrMinusZero)))) { 1322 type_cache_.kSafeIntegerOrMinusZero)))) {
1324 // Multiply reduces to Int32Mul if the inputs are integers, and 1323 // Multiply reduces to Int32Mul if the inputs are integers, and
1325 // (a) the output is either known to be Signed32, or 1324 // (a) the output is either known to be Signed32, or
1326 // (b) the output is known to be Unsigned32, or 1325 // (b) the output is known to be Unsigned32, or
1327 // (c) the uses are truncating and the result is in the safe 1326 // (c) the uses are truncating and the result is in the safe
1328 // integer range. 1327 // integer range.
1329 VisitWord32TruncatingBinop(node); 1328 VisitWord32TruncatingBinop(node);
1330 if (lower()) ChangeToPureOp(node, Int32Op(node)); 1329 if (lower()) ChangeToPureOp(node, Int32Op(node));
1331 return; 1330 return;
1332 } 1331 }
1332 // Try to use type feedback.
1333 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op());
1334
1335 // Handle the case when no int32 checks on inputs are necessary
1336 // (but an overflow check is needed on the output).
1337 if (BothInputsAre(node, Type::Signed32())) {
1338 // If both the inputs the feedback are int32, use the overflow op.
1339 if (hint == BinaryOperationHints::kSignedSmall ||
1340 hint == BinaryOperationHints::kSigned32) {
1341 VisitBinop(node, UseInfo::TruncatingWord32(),
1342 MachineRepresentation::kWord32, Type::Signed32());
1343 if (lower()) ChangeToInt32OverflowOp(node);
1344 return;
1345 }
1346 }
1347
1348 if (hint == BinaryOperationHints::kSignedSmall ||
1349 hint == BinaryOperationHints::kSigned32) {
1350 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
1351 MachineRepresentation::kWord32, Type::Signed32());
1352 if (lower()) ChangeToInt32OverflowOp(node);
1353 return;
1354 }
1355
1356 // Checked float64 x float64 => float64
1357 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1358 MachineRepresentation::kFloat64, Type::Number());
1359 if (lower()) ChangeToPureOp(node, Float64Op(node));
1360 return;
1361 }
1362 case IrOpcode::kNumberMultiply: {
1363 if (BothInputsAre(node, Type::Integral32()) &&
1364 (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
1365 NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
1366 (truncation.TruncatesToWord32() &&
1367 NodeProperties::GetType(node)->Is(
1368 type_cache_.kSafeIntegerOrMinusZero)))) {
1369 // Multiply reduces to Int32Mul if the inputs are integers, and
1370 // (a) the output is either known to be Signed32, or
1371 // (b) the output is known to be Unsigned32, or
1372 // (c) the uses are truncating and the result is in the safe
1373 // integer range.
1374 VisitWord32TruncatingBinop(node);
1375 if (lower()) ChangeToPureOp(node, Int32Op(node));
1376 return;
1377 }
1333 // Number x Number => Float64Mul 1378 // Number x Number => Float64Mul
1334 if (BothInputsAre(node, Type::NumberOrUndefined())) { 1379 VisitFloat64Binop(node);
1335 VisitFloat64Binop(node);
1336 if (lower()) ChangeToPureOp(node, Float64Op(node));
1337 return;
1338 }
1339 // Checked float64 x float64 => float64
1340 DCHECK_EQ(IrOpcode::kSpeculativeNumberMultiply, node->opcode());
1341 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1342 MachineRepresentation::kFloat64, Type::Number());
1343 if (lower()) ChangeToPureOp(node, Float64Op(node)); 1380 if (lower()) ChangeToPureOp(node, Float64Op(node));
1344 return; 1381 return;
1345 } 1382 }
1346 case IrOpcode::kSpeculativeNumberDivide: { 1383 case IrOpcode::kSpeculativeNumberDivide: {
1347 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) { 1384 if (BothInputsAreUnsigned32(node) && truncation.TruncatesToWord32()) {
1348 // => unsigned Uint32Div 1385 // => unsigned Uint32Div
1349 VisitWord32TruncatingBinop(node); 1386 VisitWord32TruncatingBinop(node);
1350 if (lower()) DeferReplacement(node, lowering->Uint32Div(node)); 1387 if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
1351 return; 1388 return;
1352 } 1389 }
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after
3269 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3306 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3270 Operator::kNoProperties); 3307 Operator::kNoProperties);
3271 to_number_operator_.set(common()->Call(desc)); 3308 to_number_operator_.set(common()->Call(desc));
3272 } 3309 }
3273 return to_number_operator_.get(); 3310 return to_number_operator_.get();
3274 } 3311 }
3275 3312
3276 } // namespace compiler 3313 } // namespace compiler
3277 } // namespace internal 3314 } // namespace internal
3278 } // namespace v8 3315 } // 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