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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 1512023002: [turbofan] Change TruncateFloat32ToUint64 to TryTruncateFloat32ToUint64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added better mips64 code. Created 5 years 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 | « test/cctest/compiler/test-representation-change.cc ('k') | test/cctest/compiler/value-helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 5509 matching lines...) Expand 10 before | Expand all | Expand 10 after
5520 } else { 5520 } else {
5521 m.Call(*i); 5521 m.Call(*i);
5522 CHECK_EQ(0, success); 5522 CHECK_EQ(0, success);
5523 } 5523 }
5524 } 5524 }
5525 } 5525 }
5526 5526
5527 5527
5528 TEST(RunTruncateFloat32ToUint64) { 5528 TEST(RunTruncateFloat32ToUint64) {
5529 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32()); 5529 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32());
5530 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0))); 5530 m.Return(m.TryTruncateFloat32ToUint64(m.Parameter(0)));
5531 5531
5532 FOR_UINT64_INPUTS(i) { 5532 FOR_UINT64_INPUTS(i) {
5533 float input = static_cast<float>(*i); 5533 float input = static_cast<float>(*i);
5534 if (input < 18446744073709551616.0) { 5534 if (input < 18446744073709551616.0) {
5535 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5535 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5536 } 5536 }
5537 } 5537 }
5538 FOR_FLOAT32_INPUTS(j) { 5538 FOR_FLOAT32_INPUTS(j) {
5539 if (*j < 18446744073709551616.0 && *j >= 0) { 5539 if (*j < 18446744073709551616.0 && *j >= 0) {
5540 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j)); 5540 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j));
5541 } 5541 }
5542 } 5542 }
5543 } 5543 }
5544 5544
5545 5545
5546 TEST(RunTryTruncateFloat32ToUint64WithCheck) {
5547 int64_t success = 0;
5548 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32());
5549 Node* trunc = m.TryTruncateFloat32ToUint64(m.Parameter(0));
5550 Node* val = m.Projection(0, trunc);
5551 Node* check = m.Projection(1, trunc);
5552 m.StoreToPointer(&success, MachineType::Int64(), check);
5553 m.Return(val);
5554
5555 FOR_FLOAT32_INPUTS(i) {
5556 if (*i < 18446744073709551616.0 && *i >= 0.0) {
5557 // Conversions within this range should succeed.
5558 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i));
5559 CHECK_NE(0, success);
5560 } else {
5561 m.Call(*i);
5562 CHECK_EQ(0, success);
5563 }
5564 }
5565 }
5566
5567
5546 TEST(RunTryTruncateFloat64ToUint64WithoutCheck) { 5568 TEST(RunTryTruncateFloat64ToUint64WithoutCheck) {
5547 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float64()); 5569 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float64());
5548 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0))); 5570 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0)));
5549 5571
5550 FOR_UINT64_INPUTS(j) { 5572 FOR_UINT64_INPUTS(j) {
5551 double input = static_cast<double>(*j); 5573 double input = static_cast<double>(*j);
5552 5574
5553 if (input < 18446744073709551616.0) { 5575 if (input < 18446744073709551616.0) {
5554 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5576 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5555 } 5577 }
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
5851 Node* call = r.AddNode(r.common()->Call(desc), phi); 5873 Node* call = r.AddNode(r.common()->Call(desc), phi);
5852 r.Return(call); 5874 r.Return(call);
5853 5875
5854 CHECK_EQ(33, r.Call(1)); 5876 CHECK_EQ(33, r.Call(1));
5855 CHECK_EQ(44, r.Call(0)); 5877 CHECK_EQ(44, r.Call(0));
5856 } 5878 }
5857 5879
5858 } // namespace compiler 5880 } // namespace compiler
5859 } // namespace internal 5881 } // namespace internal
5860 } // namespace v8 5882 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-representation-change.cc ('k') | test/cctest/compiler/value-helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698