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

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

Issue 1504363002: [turbofan] Change TruncateFloat32ToInt64 to TryTruncateFloat32ToInt64. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed bad code in the mips 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 | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | 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 5369 matching lines...) Expand 10 before | Expand all | Expand 10 after
5380 5380
5381 5381
5382 TEST(RunBitcastFloat64ToInt64) { 5382 TEST(RunBitcastFloat64ToInt64) {
5383 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5383 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64);
5384 5384
5385 m.Return(m.BitcastFloat64ToInt64(m.Parameter(0))); 5385 m.Return(m.BitcastFloat64ToInt64(m.Parameter(0)));
5386 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast<int64_t>(*i), m.Call(*i)); } 5386 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast<int64_t>(*i), m.Call(*i)); }
5387 } 5387 }
5388 5388
5389 5389
5390 TEST(RunTruncateFloat32ToInt64) { 5390 TEST(RunTryTruncateFloat32ToInt64WithoutCheck) {
5391 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32); 5391 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32);
5392 m.Return(m.TruncateFloat32ToInt64(m.Parameter(0))); 5392 m.Return(m.TryTruncateFloat32ToInt64(m.Parameter(0)));
5393 5393
5394 FOR_INT64_INPUTS(i) { 5394 FOR_INT64_INPUTS(i) {
5395 float input = static_cast<float>(*i); 5395 float input = static_cast<float>(*i);
5396 if (input < 9223372036854775808.0 && input > -9223372036854775809.0) { 5396 if (input < 9223372036854775808.0 && input > -9223372036854775809.0) {
5397 CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); 5397 CHECK_EQ(static_cast<int64_t>(input), m.Call(input));
5398 } 5398 }
5399 } 5399 }
5400 FOR_FLOAT32_INPUTS(j) { 5400 }
5401 if (*j < 9223372036854775808.0 && *j > -9223372036854775809.0) { 5401
5402 CHECK_EQ(static_cast<int64_t>(*j), m.Call(*j)); 5402
5403 TEST(RunTryTruncateFloat32ToInt64WithCheck) {
5404 int64_t success = 0;
5405 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32);
5406 Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0));
5407 Node* val = m.Projection(0, trunc);
5408 Node* check = m.Projection(1, trunc);
5409 m.StoreToPointer(&success, kMachInt64, check);
5410 m.Return(val);
5411
5412 FOR_FLOAT32_INPUTS(i) {
5413 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) {
5414 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i));
5415 CHECK_NE(0, success);
5416 } else {
5417 m.Call(*i);
5418 CHECK_EQ(0, success);
5403 } 5419 }
5404 } 5420 }
5405 } 5421 }
5406 5422
5407 5423
5408 TEST(RunTryTruncateFloat64ToInt64WithoutCheck) { 5424 TEST(RunTryTruncateFloat64ToInt64WithoutCheck) {
5409 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); 5425 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64);
5410 m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0))); 5426 m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0)));
5411 5427
5412 FOR_INT64_INPUTS(i) { 5428 FOR_INT64_INPUTS(i) {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
5763 Node* call = r.AddNode(r.common()->Call(desc), phi); 5779 Node* call = r.AddNode(r.common()->Call(desc), phi);
5764 r.Return(call); 5780 r.Return(call);
5765 5781
5766 CHECK_EQ(33, r.Call(1)); 5782 CHECK_EQ(33, r.Call(1));
5767 CHECK_EQ(44, r.Call(0)); 5783 CHECK_EQ(44, r.Call(0));
5768 } 5784 }
5769 5785
5770 } // namespace compiler 5786 } // namespace compiler
5771 } // namespace internal 5787 } // namespace internal
5772 } // namespace v8 5788 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698