OLD | NEW |
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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 #include "src/compiler/change-lowering.h" | 6 #include "src/compiler/change-lowering.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
11 #include "test/unittests/compiler/compiler-test-utils.h" | 11 #include "test/unittests/compiler/compiler-test-utils.h" |
12 #include "test/unittests/compiler/graph-unittest.h" | 12 #include "test/unittests/compiler/graph-unittest.h" |
13 #include "test/unittests/compiler/node-test-utils.h" | 13 #include "test/unittests/compiler/node-test-utils.h" |
14 #include "testing/gmock-support.h" | 14 #include "testing/gmock-support.h" |
15 | 15 |
16 using testing::_; | 16 using testing::_; |
17 using testing::AllOf; | 17 using testing::AllOf; |
18 using testing::BitEq; | 18 using testing::BitEq; |
19 using testing::Capture; | 19 using testing::Capture; |
20 using testing::CaptureEq; | 20 using testing::CaptureEq; |
21 | 21 |
22 namespace v8 { | 22 namespace v8 { |
23 namespace internal { | 23 namespace internal { |
24 namespace compiler { | 24 namespace compiler { |
25 | 25 |
26 class ChangeLoweringTest : public TypedGraphTest { | 26 class ChangeLoweringTest : public TypedGraphTest { |
27 public: | 27 public: |
28 ChangeLoweringTest() : simplified_(zone()) {} | 28 ChangeLoweringTest() : simplified_(zone()) {} |
29 | 29 |
30 virtual MachineType WordRepresentation() const = 0; | 30 virtual MachineRepresentation WordRepresentation() const = 0; |
31 | 31 |
32 protected: | 32 protected: |
33 bool Is32() const { return WordRepresentation() == kRepWord32; } | 33 bool Is32() const { |
34 bool Is64() const { return WordRepresentation() == kRepWord64; } | 34 return WordRepresentation() == MachineRepresentation::kWord32; |
| 35 } |
| 36 bool Is64() const { |
| 37 return WordRepresentation() == MachineRepresentation::kWord64; |
| 38 } |
35 | 39 |
36 Reduction Reduce(Node* node) { | 40 Reduction Reduce(Node* node) { |
37 MachineOperatorBuilder machine(zone(), WordRepresentation()); | 41 MachineOperatorBuilder machine(zone(), WordRepresentation()); |
38 JSOperatorBuilder javascript(zone()); | 42 JSOperatorBuilder javascript(zone()); |
39 JSGraph jsgraph(isolate(), graph(), common(), &javascript, nullptr, | 43 JSGraph jsgraph(isolate(), graph(), common(), &javascript, nullptr, |
40 &machine); | 44 &machine); |
41 ChangeLowering reducer(&jsgraph); | 45 ChangeLowering reducer(&jsgraph); |
42 return reducer.Reduce(node); | 46 return reducer.Reduce(node); |
43 } | 47 } |
44 | 48 |
(...skipping 15 matching lines...) Expand all Loading... |
60 IsWord64Sar(value_matcher, IsSmiShiftBitsConstant())) | 64 IsWord64Sar(value_matcher, IsSmiShiftBitsConstant())) |
61 : IsWord32Sar(value_matcher, IsSmiShiftBitsConstant()); | 65 : IsWord32Sar(value_matcher, IsSmiShiftBitsConstant()); |
62 } | 66 } |
63 Matcher<Node*> IsChangeUint32ToSmi(const Matcher<Node*>& value_matcher) { | 67 Matcher<Node*> IsChangeUint32ToSmi(const Matcher<Node*>& value_matcher) { |
64 return Is64() ? IsWord64Shl(IsChangeUint32ToUint64(value_matcher), | 68 return Is64() ? IsWord64Shl(IsChangeUint32ToUint64(value_matcher), |
65 IsSmiShiftBitsConstant()) | 69 IsSmiShiftBitsConstant()) |
66 : IsWord32Shl(value_matcher, IsSmiShiftBitsConstant()); | 70 : IsWord32Shl(value_matcher, IsSmiShiftBitsConstant()); |
67 } | 71 } |
68 Matcher<Node*> IsLoadHeapNumber(const Matcher<Node*>& value_matcher, | 72 Matcher<Node*> IsLoadHeapNumber(const Matcher<Node*>& value_matcher, |
69 const Matcher<Node*>& control_matcher) { | 73 const Matcher<Node*>& control_matcher) { |
70 return IsLoad(kMachFloat64, value_matcher, | 74 return IsLoad(MachineType::Float64(), value_matcher, |
71 IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), | 75 IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), |
72 graph()->start(), control_matcher); | 76 graph()->start(), control_matcher); |
73 } | 77 } |
74 Matcher<Node*> IsIntPtrConstant(int value) { | 78 Matcher<Node*> IsIntPtrConstant(int value) { |
75 return Is32() ? IsInt32Constant(value) : IsInt64Constant(value); | 79 return Is32() ? IsInt32Constant(value) : IsInt64Constant(value); |
76 } | 80 } |
77 Matcher<Node*> IsSmiShiftBitsConstant() { | 81 Matcher<Node*> IsSmiShiftBitsConstant() { |
78 return IsIntPtrConstant(kSmiShiftSize + kSmiTagSize); | 82 return IsIntPtrConstant(kSmiShiftSize + kSmiTagSize); |
79 } | 83 } |
80 Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher, | 84 Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher, |
81 const Matcher<Node*>& rhs_matcher) { | 85 const Matcher<Node*>& rhs_matcher) { |
82 return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher) | 86 return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher) |
83 : IsWord64Equal(lhs_matcher, rhs_matcher); | 87 : IsWord64Equal(lhs_matcher, rhs_matcher); |
84 } | 88 } |
85 | 89 |
86 private: | 90 private: |
87 SimplifiedOperatorBuilder simplified_; | 91 SimplifiedOperatorBuilder simplified_; |
88 }; | 92 }; |
89 | 93 |
90 | 94 |
91 // ----------------------------------------------------------------------------- | 95 // ----------------------------------------------------------------------------- |
92 // Common. | 96 // Common. |
93 | 97 |
94 | 98 |
95 class ChangeLoweringCommonTest | 99 class ChangeLoweringCommonTest |
96 : public ChangeLoweringTest, | 100 : public ChangeLoweringTest, |
97 public ::testing::WithParamInterface<MachineType> { | 101 public ::testing::WithParamInterface<MachineRepresentation> { |
98 public: | 102 public: |
99 ~ChangeLoweringCommonTest() override {} | 103 ~ChangeLoweringCommonTest() override {} |
100 | 104 |
101 MachineType WordRepresentation() const final { return GetParam(); } | 105 MachineRepresentation WordRepresentation() const final { return GetParam(); } |
102 }; | 106 }; |
103 | 107 |
104 | 108 |
105 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { | 109 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) { |
106 Node* value = Parameter(Type::Boolean()); | 110 Node* value = Parameter(Type::Boolean()); |
107 Reduction r = | 111 Reduction r = |
108 Reduce(graph()->NewNode(simplified()->ChangeBitToBool(), value)); | 112 Reduce(graph()->NewNode(simplified()->ChangeBitToBool(), value)); |
109 ASSERT_TRUE(r.Changed()); | 113 ASSERT_TRUE(r.Changed()); |
110 EXPECT_THAT(r.replacement(), IsSelect(kMachAnyTagged, value, IsTrueConstant(), | 114 EXPECT_THAT(r.replacement(), IsSelect(MachineRepresentation::kTagged, value, |
111 IsFalseConstant())); | 115 IsTrueConstant(), IsFalseConstant())); |
112 } | 116 } |
113 | 117 |
114 | 118 |
115 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) { | 119 TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) { |
116 Node* value = Parameter(Type::Number()); | 120 Node* value = Parameter(Type::Number()); |
117 Reduction r = | 121 Reduction r = |
118 Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), value)); | 122 Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), value)); |
119 ASSERT_TRUE(r.Changed()); | 123 ASSERT_TRUE(r.Changed()); |
120 EXPECT_THAT(r.replacement(), IsWordEqual(value, IsTrueConstant())); | 124 EXPECT_THAT(r.replacement(), IsWordEqual(value, IsTrueConstant())); |
121 } | 125 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 Reduction r = | 176 Reduction r = |
173 Reduce(graph()->NewNode(simplified()->ChangeTaggedToUint32(), value)); | 177 Reduce(graph()->NewNode(simplified()->ChangeTaggedToUint32(), value)); |
174 ASSERT_TRUE(r.Changed()); | 178 ASSERT_TRUE(r.Changed()); |
175 EXPECT_THAT(r.replacement(), IsChangeFloat64ToUint32( | 179 EXPECT_THAT(r.replacement(), IsChangeFloat64ToUint32( |
176 IsLoadHeapNumber(value, graph()->start()))); | 180 IsLoadHeapNumber(value, graph()->start()))); |
177 } | 181 } |
178 | 182 |
179 | 183 |
180 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) { | 184 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) { |
181 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 185 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
182 Handle<Name>::null(), Type::Any(), kMachAnyTagged}; | 186 Handle<Name>::null(), Type::Any(), |
| 187 MachineType::AnyTagged()}; |
183 Node* p0 = Parameter(Type::TaggedPointer()); | 188 Node* p0 = Parameter(Type::TaggedPointer()); |
184 Node* p1 = Parameter(Type::TaggedSigned()); | 189 Node* p1 = Parameter(Type::TaggedSigned()); |
185 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, | 190 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, |
186 graph()->start(), graph()->start()); | 191 graph()->start(), graph()->start()); |
187 Reduction r = Reduce(store); | 192 Reduction r = Reduce(store); |
188 | 193 |
189 ASSERT_TRUE(r.Changed()); | 194 ASSERT_TRUE(r.Changed()); |
190 EXPECT_THAT(r.replacement(), | 195 EXPECT_THAT( |
191 IsStore(StoreRepresentation(kMachAnyTagged, kNoWriteBarrier), p0, | 196 r.replacement(), |
192 IsIntPtrConstant(access.offset - access.tag()), p1, | 197 IsStore(StoreRepresentation(MachineType::AnyTagged(), kNoWriteBarrier), |
193 graph()->start(), graph()->start())); | 198 p0, IsIntPtrConstant(access.offset - access.tag()), p1, |
| 199 graph()->start(), graph()->start())); |
194 } | 200 } |
195 | 201 |
196 | 202 |
197 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) { | 203 TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) { |
198 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 204 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
199 Handle<Name>::null(), Type::Any(), kMachAnyTagged}; | 205 Handle<Name>::null(), Type::Any(), |
| 206 MachineType::AnyTagged()}; |
200 Node* p0 = Parameter(Type::TaggedPointer()); | 207 Node* p0 = Parameter(Type::TaggedPointer()); |
201 Node* p1 = Parameter(Type::Tagged()); | 208 Node* p1 = Parameter(Type::Tagged()); |
202 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, | 209 Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1, |
203 graph()->start(), graph()->start()); | 210 graph()->start(), graph()->start()); |
204 Reduction r = Reduce(store); | 211 Reduction r = Reduce(store); |
205 | 212 |
206 ASSERT_TRUE(r.Changed()); | 213 ASSERT_TRUE(r.Changed()); |
207 EXPECT_THAT(r.replacement(), | 214 EXPECT_THAT( |
208 IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), | 215 r.replacement(), |
209 p0, IsIntPtrConstant(access.offset - access.tag()), p1, | 216 IsStore(StoreRepresentation(MachineType::AnyTagged(), kFullWriteBarrier), |
210 graph()->start(), graph()->start())); | 217 p0, IsIntPtrConstant(access.offset - access.tag()), p1, |
| 218 graph()->start(), graph()->start())); |
211 } | 219 } |
212 | 220 |
213 | 221 |
214 TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) { | 222 TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) { |
215 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 223 FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
216 Handle<Name>::null(), Type::Any(), kMachAnyTagged}; | 224 Handle<Name>::null(), Type::Any(), |
| 225 MachineType::AnyTagged()}; |
217 Node* p0 = Parameter(Type::TaggedPointer()); | 226 Node* p0 = Parameter(Type::TaggedPointer()); |
218 Node* load = graph()->NewNode(simplified()->LoadField(access), p0, | 227 Node* load = graph()->NewNode(simplified()->LoadField(access), p0, |
219 graph()->start(), graph()->start()); | 228 graph()->start(), graph()->start()); |
220 Reduction r = Reduce(load); | 229 Reduction r = Reduce(load); |
221 | 230 |
222 ASSERT_TRUE(r.Changed()); | 231 ASSERT_TRUE(r.Changed()); |
223 Matcher<Node*> index_match = IsIntPtrConstant(access.offset - access.tag()); | 232 Matcher<Node*> index_match = IsIntPtrConstant(access.offset - access.tag()); |
224 EXPECT_THAT( | 233 EXPECT_THAT(r.replacement(), |
225 r.replacement(), | 234 IsLoad(MachineType::AnyTagged(), p0, |
226 IsLoad(kMachAnyTagged, p0, IsIntPtrConstant(access.offset - access.tag()), | 235 IsIntPtrConstant(access.offset - access.tag()), |
227 graph()->start(), graph()->start())); | 236 graph()->start(), graph()->start())); |
228 } | 237 } |
229 | 238 |
230 | 239 |
231 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) { | 240 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) { |
232 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), | 241 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), |
233 kMachAnyTagged}; | 242 MachineType::AnyTagged()}; |
234 Node* p0 = Parameter(Type::TaggedPointer()); | 243 Node* p0 = Parameter(Type::TaggedPointer()); |
235 Node* p1 = Parameter(Type::Signed32()); | 244 Node* p1 = Parameter(Type::Signed32()); |
236 Node* p2 = Parameter(Type::Tagged()); | 245 Node* p2 = Parameter(Type::Tagged()); |
237 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2, | 246 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2, |
238 graph()->start(), graph()->start()); | 247 graph()->start(), graph()->start()); |
239 Reduction r = Reduce(store); | 248 Reduction r = Reduce(store); |
240 | 249 |
241 const int element_size_shift = ElementSizeLog2Of(access.machine_type); | 250 const int element_size_shift = |
| 251 ElementSizeLog2Of(access.machine_type.representation()); |
242 ASSERT_TRUE(r.Changed()); | 252 ASSERT_TRUE(r.Changed()); |
243 Matcher<Node*> index_match = | 253 Matcher<Node*> index_match = |
244 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), | 254 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), |
245 IsInt32Constant(access.header_size - access.tag())); | 255 IsInt32Constant(access.header_size - access.tag())); |
246 if (!Is32()) { | 256 if (!Is32()) { |
247 index_match = IsChangeUint32ToUint64(index_match); | 257 index_match = IsChangeUint32ToUint64(index_match); |
248 } | 258 } |
249 | 259 |
250 EXPECT_THAT(r.replacement(), | 260 EXPECT_THAT( |
251 IsStore(StoreRepresentation(kMachAnyTagged, kFullWriteBarrier), | 261 r.replacement(), |
252 p0, index_match, p2, graph()->start(), graph()->start())); | 262 IsStore(StoreRepresentation(MachineType::AnyTagged(), kFullWriteBarrier), |
| 263 p0, index_match, p2, graph()->start(), graph()->start())); |
253 } | 264 } |
254 | 265 |
255 | 266 |
256 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) { | 267 TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) { |
257 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 268 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
258 Type::Signed32(), kMachUint8}; | 269 Type::Signed32(), MachineType::Uint8()}; |
259 Node* p0 = Parameter(Type::TaggedPointer()); | 270 Node* p0 = Parameter(Type::TaggedPointer()); |
260 Node* p1 = Parameter(Type::Signed32()); | 271 Node* p1 = Parameter(Type::Signed32()); |
261 Node* p2 = Parameter(Type::Signed32()); | 272 Node* p2 = Parameter(Type::Signed32()); |
262 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2, | 273 Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2, |
263 graph()->start(), graph()->start()); | 274 graph()->start(), graph()->start()); |
264 Reduction r = Reduce(store); | 275 Reduction r = Reduce(store); |
265 | 276 |
266 ASSERT_TRUE(r.Changed()); | 277 ASSERT_TRUE(r.Changed()); |
267 Matcher<Node*> index_match = | 278 Matcher<Node*> index_match = |
268 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag())); | 279 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag())); |
269 if (!Is32()) { | 280 if (!Is32()) { |
270 index_match = IsChangeUint32ToUint64(index_match); | 281 index_match = IsChangeUint32ToUint64(index_match); |
271 } | 282 } |
272 | 283 |
273 EXPECT_THAT(r.replacement(), | 284 EXPECT_THAT( |
274 IsStore(StoreRepresentation(kMachUint8, kNoWriteBarrier), p0, | 285 r.replacement(), |
275 index_match, p2, graph()->start(), graph()->start())); | 286 IsStore(StoreRepresentation(MachineType::Uint8(), kNoWriteBarrier), p0, |
| 287 index_match, p2, graph()->start(), graph()->start())); |
276 } | 288 } |
277 | 289 |
278 | 290 |
279 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) { | 291 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) { |
280 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), | 292 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), |
281 kMachAnyTagged}; | 293 MachineType::AnyTagged()}; |
282 Node* p0 = Parameter(Type::TaggedPointer()); | 294 Node* p0 = Parameter(Type::TaggedPointer()); |
283 Node* p1 = Parameter(Type::Signed32()); | 295 Node* p1 = Parameter(Type::Signed32()); |
284 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, | 296 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, |
285 graph()->start(), graph()->start()); | 297 graph()->start(), graph()->start()); |
286 Reduction r = Reduce(load); | 298 Reduction r = Reduce(load); |
287 | 299 |
288 const int element_size_shift = ElementSizeLog2Of(access.machine_type); | 300 const int element_size_shift = |
| 301 ElementSizeLog2Of(access.machine_type.representation()); |
289 ASSERT_TRUE(r.Changed()); | 302 ASSERT_TRUE(r.Changed()); |
290 Matcher<Node*> index_match = | 303 Matcher<Node*> index_match = |
291 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), | 304 IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)), |
292 IsInt32Constant(access.header_size - access.tag())); | 305 IsInt32Constant(access.header_size - access.tag())); |
293 if (!Is32()) { | 306 if (!Is32()) { |
294 index_match = IsChangeUint32ToUint64(index_match); | 307 index_match = IsChangeUint32ToUint64(index_match); |
295 } | 308 } |
296 | 309 |
297 EXPECT_THAT(r.replacement(), IsLoad(kMachAnyTagged, p0, index_match, | 310 EXPECT_THAT(r.replacement(), IsLoad(MachineType::AnyTagged(), p0, index_match, |
298 graph()->start(), graph()->start())); | 311 graph()->start(), graph()->start())); |
299 } | 312 } |
300 | 313 |
301 | 314 |
302 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) { | 315 TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) { |
303 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, | 316 ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, |
304 Type::Signed32(), kMachInt8}; | 317 Type::Signed32(), MachineType::Int8()}; |
305 Node* p0 = Parameter(Type::TaggedPointer()); | 318 Node* p0 = Parameter(Type::TaggedPointer()); |
306 Node* p1 = Parameter(Type::Signed32()); | 319 Node* p1 = Parameter(Type::Signed32()); |
307 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, | 320 Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1, |
308 graph()->start(), graph()->start()); | 321 graph()->start(), graph()->start()); |
309 Reduction r = Reduce(load); | 322 Reduction r = Reduce(load); |
310 | 323 |
311 ASSERT_TRUE(r.Changed()); | 324 ASSERT_TRUE(r.Changed()); |
312 Matcher<Node*> index_match = | 325 Matcher<Node*> index_match = |
313 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag())); | 326 IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag())); |
314 if (!Is32()) { | 327 if (!Is32()) { |
315 index_match = IsChangeUint32ToUint64(index_match); | 328 index_match = IsChangeUint32ToUint64(index_match); |
316 } | 329 } |
317 | 330 |
318 EXPECT_THAT(r.replacement(), IsLoad(kMachInt8, p0, index_match, | 331 EXPECT_THAT(r.replacement(), IsLoad(MachineType::Int8(), p0, index_match, |
319 graph()->start(), graph()->start())); | 332 graph()->start(), graph()->start())); |
320 } | 333 } |
321 | 334 |
322 | 335 |
323 TARGET_TEST_P(ChangeLoweringCommonTest, Allocate) { | 336 TARGET_TEST_P(ChangeLoweringCommonTest, Allocate) { |
324 Node* p0 = Parameter(Type::Signed32()); | 337 Node* p0 = Parameter(Type::Signed32()); |
325 Node* alloc = graph()->NewNode(simplified()->Allocate(TENURED), p0, | 338 Node* alloc = graph()->NewNode(simplified()->Allocate(TENURED), p0, |
326 graph()->start(), graph()->start()); | 339 graph()->start(), graph()->start()); |
327 Reduction r = Reduce(alloc); | 340 Reduction r = Reduce(alloc); |
328 | 341 |
329 // Only check that we lowered, but do not specify the exact form since | 342 // Only check that we lowered, but do not specify the exact form since |
330 // this is subject to change. | 343 // this is subject to change. |
331 ASSERT_TRUE(r.Changed()); | 344 ASSERT_TRUE(r.Changed()); |
332 } | 345 } |
333 | 346 |
334 | 347 |
335 INSTANTIATE_TEST_CASE_P(ChangeLoweringTest, ChangeLoweringCommonTest, | 348 INSTANTIATE_TEST_CASE_P(ChangeLoweringTest, ChangeLoweringCommonTest, |
336 ::testing::Values(kRepWord32, kRepWord64)); | 349 ::testing::Values(MachineRepresentation::kWord32, |
| 350 MachineRepresentation::kWord64)); |
337 | 351 |
338 | 352 |
339 // ----------------------------------------------------------------------------- | 353 // ----------------------------------------------------------------------------- |
340 // 32-bit | 354 // 32-bit |
341 | 355 |
342 | 356 |
343 class ChangeLowering32Test : public ChangeLoweringTest { | 357 class ChangeLowering32Test : public ChangeLoweringTest { |
344 public: | 358 public: |
345 ~ChangeLowering32Test() override {} | 359 ~ChangeLowering32Test() override {} |
346 MachineType WordRepresentation() const final { return kRepWord32; } | 360 MachineRepresentation WordRepresentation() const final { |
| 361 return MachineRepresentation::kWord32; |
| 362 } |
347 }; | 363 }; |
348 | 364 |
349 | 365 |
350 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { | 366 TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { |
351 Node* value = Parameter(Type::Integral32()); | 367 Node* value = Parameter(Type::Integral32()); |
352 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value); | 368 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value); |
353 Reduction r = Reduce(node); | 369 Reduction r = Reduce(node); |
354 ASSERT_TRUE(r.Changed()); | 370 ASSERT_TRUE(r.Changed()); |
355 Capture<Node*> add, branch, heap_number, if_true; | 371 Capture<Node*> add, branch, heap_number, if_true; |
356 EXPECT_THAT( | 372 EXPECT_THAT( |
357 r.replacement(), | 373 r.replacement(), |
358 IsPhi(kMachAnyTagged, | 374 IsPhi( |
359 IsFinishRegion( | 375 MachineRepresentation::kTagged, |
360 AllOf(CaptureEq(&heap_number), | 376 IsFinishRegion( |
361 IsAllocateHeapNumber(_, CaptureEq(&if_true))), | 377 AllOf(CaptureEq(&heap_number), |
362 IsStore( | 378 IsAllocateHeapNumber(_, CaptureEq(&if_true))), |
363 StoreRepresentation(kMachFloat64, kNoWriteBarrier), | 379 IsStore( |
364 CaptureEq(&heap_number), | 380 StoreRepresentation(MachineType::Float64(), kNoWriteBarrier), |
365 IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), | 381 CaptureEq(&heap_number), |
366 IsChangeInt32ToFloat64(value), CaptureEq(&heap_number), | 382 IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag), |
367 CaptureEq(&if_true))), | 383 IsChangeInt32ToFloat64(value), CaptureEq(&heap_number), |
368 IsProjection(0, AllOf(CaptureEq(&add), | 384 CaptureEq(&if_true))), |
369 IsInt32AddWithOverflow(value, value))), | 385 IsProjection( |
370 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 386 0, AllOf(CaptureEq(&add), IsInt32AddWithOverflow(value, value))), |
371 IsIfFalse(AllOf(CaptureEq(&branch), | 387 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
372 IsBranch(IsProjection(1, CaptureEq(&add)), | 388 IsIfFalse(AllOf(CaptureEq(&branch), |
373 graph()->start())))))); | 389 IsBranch(IsProjection(1, CaptureEq(&add)), |
| 390 graph()->start())))))); |
374 } | 391 } |
375 | 392 |
376 | 393 |
377 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { | 394 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { |
378 STATIC_ASSERT(kSmiTag == 0); | 395 STATIC_ASSERT(kSmiTag == 0); |
379 STATIC_ASSERT(kSmiTagSize == 1); | 396 STATIC_ASSERT(kSmiTagSize == 1); |
380 | 397 |
381 Node* value = Parameter(Type::Number()); | 398 Node* value = Parameter(Type::Number()); |
382 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value); | 399 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value); |
383 Reduction r = Reduce(node); | 400 Reduction r = Reduce(node); |
384 ASSERT_TRUE(r.Changed()); | 401 ASSERT_TRUE(r.Changed()); |
385 Capture<Node*> branch, if_true; | 402 Capture<Node*> branch, if_true; |
386 EXPECT_THAT( | 403 EXPECT_THAT( |
387 r.replacement(), | 404 r.replacement(), |
388 IsPhi(kMachFloat64, IsLoadHeapNumber(value, CaptureEq(&if_true)), | 405 IsPhi(MachineRepresentation::kFloat64, |
| 406 IsLoadHeapNumber(value, CaptureEq(&if_true)), |
389 IsChangeInt32ToFloat64(IsWord32Sar( | 407 IsChangeInt32ToFloat64(IsWord32Sar( |
390 value, IsInt32Constant(kSmiTagSize + kSmiShiftSize))), | 408 value, IsInt32Constant(kSmiTagSize + kSmiShiftSize))), |
391 IsMerge(AllOf(CaptureEq(&if_true), | 409 IsMerge(AllOf(CaptureEq(&if_true), |
392 IsIfTrue(AllOf( | 410 IsIfTrue(AllOf( |
393 CaptureEq(&branch), | 411 CaptureEq(&branch), |
394 IsBranch(IsWord32And( | 412 IsBranch(IsWord32And( |
395 value, IsInt32Constant(kSmiTagMask)), | 413 value, IsInt32Constant(kSmiTagMask)), |
396 graph()->start())))), | 414 graph()->start())))), |
397 IsIfFalse(CaptureEq(&branch))))); | 415 IsIfFalse(CaptureEq(&branch))))); |
398 } | 416 } |
399 | 417 |
400 | 418 |
401 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToInt32) { | 419 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToInt32) { |
402 STATIC_ASSERT(kSmiTag == 0); | 420 STATIC_ASSERT(kSmiTag == 0); |
403 STATIC_ASSERT(kSmiTagSize == 1); | 421 STATIC_ASSERT(kSmiTagSize == 1); |
404 | 422 |
405 Node* value = Parameter(Type::Signed32()); | 423 Node* value = Parameter(Type::Signed32()); |
406 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value); | 424 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value); |
407 Reduction r = Reduce(node); | 425 Reduction r = Reduce(node); |
408 ASSERT_TRUE(r.Changed()); | 426 ASSERT_TRUE(r.Changed()); |
409 Capture<Node*> branch, if_true; | 427 Capture<Node*> branch, if_true; |
410 EXPECT_THAT( | 428 EXPECT_THAT( |
411 r.replacement(), | 429 r.replacement(), |
412 IsPhi( | 430 IsPhi( |
413 kMachInt32, | 431 MachineRepresentation::kWord32, |
414 IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), | 432 IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
415 IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), | 433 IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), |
416 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 434 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
417 IsIfFalse(AllOf( | 435 IsIfFalse(AllOf( |
418 CaptureEq(&branch), | 436 CaptureEq(&branch), |
419 IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)), | 437 IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)), |
420 graph()->start())))))); | 438 graph()->start())))))); |
421 } | 439 } |
422 | 440 |
423 | 441 |
424 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { | 442 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { |
425 STATIC_ASSERT(kSmiTag == 0); | 443 STATIC_ASSERT(kSmiTag == 0); |
426 STATIC_ASSERT(kSmiTagSize == 1); | 444 STATIC_ASSERT(kSmiTagSize == 1); |
427 | 445 |
428 Node* value = Parameter(Type::Unsigned32()); | 446 Node* value = Parameter(Type::Unsigned32()); |
429 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value); | 447 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value); |
430 Reduction r = Reduce(node); | 448 Reduction r = Reduce(node); |
431 ASSERT_TRUE(r.Changed()); | 449 ASSERT_TRUE(r.Changed()); |
432 Capture<Node*> branch, if_true; | 450 Capture<Node*> branch, if_true; |
433 EXPECT_THAT( | 451 EXPECT_THAT( |
434 r.replacement(), | 452 r.replacement(), |
435 IsPhi( | 453 IsPhi( |
436 kMachUint32, | 454 MachineRepresentation::kWord32, |
437 IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), | 455 IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
438 IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), | 456 IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), |
439 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 457 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
440 IsIfFalse(AllOf( | 458 IsIfFalse(AllOf( |
441 CaptureEq(&branch), | 459 CaptureEq(&branch), |
442 IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)), | 460 IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)), |
443 graph()->start())))))); | 461 graph()->start())))))); |
444 } | 462 } |
445 | 463 |
446 | 464 |
447 TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { | 465 TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) { |
448 STATIC_ASSERT(kSmiTag == 0); | 466 STATIC_ASSERT(kSmiTag == 0); |
449 STATIC_ASSERT(kSmiTagSize == 1); | 467 STATIC_ASSERT(kSmiTagSize == 1); |
450 | 468 |
451 Node* value = Parameter(Type::Number()); | 469 Node* value = Parameter(Type::Number()); |
452 Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value); | 470 Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value); |
453 Reduction r = Reduce(node); | 471 Reduction r = Reduce(node); |
454 ASSERT_TRUE(r.Changed()); | 472 ASSERT_TRUE(r.Changed()); |
455 Capture<Node*> branch, heap_number, if_false; | 473 Capture<Node*> branch, heap_number, if_false; |
456 EXPECT_THAT( | 474 EXPECT_THAT( |
457 r.replacement(), | 475 r.replacement(), |
458 IsPhi( | 476 IsPhi( |
459 kMachAnyTagged, | 477 MachineRepresentation::kTagged, |
460 IsWord32Shl(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), | 478 IsWord32Shl(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)), |
461 IsFinishRegion( | 479 IsFinishRegion( |
462 AllOf(CaptureEq(&heap_number), | 480 AllOf(CaptureEq(&heap_number), |
463 IsAllocateHeapNumber(_, CaptureEq(&if_false))), | 481 IsAllocateHeapNumber(_, CaptureEq(&if_false))), |
464 IsStore( | 482 IsStore( |
465 StoreRepresentation(kMachFloat64, kNoWriteBarrier), | 483 StoreRepresentation(MachineType::Float64(), kNoWriteBarrier), |
466 CaptureEq(&heap_number), | 484 CaptureEq(&heap_number), |
467 IsInt32Constant(HeapNumber::kValueOffset - kHeapObjectTag), | 485 IsInt32Constant(HeapNumber::kValueOffset - kHeapObjectTag), |
468 IsChangeUint32ToFloat64(value), CaptureEq(&heap_number), | 486 IsChangeUint32ToFloat64(value), CaptureEq(&heap_number), |
469 CaptureEq(&if_false))), | 487 CaptureEq(&if_false))), |
470 IsMerge(IsIfTrue(AllOf( | 488 IsMerge(IsIfTrue(AllOf( |
471 CaptureEq(&branch), | 489 CaptureEq(&branch), |
472 IsBranch(IsUint32LessThanOrEqual( | 490 IsBranch(IsUint32LessThanOrEqual( |
473 value, IsInt32Constant(Smi::kMaxValue)), | 491 value, IsInt32Constant(Smi::kMaxValue)), |
474 graph()->start()))), | 492 graph()->start()))), |
475 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 493 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
476 } | 494 } |
477 | 495 |
478 | 496 |
479 // ----------------------------------------------------------------------------- | 497 // ----------------------------------------------------------------------------- |
480 // 64-bit | 498 // 64-bit |
481 | 499 |
482 | 500 |
483 class ChangeLowering64Test : public ChangeLoweringTest { | 501 class ChangeLowering64Test : public ChangeLoweringTest { |
484 public: | 502 public: |
485 ~ChangeLowering64Test() override {} | 503 ~ChangeLowering64Test() override {} |
486 MachineType WordRepresentation() const final { return kRepWord64; } | 504 MachineRepresentation WordRepresentation() const final { |
| 505 return MachineRepresentation::kWord64; |
| 506 } |
487 }; | 507 }; |
488 | 508 |
489 | 509 |
490 TARGET_TEST_F(ChangeLowering64Test, ChangeInt32ToTagged) { | 510 TARGET_TEST_F(ChangeLowering64Test, ChangeInt32ToTagged) { |
491 Node* value = Parameter(Type::Signed32()); | 511 Node* value = Parameter(Type::Signed32()); |
492 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value); | 512 Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value); |
493 Reduction r = Reduce(node); | 513 Reduction r = Reduce(node); |
494 ASSERT_TRUE(r.Changed()); | 514 ASSERT_TRUE(r.Changed()); |
495 EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value)); | 515 EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value)); |
496 } | 516 } |
497 | 517 |
498 | 518 |
499 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { | 519 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { |
500 STATIC_ASSERT(kSmiTag == 0); | 520 STATIC_ASSERT(kSmiTag == 0); |
501 STATIC_ASSERT(kSmiTagSize == 1); | 521 STATIC_ASSERT(kSmiTagSize == 1); |
502 | 522 |
503 Node* value = Parameter(Type::Number()); | 523 Node* value = Parameter(Type::Number()); |
504 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value); | 524 Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value); |
505 Reduction r = Reduce(node); | 525 Reduction r = Reduce(node); |
506 ASSERT_TRUE(r.Changed()); | 526 ASSERT_TRUE(r.Changed()); |
507 Capture<Node*> branch, if_true; | 527 Capture<Node*> branch, if_true; |
508 EXPECT_THAT( | 528 EXPECT_THAT( |
509 r.replacement(), | 529 r.replacement(), |
510 IsPhi(kMachFloat64, IsLoadHeapNumber(value, CaptureEq(&if_true)), | 530 IsPhi(MachineRepresentation::kFloat64, |
| 531 IsLoadHeapNumber(value, CaptureEq(&if_true)), |
511 IsChangeInt32ToFloat64(IsTruncateInt64ToInt32(IsWord64Sar( | 532 IsChangeInt32ToFloat64(IsTruncateInt64ToInt32(IsWord64Sar( |
512 value, IsInt64Constant(kSmiTagSize + kSmiShiftSize)))), | 533 value, IsInt64Constant(kSmiTagSize + kSmiShiftSize)))), |
513 IsMerge(AllOf(CaptureEq(&if_true), | 534 IsMerge(AllOf(CaptureEq(&if_true), |
514 IsIfTrue(AllOf( | 535 IsIfTrue(AllOf( |
515 CaptureEq(&branch), | 536 CaptureEq(&branch), |
516 IsBranch(IsWord64And( | 537 IsBranch(IsWord64And( |
517 value, IsInt64Constant(kSmiTagMask)), | 538 value, IsInt64Constant(kSmiTagMask)), |
518 graph()->start())))), | 539 graph()->start())))), |
519 IsIfFalse(CaptureEq(&branch))))); | 540 IsIfFalse(CaptureEq(&branch))))); |
520 } | 541 } |
521 | 542 |
522 | 543 |
523 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToInt32) { | 544 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToInt32) { |
524 STATIC_ASSERT(kSmiTag == 0); | 545 STATIC_ASSERT(kSmiTag == 0); |
525 STATIC_ASSERT(kSmiTagSize == 1); | 546 STATIC_ASSERT(kSmiTagSize == 1); |
526 | 547 |
527 Node* value = Parameter(Type::Signed32()); | 548 Node* value = Parameter(Type::Signed32()); |
528 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value); | 549 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value); |
529 Reduction r = Reduce(node); | 550 Reduction r = Reduce(node); |
530 ASSERT_TRUE(r.Changed()); | 551 ASSERT_TRUE(r.Changed()); |
531 Capture<Node*> branch, if_true; | 552 Capture<Node*> branch, if_true; |
532 EXPECT_THAT( | 553 EXPECT_THAT( |
533 r.replacement(), | 554 r.replacement(), |
534 IsPhi( | 555 IsPhi( |
535 kMachInt32, | 556 MachineRepresentation::kWord32, |
536 IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), | 557 IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
537 IsTruncateInt64ToInt32( | 558 IsTruncateInt64ToInt32( |
538 IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), | 559 IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), |
539 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 560 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
540 IsIfFalse(AllOf( | 561 IsIfFalse(AllOf( |
541 CaptureEq(&branch), | 562 CaptureEq(&branch), |
542 IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)), | 563 IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)), |
543 graph()->start())))))); | 564 graph()->start())))))); |
544 } | 565 } |
545 | 566 |
546 | 567 |
547 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { | 568 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { |
548 STATIC_ASSERT(kSmiTag == 0); | 569 STATIC_ASSERT(kSmiTag == 0); |
549 STATIC_ASSERT(kSmiTagSize == 1); | 570 STATIC_ASSERT(kSmiTagSize == 1); |
550 | 571 |
551 Node* value = Parameter(Type::Unsigned32()); | 572 Node* value = Parameter(Type::Unsigned32()); |
552 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value); | 573 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value); |
553 Reduction r = Reduce(node); | 574 Reduction r = Reduce(node); |
554 ASSERT_TRUE(r.Changed()); | 575 ASSERT_TRUE(r.Changed()); |
555 Capture<Node*> branch, if_true; | 576 Capture<Node*> branch, if_true; |
556 EXPECT_THAT( | 577 EXPECT_THAT( |
557 r.replacement(), | 578 r.replacement(), |
558 IsPhi( | 579 IsPhi( |
559 kMachUint32, | 580 MachineRepresentation::kWord32, |
560 IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), | 581 IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))), |
561 IsTruncateInt64ToInt32( | 582 IsTruncateInt64ToInt32( |
562 IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), | 583 IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))), |
563 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 584 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
564 IsIfFalse(AllOf( | 585 IsIfFalse(AllOf( |
565 CaptureEq(&branch), | 586 CaptureEq(&branch), |
566 IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)), | 587 IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)), |
567 graph()->start())))))); | 588 graph()->start())))))); |
568 } | 589 } |
569 | 590 |
570 | 591 |
571 TARGET_TEST_F(ChangeLowering64Test, ChangeUint32ToTagged) { | 592 TARGET_TEST_F(ChangeLowering64Test, ChangeUint32ToTagged) { |
572 STATIC_ASSERT(kSmiTag == 0); | 593 STATIC_ASSERT(kSmiTag == 0); |
573 STATIC_ASSERT(kSmiTagSize == 1); | 594 STATIC_ASSERT(kSmiTagSize == 1); |
574 | 595 |
575 Node* value = Parameter(Type::Number()); | 596 Node* value = Parameter(Type::Number()); |
576 Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value); | 597 Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value); |
577 Reduction r = Reduce(node); | 598 Reduction r = Reduce(node); |
578 ASSERT_TRUE(r.Changed()); | 599 ASSERT_TRUE(r.Changed()); |
579 Capture<Node*> branch, heap_number, if_false; | 600 Capture<Node*> branch, heap_number, if_false; |
580 EXPECT_THAT( | 601 EXPECT_THAT( |
581 r.replacement(), | 602 r.replacement(), |
582 IsPhi( | 603 IsPhi( |
583 kMachAnyTagged, | 604 MachineRepresentation::kTagged, |
584 IsWord64Shl(IsChangeUint32ToUint64(value), | 605 IsWord64Shl(IsChangeUint32ToUint64(value), |
585 IsInt64Constant(kSmiTagSize + kSmiShiftSize)), | 606 IsInt64Constant(kSmiTagSize + kSmiShiftSize)), |
586 IsFinishRegion( | 607 IsFinishRegion( |
587 AllOf(CaptureEq(&heap_number), | 608 AllOf(CaptureEq(&heap_number), |
588 IsAllocateHeapNumber(_, CaptureEq(&if_false))), | 609 IsAllocateHeapNumber(_, CaptureEq(&if_false))), |
589 IsStore( | 610 IsStore( |
590 StoreRepresentation(kMachFloat64, kNoWriteBarrier), | 611 StoreRepresentation(MachineType::Float64(), kNoWriteBarrier), |
591 CaptureEq(&heap_number), | 612 CaptureEq(&heap_number), |
592 IsInt64Constant(HeapNumber::kValueOffset - kHeapObjectTag), | 613 IsInt64Constant(HeapNumber::kValueOffset - kHeapObjectTag), |
593 IsChangeUint32ToFloat64(value), CaptureEq(&heap_number), | 614 IsChangeUint32ToFloat64(value), CaptureEq(&heap_number), |
594 CaptureEq(&if_false))), | 615 CaptureEq(&if_false))), |
595 IsMerge(IsIfTrue(AllOf( | 616 IsMerge(IsIfTrue(AllOf( |
596 CaptureEq(&branch), | 617 CaptureEq(&branch), |
597 IsBranch(IsUint32LessThanOrEqual( | 618 IsBranch(IsUint32LessThanOrEqual( |
598 value, IsInt32Constant(Smi::kMaxValue)), | 619 value, IsInt32Constant(Smi::kMaxValue)), |
599 graph()->start()))), | 620 graph()->start()))), |
600 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 621 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
601 } | 622 } |
602 | 623 |
603 } // namespace compiler | 624 } // namespace compiler |
604 } // namespace internal | 625 } // namespace internal |
605 } // namespace v8 | 626 } // namespace v8 |
OLD | NEW |