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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/representation-change.cc
diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc
index d05fa19a4d988fd86d2b5b869c6eb891a97f5275..9b8c193d45969bb632335d609bba371648828671 100644
--- a/src/compiler/representation-change.cc
+++ b/src/compiler/representation-change.cc
@@ -368,19 +368,30 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
Node* node, MachineRepresentation output_rep, Type* output_type,
Node* use_node, UseInfo use_info) {
// Eagerly fold representation changes for constants.
- // TODO(jarin) Properly fold constants in presence of type check.
- if (use_info.type_check() == TypeCheckKind::kNone) {
- switch (node->opcode()) {
- case IrOpcode::kInt32Constant:
- return node; // No change necessary.
- case IrOpcode::kFloat32Constant:
- return MakeTruncatedInt32Constant(OpParameter<float>(node));
- case IrOpcode::kNumberConstant:
- case IrOpcode::kFloat64Constant:
- return MakeTruncatedInt32Constant(OpParameter<double>(node));
- default:
- break;
+ switch (node->opcode()) {
+ case IrOpcode::kInt32Constant:
+ return node; // No change necessary.
+ case IrOpcode::kFloat32Constant: {
+ float const fv = OpParameter<float>(node);
+ if (use_info.type_check() == TypeCheckKind::kNone ||
+ (use_info.type_check() == TypeCheckKind::kSigned32 &&
+ IsInt32Double(fv))) {
+ return MakeTruncatedInt32Constant(fv);
+ }
+ break;
}
+ case IrOpcode::kNumberConstant:
+ case IrOpcode::kFloat64Constant: {
+ double const fv = OpParameter<double>(node);
+ if (use_info.type_check() == TypeCheckKind::kNone ||
+ (use_info.type_check() == TypeCheckKind::kSigned32 &&
+ IsInt32Double(fv))) {
+ return MakeTruncatedInt32Constant(fv);
+ }
+ break;
+ }
+ default:
+ break;
}
// Select the correct X -> Word32 operator.
« 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