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

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

Issue 1495213003: [turbofan] Changed TruncateFloat64ToInt64 to TryTruncateFloat64ToInt64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Generate better arm64 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
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 5390 matching lines...) Expand 10 before | Expand all | Expand 10 after
5401 } 5401 }
5402 } 5402 }
5403 FOR_FLOAT32_INPUTS(j) { 5403 FOR_FLOAT32_INPUTS(j) {
5404 if (*j < 9223372036854775808.0 && *j > -9223372036854775809.0) { 5404 if (*j < 9223372036854775808.0 && *j > -9223372036854775809.0) {
5405 CHECK_EQ(static_cast<int64_t>(*j), m.Call(*j)); 5405 CHECK_EQ(static_cast<int64_t>(*j), m.Call(*j));
5406 } 5406 }
5407 } 5407 }
5408 } 5408 }
5409 5409
5410 5410
5411 TEST(RunTruncateFloat64ToInt64) { 5411 TEST(RunTryTruncateFloat64ToInt64WithoutCheck) {
5412 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5412 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64);
5413 m.Return(m.TruncateFloat64ToInt64(m.Parameter(0))); 5413 m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0)));
5414 5414
5415 FOR_INT64_INPUTS(i) { 5415 FOR_INT64_INPUTS(i) {
5416 double input = static_cast<double>(*i); 5416 double input = static_cast<double>(*i);
5417 CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); 5417 CHECK_EQ(static_cast<int64_t>(input), m.Call(input));
5418 } 5418 }
5419 } 5419 }
5420 5420
5421 5421
5422 TEST(RunTryTruncateFloat64ToInt64WithCheck) {
5423 int64_t success = 0;
5424 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64);
5425 Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0));
5426 Node* val = m.Projection(0, trunc);
5427 Node* check = m.Projection(1, trunc);
5428 m.StoreToPointer(&success, kMachInt64, check);
5429 m.Return(val);
5430
5431 FOR_FLOAT64_INPUTS(i) {
5432 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) {
5433 // Conversions within this range
5434 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i));
5435 CHECK_NE(0, success);
5436 } else {
5437 m.Call(*i);
5438 CHECK_EQ(0, success);
5439 }
5440 }
5441 }
5442
5443
5422 TEST(RunTruncateFloat32ToUint64) { 5444 TEST(RunTruncateFloat32ToUint64) {
5423 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32); 5445 BufferedRawMachineAssemblerTester<uint64_t> m(kMachFloat32);
5424 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0))); 5446 m.Return(m.TruncateFloat32ToUint64(m.Parameter(0)));
5425 5447
5426 FOR_UINT64_INPUTS(i) { 5448 FOR_UINT64_INPUTS(i) {
5427 float input = static_cast<float>(*i); 5449 float input = static_cast<float>(*i);
5428 if (input < 18446744073709551616.0) { 5450 if (input < 18446744073709551616.0) {
5429 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input)); 5451 CHECK_EQ(static_cast<uint64_t>(input), m.Call(input));
5430 } 5452 }
5431 } 5453 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
5728 Node* call = r.AddNode(r.common()->Call(desc), phi); 5750 Node* call = r.AddNode(r.common()->Call(desc), phi);
5729 r.Return(call); 5751 r.Return(call);
5730 5752
5731 CHECK_EQ(33, r.Call(1)); 5753 CHECK_EQ(33, r.Call(1));
5732 CHECK_EQ(44, r.Call(0)); 5754 CHECK_EQ(44, r.Call(0));
5733 } 5755 }
5734 5756
5735 } // namespace compiler 5757 } // namespace compiler
5736 } // namespace internal 5758 } // namespace internal
5737 } // namespace v8 5759 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698