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

Side by Side Diff: test/unittests/compiler/simplified-operator-reducer-unittest.cc

Issue 831203003: [turbofan] Fix incorrect minus zero handling in the unit tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months 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/unittests/compiler/machine-operator-reducer-unittest.cc ('k') | testing/gmock-support.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. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/js-graph.h" 5 #include "src/compiler/js-graph.h"
6 #include "src/compiler/simplified-operator.h" 6 #include "src/compiler/simplified-operator.h"
7 #include "src/compiler/simplified-operator-reducer.h" 7 #include "src/compiler/simplified-operator-reducer.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 #include "test/unittests/compiler/graph-unittest.h" 10 #include "test/unittests/compiler/graph-unittest.h"
11 #include "test/unittests/compiler/node-test-utils.h" 11 #include "test/unittests/compiler/node-test-utils.h"
12 #include "testing/gmock-support.h"
13
14 using testing::BitEq;
15
12 16
13 namespace v8 { 17 namespace v8 {
14 namespace internal { 18 namespace internal {
15 namespace compiler { 19 namespace compiler {
16 20
17 class SimplifiedOperatorReducerTest : public GraphTest { 21 class SimplifiedOperatorReducerTest : public GraphTest {
18 public: 22 public:
19 explicit SimplifiedOperatorReducerTest(int num_parameters = 1) 23 explicit SimplifiedOperatorReducerTest(int num_parameters = 1)
20 : GraphTest(num_parameters), simplified_(zone()) {} 24 : GraphTest(num_parameters), simplified_(zone()) {}
21 ~SimplifiedOperatorReducerTest() OVERRIDE {} 25 ~SimplifiedOperatorReducerTest() OVERRIDE {}
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 0xfba5, 0x172dcc6, 0x114d8fc1, 0x182d6c9d, 0x1b1e3fad, 0x1db033bf, 111 0xfba5, 0x172dcc6, 0x114d8fc1, 0x182d6c9d, 0x1b1e3fad, 0x1db033bf,
108 0x1e1de755, 0x1f625c80, 0x28f6cf00, 0x2acb6a94, 0x2c20240e, 0x2f0fe54e, 112 0x1e1de755, 0x1f625c80, 0x28f6cf00, 0x2acb6a94, 0x2c20240e, 0x2f0fe54e,
109 0x31863a7c, 0x33325474, 0x3532fae3, 0x3bab82ea, 0x4c4b83a2, 0x4cd93d1e, 113 0x31863a7c, 0x33325474, 0x3532fae3, 0x3bab82ea, 0x4c4b83a2, 0x4cd93d1e,
110 0x4f7331d4, 0x5491b09b, 0x57cc6ff9, 0x60d3b4dc, 0x653f5904, 0x690ae256, 114 0x4f7331d4, 0x5491b09b, 0x57cc6ff9, 0x60d3b4dc, 0x653f5904, 0x690ae256,
111 0x69fe3276, 0x6bebf0ba, 0x6e2c69a3, 0x73b84ff7, 0x7b3a1924, 0x7ed032d9, 115 0x69fe3276, 0x6bebf0ba, 0x6e2c69a3, 0x73b84ff7, 0x7b3a1924, 0x7ed032d9,
112 0x84dd734b, 0x8552ea53, 0x8680754f, 0x8e9660eb, 0x94fe2b9c, 0x972d30cf, 116 0x84dd734b, 0x8552ea53, 0x8680754f, 0x8e9660eb, 0x94fe2b9c, 0x972d30cf,
113 0x9b98c482, 0xb158667e, 0xb432932c, 0xb5b70989, 0xb669971a, 0xb7c359d1, 117 0x9b98c482, 0xb158667e, 0xb432932c, 0xb5b70989, 0xb669971a, 0xb7c359d1,
114 0xbeb15c0d, 0xc171c53d, 0xc743dd38, 0xc8e2af50, 0xc98e2df0, 0xd9d1cdf9, 118 0xbeb15c0d, 0xc171c53d, 0xc743dd38, 0xc8e2af50, 0xc98e2df0, 0xd9d1cdf9,
115 0xdcc91049, 0xe46f396d, 0xee991950, 0xef64e521, 0xf7aeefc9, 0xffffffff}; 119 0xdcc91049, 0xe46f396d, 0xee991950, 0xef64e521, 0xf7aeefc9, 0xffffffff};
116 120
117
118 MATCHER(IsNaN, std::string(negation ? "isn't" : "is") + " NaN") {
119 return std::isnan(arg);
120 }
121
122 } // namespace 121 } // namespace
123 122
124 123
125 // ----------------------------------------------------------------------------- 124 // -----------------------------------------------------------------------------
126 // Unary operators 125 // Unary operators
127 126
128 127
129 namespace { 128 namespace {
130 129
131 struct UnaryOperator { 130 struct UnaryOperator {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 263
265 // ----------------------------------------------------------------------------- 264 // -----------------------------------------------------------------------------
266 // ChangeFloat64ToTagged 265 // ChangeFloat64ToTagged
267 266
268 267
269 TEST_F(SimplifiedOperatorReducerTest, ChangeFloat64ToTaggedWithConstant) { 268 TEST_F(SimplifiedOperatorReducerTest, ChangeFloat64ToTaggedWithConstant) {
270 TRACED_FOREACH(double, n, kFloat64Values) { 269 TRACED_FOREACH(double, n, kFloat64Values) {
271 Reduction reduction = Reduce(graph()->NewNode( 270 Reduction reduction = Reduce(graph()->NewNode(
272 simplified()->ChangeFloat64ToTagged(), Float64Constant(n))); 271 simplified()->ChangeFloat64ToTagged(), Float64Constant(n)));
273 ASSERT_TRUE(reduction.Changed()); 272 ASSERT_TRUE(reduction.Changed());
274 EXPECT_THAT(reduction.replacement(), IsNumberConstant(n)); 273 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(n)));
275 } 274 }
276 } 275 }
277 276
278 277
279 // ----------------------------------------------------------------------------- 278 // -----------------------------------------------------------------------------
280 // ChangeInt32ToTagged 279 // ChangeInt32ToTagged
281 280
282 281
283 TEST_F(SimplifiedOperatorReducerTest, ChangeInt32ToTaggedWithConstant) { 282 TEST_F(SimplifiedOperatorReducerTest, ChangeInt32ToTaggedWithConstant) {
284 TRACED_FOREACH(int32_t, n, kInt32Values) { 283 TRACED_FOREACH(int32_t, n, kInt32Values) {
285 Reduction reduction = Reduce(graph()->NewNode( 284 Reduction reduction = Reduce(graph()->NewNode(
286 simplified()->ChangeInt32ToTagged(), Int32Constant(n))); 285 simplified()->ChangeInt32ToTagged(), Int32Constant(n)));
287 ASSERT_TRUE(reduction.Changed()); 286 ASSERT_TRUE(reduction.Changed());
288 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastI2D(n))); 287 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastI2D(n))));
289 } 288 }
290 } 289 }
291 290
292 291
293 // ----------------------------------------------------------------------------- 292 // -----------------------------------------------------------------------------
294 // ChangeTaggedToFloat64 293 // ChangeTaggedToFloat64
295 294
296 295
297 TEST_F(SimplifiedOperatorReducerTest, 296 TEST_F(SimplifiedOperatorReducerTest,
298 ChangeTaggedToFloat64WithChangeFloat64ToTagged) { 297 ChangeTaggedToFloat64WithChangeFloat64ToTagged) {
(...skipping 26 matching lines...) Expand all
325 ASSERT_TRUE(reduction.Changed()); 324 ASSERT_TRUE(reduction.Changed());
326 EXPECT_THAT(reduction.replacement(), IsChangeUint32ToFloat64(param0)); 325 EXPECT_THAT(reduction.replacement(), IsChangeUint32ToFloat64(param0));
327 } 326 }
328 327
329 328
330 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToFloat64WithConstant) { 329 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToFloat64WithConstant) {
331 TRACED_FOREACH(double, n, kFloat64Values) { 330 TRACED_FOREACH(double, n, kFloat64Values) {
332 Reduction reduction = Reduce(graph()->NewNode( 331 Reduction reduction = Reduce(graph()->NewNode(
333 simplified()->ChangeTaggedToFloat64(), NumberConstant(n))); 332 simplified()->ChangeTaggedToFloat64(), NumberConstant(n)));
334 ASSERT_TRUE(reduction.Changed()); 333 ASSERT_TRUE(reduction.Changed());
335 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(n)); 334 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(BitEq(n)));
336 } 335 }
337 } 336 }
338 337
339 338
340 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToFloat64WithNaNConstant1) { 339 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToFloat64WithNaNConstant1) {
341 Reduction reduction = 340 Reduction reduction =
342 Reduce(graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 341 Reduce(graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
343 NumberConstant(-base::OS::nan_value()))); 342 NumberConstant(-base::OS::nan_value())));
344 ASSERT_TRUE(reduction.Changed()); 343 ASSERT_TRUE(reduction.Changed());
345 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(IsNaN())); 344 EXPECT_THAT(reduction.replacement(),
345 IsFloat64Constant(BitEq(-base::OS::nan_value())));
346 } 346 }
347 347
348 348
349 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToFloat64WithNaNConstant2) { 349 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToFloat64WithNaNConstant2) {
350 Reduction reduction = 350 Reduction reduction =
351 Reduce(graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 351 Reduce(graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
352 NumberConstant(base::OS::nan_value()))); 352 NumberConstant(base::OS::nan_value())));
353 ASSERT_TRUE(reduction.Changed()); 353 ASSERT_TRUE(reduction.Changed());
354 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(IsNaN())); 354 EXPECT_THAT(reduction.replacement(),
355 IsFloat64Constant(BitEq(base::OS::nan_value())));
355 } 356 }
356 357
357 358
358 // ----------------------------------------------------------------------------- 359 // -----------------------------------------------------------------------------
359 // ChangeTaggedToInt32 360 // ChangeTaggedToInt32
360 361
361 362
362 TEST_F(SimplifiedOperatorReducerTest, 363 TEST_F(SimplifiedOperatorReducerTest,
363 ChangeTaggedToInt32WithChangeFloat64ToTagged) { 364 ChangeTaggedToInt32WithChangeFloat64ToTagged) {
364 Node* param0 = Parameter(0); 365 Node* param0 = Parameter(0);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // ----------------------------------------------------------------------------- 468 // -----------------------------------------------------------------------------
468 // ChangeUint32ToTagged 469 // ChangeUint32ToTagged
469 470
470 471
471 TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) { 472 TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) {
472 TRACED_FOREACH(uint32_t, n, kUint32Values) { 473 TRACED_FOREACH(uint32_t, n, kUint32Values) {
473 Reduction reduction = 474 Reduction reduction =
474 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), 475 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(),
475 Int32Constant(bit_cast<int32_t>(n)))); 476 Int32Constant(bit_cast<int32_t>(n))));
476 ASSERT_TRUE(reduction.Changed()); 477 ASSERT_TRUE(reduction.Changed());
477 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastUI2D(n))); 478 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n))));
478 } 479 }
479 } 480 }
480 481
481 } // namespace compiler 482 } // namespace compiler
482 } // namespace internal 483 } // namespace internal
483 } // namespace v8 484 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/machine-operator-reducer-unittest.cc ('k') | testing/gmock-support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698