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

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

Issue 2407153007: [turbofan] Remove Float32 truncation. (Closed)
Patch Set: Created 4 years, 2 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
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"
11 #include "src/compiler/machine-operator.h" 11 #include "src/compiler/machine-operator.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 const char* Truncation::description() const { 17 const char* Truncation::description() const {
18 switch (kind()) { 18 switch (kind()) {
19 case TruncationKind::kNone: 19 case TruncationKind::kNone:
20 return "no-value-use"; 20 return "no-value-use";
21 case TruncationKind::kBool: 21 case TruncationKind::kBool:
22 return "truncate-to-bool"; 22 return "truncate-to-bool";
23 case TruncationKind::kWord32: 23 case TruncationKind::kWord32:
24 return "truncate-to-word32"; 24 return "truncate-to-word32";
25 case TruncationKind::kWord64: 25 case TruncationKind::kWord64:
26 return "truncate-to-word64"; 26 return "truncate-to-word64";
27 case TruncationKind::kFloat32:
28 return "truncate-to-float32";
29 case TruncationKind::kFloat64: 27 case TruncationKind::kFloat64:
30 return "truncate-to-float64"; 28 return "truncate-to-float64";
31 case TruncationKind::kAny: 29 case TruncationKind::kAny:
32 return "no-truncation"; 30 return "no-truncation";
33 } 31 }
34 UNREACHABLE(); 32 UNREACHABLE();
35 return nullptr; 33 return nullptr;
36 } 34 }
37 35
38 36
39 // Partial order for truncations: 37 // Partial order for truncations:
40 // 38 //
41 // kWord64 kAny 39 // kWord64 kAny
42 // ^ ^ 40 // ^ ^
43 // \ | 41 // \ |
44 // \ kFloat64 <--+ 42 // \ kFloat64 <--+
45 // \ ^ ^ | 43 // \ ^ |
46 // \ / | | 44 // \ / |
47 // kWord32 kFloat32 kBool 45 // kWord32 kBool
48 // ^ ^ ^ 46 // ^ ^
49 // \ | / 47 // \ /
50 // \ | / 48 // \ /
51 // \ | / 49 // \ /
52 // \ | / 50 // \ /
53 // \ | / 51 // \ /
54 // kNone 52 // kNone
55 53
56 // static 54 // static
57 Truncation::TruncationKind Truncation::Generalize(TruncationKind rep1, 55 Truncation::TruncationKind Truncation::Generalize(TruncationKind rep1,
58 TruncationKind rep2) { 56 TruncationKind rep2) {
59 if (LessGeneral(rep1, rep2)) return rep2; 57 if (LessGeneral(rep1, rep2)) return rep2;
60 if (LessGeneral(rep2, rep1)) return rep1; 58 if (LessGeneral(rep2, rep1)) return rep1;
61 // Handle the generalization of float64-representable values. 59 // Handle the generalization of float64-representable values.
62 if (LessGeneral(rep1, TruncationKind::kFloat64) && 60 if (LessGeneral(rep1, TruncationKind::kFloat64) &&
63 LessGeneral(rep2, TruncationKind::kFloat64)) { 61 LessGeneral(rep2, TruncationKind::kFloat64)) {
(...skipping 16 matching lines...) Expand all
80 case TruncationKind::kNone: 78 case TruncationKind::kNone:
81 return true; 79 return true;
82 case TruncationKind::kBool: 80 case TruncationKind::kBool:
83 return rep2 == TruncationKind::kBool || rep2 == TruncationKind::kAny; 81 return rep2 == TruncationKind::kBool || rep2 == TruncationKind::kAny;
84 case TruncationKind::kWord32: 82 case TruncationKind::kWord32:
85 return rep2 == TruncationKind::kWord32 || 83 return rep2 == TruncationKind::kWord32 ||
86 rep2 == TruncationKind::kWord64 || 84 rep2 == TruncationKind::kWord64 ||
87 rep2 == TruncationKind::kFloat64 || rep2 == TruncationKind::kAny; 85 rep2 == TruncationKind::kFloat64 || rep2 == TruncationKind::kAny;
88 case TruncationKind::kWord64: 86 case TruncationKind::kWord64:
89 return rep2 == TruncationKind::kWord64; 87 return rep2 == TruncationKind::kWord64;
90 case TruncationKind::kFloat32:
91 return rep2 == TruncationKind::kFloat32 ||
92 rep2 == TruncationKind::kFloat64 || rep2 == TruncationKind::kAny;
93 case TruncationKind::kFloat64: 88 case TruncationKind::kFloat64:
94 return rep2 == TruncationKind::kFloat64 || rep2 == TruncationKind::kAny; 89 return rep2 == TruncationKind::kFloat64 || rep2 == TruncationKind::kAny;
95 case TruncationKind::kAny: 90 case TruncationKind::kAny:
96 return rep2 == TruncationKind::kAny; 91 return rep2 == TruncationKind::kAny;
97 } 92 }
98 UNREACHABLE(); 93 UNREACHABLE();
99 return false; 94 return false;
100 } 95 }
101 96
102 97
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 984 }
990 985
991 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { 986 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
992 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 987 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
993 node); 988 node);
994 } 989 }
995 990
996 } // namespace compiler 991 } // namespace compiler
997 } // namespace internal 992 } // namespace internal
998 } // namespace v8 993 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698