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

Side by Side Diff: src/compiler/representation-change.cc

Issue 2100063002: [turbofan] Fold word32 representation changes for checked constants. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/representation-change.h" 5 #include "src/compiler/representation-change.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 361 }
362 362
363 Node* RepresentationChanger::MakeTruncatedInt32Constant(double value) { 363 Node* RepresentationChanger::MakeTruncatedInt32Constant(double value) {
364 return jsgraph()->Int32Constant(DoubleToInt32(value)); 364 return jsgraph()->Int32Constant(DoubleToInt32(value));
365 } 365 }
366 366
367 Node* RepresentationChanger::GetWord32RepresentationFor( 367 Node* RepresentationChanger::GetWord32RepresentationFor(
368 Node* node, MachineRepresentation output_rep, Type* output_type, 368 Node* node, MachineRepresentation output_rep, Type* output_type,
369 Node* use_node, UseInfo use_info) { 369 Node* use_node, UseInfo use_info) {
370 // Eagerly fold representation changes for constants. 370 // Eagerly fold representation changes for constants.
371 // TODO(jarin) Properly fold constants in presence of type check. 371 switch (node->opcode()) {
372 if (use_info.type_check() == TypeCheckKind::kNone) { 372 case IrOpcode::kInt32Constant:
373 switch (node->opcode()) { 373 return node; // No change necessary.
374 case IrOpcode::kInt32Constant: 374 case IrOpcode::kFloat32Constant: {
375 return node; // No change necessary. 375 float const fv = OpParameter<float>(node);
376 case IrOpcode::kFloat32Constant: 376 if (use_info.type_check() == TypeCheckKind::kNone ||
377 return MakeTruncatedInt32Constant(OpParameter<float>(node)); 377 (use_info.type_check() == TypeCheckKind::kSigned32 &&
378 case IrOpcode::kNumberConstant: 378 IsInt32Double(fv))) {
379 case IrOpcode::kFloat64Constant: 379 return MakeTruncatedInt32Constant(fv);
380 return MakeTruncatedInt32Constant(OpParameter<double>(node)); 380 }
381 default: 381 break;
382 break;
383 } 382 }
383 case IrOpcode::kNumberConstant:
384 case IrOpcode::kFloat64Constant: {
385 double const fv = OpParameter<double>(node);
386 if (use_info.type_check() == TypeCheckKind::kNone ||
387 (use_info.type_check() == TypeCheckKind::kSigned32 &&
388 IsInt32Double(fv))) {
389 return MakeTruncatedInt32Constant(fv);
390 }
391 break;
392 }
393 default:
394 break;
384 } 395 }
385 396
386 // Select the correct X -> Word32 operator. 397 // Select the correct X -> Word32 operator.
387 const Operator* op = nullptr; 398 const Operator* op = nullptr;
388 if (output_rep == MachineRepresentation::kBit) { 399 if (output_rep == MachineRepresentation::kBit) {
389 return node; // Sloppy comparison -> word32 400 return node; // Sloppy comparison -> word32
390 } else if (output_rep == MachineRepresentation::kFloat64) { 401 } else if (output_rep == MachineRepresentation::kFloat64) {
391 if (output_type->Is(Type::Unsigned32())) { 402 if (output_type->Is(Type::Unsigned32())) {
392 op = machine()->ChangeFloat64ToUint32(); 403 op = machine()->ChangeFloat64ToUint32();
393 } else if (output_type->Is(Type::Signed32())) { 404 } else if (output_type->Is(Type::Signed32())) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 768 }
758 769
759 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { 770 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
760 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 771 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
761 node); 772 node);
762 } 773 }
763 774
764 } // namespace compiler 775 } // namespace compiler
765 } // namespace internal 776 } // namespace internal
766 } // namespace v8 777 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698