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

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

Issue 1507703002: [turbofan] Change TruncateFloat64ToUint64 to TryTruncateFloatToUint64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added mips64 implementation, fixed nits. 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 | « src/mips64/macro-assembler-mips64.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 // TODO(jochen): Remove this after the setting is turned on globally. 5 // TODO(jochen): Remove this after the setting is turned on globally.
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <functional> 9 #include <functional>
10 #include <limits> 10 #include <limits>
(...skipping 5412 matching lines...) Expand 10 before | Expand all | Expand 10 after
5423 int64_t success = 0; 5423 int64_t success = 0;
5424 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5424 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64);
5425 Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0)); 5425 Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0));
5426 Node* val = m.Projection(0, trunc); 5426 Node* val = m.Projection(0, trunc);
5427 Node* check = m.Projection(1, trunc); 5427 Node* check = m.Projection(1, trunc);
5428 m.StoreToPointer(&success, kMachInt64, check); 5428 m.StoreToPointer(&success, kMachInt64, check);
5429 m.Return(val); 5429 m.Return(val);
5430 5430
5431 FOR_FLOAT64_INPUTS(i) { 5431 FOR_FLOAT64_INPUTS(i) {
5432 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { 5432 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) {
5433 // Conversions within this range 5433 // Conversions within this range should succeed.
5434 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); 5434 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i));
5435 CHECK_NE(0, success); 5435 CHECK_NE(0, success);
5436 } else { 5436 } else {
5437 m.Call(*i); 5437 m.Call(*i);
5438 CHECK_EQ(0, success); 5438 CHECK_EQ(0, success);
5439 } 5439 }
5440 } 5440 }
5441 } 5441 }
5442 5442
5443 5443
5444 TEST(RunTruncateFloat32ToUint64) { 5444 TEST(RunTruncateFloat32ToUint64) {
5445 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32); 5445 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32);
5446 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0))); 5446 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0)));
5447 5447
5448 FOR_UINT64_INPUTS(i) { 5448 FOR_UINT64_INPUTS(i) {
5449 float input = static_cast<float>(*i); 5449 float input = static_cast<float>(*i);
5450 if (input < 18446744073709551616.0) { 5450 if (input < 18446744073709551616.0) {
5451 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5451 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5452 } 5452 }
5453 } 5453 }
5454 FOR_FLOAT32_INPUTS(j) { 5454 FOR_FLOAT32_INPUTS(j) {
5455 if (*j < 18446744073709551616.0 && *j >= 0) { 5455 if (*j < 18446744073709551616.0 && *j >= 0) {
5456 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j)); 5456 CHECK_EQ(static_cast<uint64_t>(*j), m.Call(*j));
5457 } 5457 }
5458 } 5458 }
5459 } 5459 }
5460 5460
5461 5461
5462 TEST(RunTruncateFloat64ToUint64) { 5462 TEST(RunTryTruncateFloat64ToUint64WithoutCheck) {
5463 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat64); 5463 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat64);
5464 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0))); 5464 m.Return(m.TruncateFloat64ToUint64(m.Parameter(0)));
5465 5465
5466 FOR_UINT64_INPUTS(j) { 5466 FOR_UINT64_INPUTS(j) {
5467 double input = static_cast<double>(*j); 5467 double input = static_cast<double>(*j);
5468 5468
5469 if (input < 18446744073709551616.0) { 5469 if (input < 18446744073709551616.0) {
5470 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5470 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5471 } 5471 }
5472 } 5472 }
5473 }
5474
5475
5476 TEST(RunTryTruncateFloat64ToUint64WithCheck) {
5477 int64_t success = 0;
5478 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64);
5479 Node* trunc = m.TryTruncateFloat64ToUint64(m.Parameter(0));
5480 Node* val = m.Projection(0, trunc);
5481 Node* check = m.Projection(1, trunc);
5482 m.StoreToPointer(&success, kMachInt64, check);
5483 m.Return(val);
5473 5484
5474 FOR_FLOAT64_INPUTS(i) { 5485 FOR_FLOAT64_INPUTS(i) {
5475 if (*i < 18446744073709551616.0 && *i >= 0) { 5486 if (*i < 18446744073709551616.0 && *i >= 0) {
5487 // Conversions within this range should succeed.
5476 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); 5488 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i));
5489 CHECK_NE(0, success);
5490 } else {
5491 m.Call(*i);
5492 CHECK_EQ(0, success);
5477 } 5493 }
5478 } 5494 }
5479 } 5495 }
5480 5496
5481 5497
5482 TEST(RunRoundInt64ToFloat32) { 5498 TEST(RunRoundInt64ToFloat32) {
5483 BufferedRawMachineAssemblerTester<float> m(kMachInt64); 5499 BufferedRawMachineAssemblerTester<float> m(kMachInt64);
5484 m.Return(m.RoundInt64ToFloat32(m.Parameter(0))); 5500 m.Return(m.RoundInt64ToFloat32(m.Parameter(0)));
5485 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); } 5501 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), m.Call(*i)); }
5486 } 5502 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
5750 Node* call = r.AddNode(r.common()->Call(desc), phi); 5766 Node* call = r.AddNode(r.common()->Call(desc), phi);
5751 r.Return(call); 5767 r.Return(call);
5752 5768
5753 CHECK_EQ(33, r.Call(1)); 5769 CHECK_EQ(33, r.Call(1));
5754 CHECK_EQ(44, r.Call(0)); 5770 CHECK_EQ(44, r.Call(0));
5755 } 5771 }
5756 5772
5757 } // namespace compiler 5773 } // namespace compiler
5758 } // namespace internal 5774 } // namespace internal
5759 } // namespace v8 5775 } // namespace v8
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | test/cctest/compiler/value-helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698