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

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: 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
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 5420 matching lines...) Expand 10 before | Expand all | Expand 10 after
5431 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); 5431 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i));
5432 CHECK_NE(0, success); 5432 CHECK_NE(0, success);
5433 } else { 5433 } else {
5434 m.Call(*i); 5434 m.Call(*i);
5435 CHECK_EQ(0, success); 5435 CHECK_EQ(0, success);
5436 } 5436 }
5437 } 5437 }
5438 } 5438 }
5439 5439
5440 5440
5441 TEST(RunTruncateFloat32ToUint64) { 5441 TEST(RunTryTruncateFloat32ToUint64WithoutCheck) {
5442 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32); 5442 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32);
5443 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0))); 5443 m.Return(m.TryTruncateFloat32ToUint64(m.Parameter(0)));
5444 5444
5445 FOR_UINT64_INPUTS(i) { 5445 FOR_UINT64_INPUTS(i) {
5446 float input = static_cast<float>(*i); 5446 float input = static_cast<float>(*i);
5447 if (input < 18446744073709551616.0) { 5447 if (input < 18446744073709551616.0) {
5448 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5448 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5449 } 5449 }
5450 } 5450 }
5451 FOR_FLOAT32_INPUTS(j) { 5451 FOR_FLOAT32_INPUTS(j) {
5452 if (*j < 18446744073709551616.0 && *j >= 0) { 5452 if (*j < 18446744073709551616.0 && *j >= 0) {
5453 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j)); 5453 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j));
5454 } 5454 }
5455 } 5455 }
5456 } 5456 }
5457 5457
5458 5458
5459 TEST(RunTryTruncateFloat32ToUint64WithCheck) {
5460 int64_t success = 0;
5461 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32);
5462 Node* trunc = m.TryTruncateFloat32ToUint64(m.Parameter(0));
5463 Node* val = m.Projection(0, trunc);
5464 Node* check = m.Projection(1, trunc);
5465 m.StoreToPointer(&success, kMachInt64, check);
5466 m.Return(val);
5467
5468 FOR_FLOAT32_INPUTS(i) {
5469 if (*i < 18446744073709551616.0 && *i >= 0.0) {
5470 // Conversions within this range should succeed.
5471 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i));
5472 CHECK_NE(0, success);
5473 } else {
5474 m.Call(*i);
5475 CHECK_EQ(0, success);
5476 }
5477 }
5478 }
5479
5480
5459 TEST(RunTryTruncateFloat64ToUint64WithoutCheck) { 5481 TEST(RunTryTruncateFloat64ToUint64WithoutCheck) {
5460 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat64); 5482 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat64);
5461 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0))); 5483 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0)));
5462 5484
5463 FOR_UINT64_INPUTS(j) { 5485 FOR_UINT64_INPUTS(j) {
5464 double input = static_cast<double>(*j); 5486 double input = static_cast<double>(*j);
5465 5487
5466 if (input < 18446744073709551616.0) { 5488 if (input < 18446744073709551616.0) {
5467 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5489 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5468 } 5490 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
5763 Node* call = r.AddNode(r.common()->Call(desc), phi); 5785 Node* call = r.AddNode(r.common()->Call(desc), phi);
5764 r.Return(call); 5786 r.Return(call);
5765 5787
5766 CHECK_EQ(33, r.Call(1)); 5788 CHECK_EQ(33, r.Call(1));
5767 CHECK_EQ(44, r.Call(0)); 5789 CHECK_EQ(44, r.Call(0));
5768 } 5790 }
5769 5791
5770 } // namespace compiler 5792 } // namespace compiler
5771 } // namespace internal 5793 } // namespace internal
5772 } // namespace v8 5794 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698