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/base/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/compiler/graph-unittest.h" | 6 #include "src/compiler/graph-unittest.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/machine-operator-reducer.h" | 8 #include "src/compiler/machine-operator-reducer.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 | 10 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 Reduce(graph()->NewNode(machine()->ChangeUint32ToUint64(), | 308 Reduce(graph()->NewNode(machine()->ChangeUint32ToUint64(), |
309 Int32Constant(bit_cast<int32_t>(x)))); | 309 Int32Constant(bit_cast<int32_t>(x)))); |
310 ASSERT_TRUE(reduction.Changed()); | 310 ASSERT_TRUE(reduction.Changed()); |
311 EXPECT_THAT(reduction.replacement(), | 311 EXPECT_THAT(reduction.replacement(), |
312 IsInt64Constant(bit_cast<int64_t>(static_cast<uint64_t>(x)))); | 312 IsInt64Constant(bit_cast<int64_t>(static_cast<uint64_t>(x)))); |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 | 316 |
317 // ----------------------------------------------------------------------------- | 317 // ----------------------------------------------------------------------------- |
| 318 // TruncateFloat64ToFloat32 |
| 319 |
| 320 |
| 321 TEST_F(MachineOperatorReducerTest, |
| 322 TruncateFloat64ToFloat32WithChangeFloat32ToFloat64) { |
| 323 Node* value = Parameter(0); |
| 324 Reduction reduction = Reduce(graph()->NewNode( |
| 325 machine()->TruncateFloat64ToFloat32(), |
| 326 graph()->NewNode(machine()->ChangeFloat32ToFloat64(), value))); |
| 327 ASSERT_TRUE(reduction.Changed()); |
| 328 EXPECT_EQ(value, reduction.replacement()); |
| 329 } |
| 330 |
| 331 |
| 332 TEST_F(MachineOperatorReducerTest, TruncateFloat64ToFloat32WithConstant) { |
| 333 TRACED_FOREACH(double, x, kFloat64Values) { |
| 334 Reduction reduction = Reduce(graph()->NewNode( |
| 335 machine()->TruncateFloat64ToFloat32(), Float64Constant(x))); |
| 336 ASSERT_TRUE(reduction.Changed()); |
| 337 EXPECT_THAT(reduction.replacement(), IsFloat32Constant(DoubleToFloat32(x))); |
| 338 } |
| 339 } |
| 340 |
| 341 |
| 342 // ----------------------------------------------------------------------------- |
318 // TruncateFloat64ToInt32 | 343 // TruncateFloat64ToInt32 |
319 | 344 |
320 | 345 |
321 TEST_F(MachineOperatorReducerTest, | 346 TEST_F(MachineOperatorReducerTest, |
322 TruncateFloat64ToInt32WithChangeInt32ToFloat64) { | 347 TruncateFloat64ToInt32WithChangeInt32ToFloat64) { |
323 Node* value = Parameter(0); | 348 Node* value = Parameter(0); |
324 Reduction reduction = Reduce(graph()->NewNode( | 349 Reduction reduction = Reduce(graph()->NewNode( |
325 machine()->TruncateFloat64ToInt32(), | 350 machine()->TruncateFloat64ToInt32(), |
326 graph()->NewNode(machine()->ChangeInt32ToFloat64(), value))); | 351 graph()->NewNode(machine()->ChangeInt32ToFloat64(), value))); |
327 ASSERT_TRUE(reduction.Changed()); | 352 ASSERT_TRUE(reduction.Changed()); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 r = Reduce(graph()->NewNode(common()->Projection(0), add)); | 556 r = Reduce(graph()->NewNode(common()->Projection(0), add)); |
532 ASSERT_TRUE(r.Changed()); | 557 ASSERT_TRUE(r.Changed()); |
533 EXPECT_THAT(r.replacement(), IsInt32Constant(z)); | 558 EXPECT_THAT(r.replacement(), IsInt32Constant(z)); |
534 } | 559 } |
535 } | 560 } |
536 } | 561 } |
537 | 562 |
538 } // namespace compiler | 563 } // namespace compiler |
539 } // namespace internal | 564 } // namespace internal |
540 } // namespace v8 | 565 } // namespace v8 |
OLD | NEW |