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

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

Issue 2033703002: [compiler] Deal with some old TODOs in the typer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: another one Created 4 years, 6 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/cctest/compiler/test-simplified-lowering.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. 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/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
8 #include "src/compiler/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
9 #include "src/compiler/simplified-operator-reducer.h" 9 #include "src/compiler/simplified-operator-reducer.h"
10 #include "src/conversions-inl.h" 10 #include "src/conversions-inl.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 -127145950, -105483328, -32325, -26653, -23858, -23834, -22363, -19858, 84 -127145950, -105483328, -32325, -26653, -23858, -23834, -22363, -19858,
85 -19044, -18744, -15528, -5309, -3372, -2093, -104, -98, -97, -93, -84, -80, 85 -19044, -18744, -15528, -5309, -3372, -2093, -104, -98, -97, -93, -84, -80,
86 -78, -76, -72, -58, -57, -56, -55, -45, -40, -34, -32, -25, -24, -5, -2, 0, 86 -78, -76, -72, -58, -57, -56, -55, -45, -40, -34, -32, -25, -24, -5, -2, 0,
87 3, 10, 24, 34, 42, 46, 47, 48, 52, 56, 64, 65, 71, 76, 79, 81, 82, 97, 102, 87 3, 10, 24, 34, 42, 46, 47, 48, 52, 56, 64, 65, 71, 76, 79, 81, 82, 97, 102,
88 103, 104, 106, 107, 109, 116, 122, 3653, 4485, 12405, 16504, 26262, 28704, 88 103, 104, 106, 107, 109, 116, 122, 3653, 4485, 12405, 16504, 26262, 28704,
89 29755, 30554, 16476817, 605431957, 832401070, 873617242, 914205764, 89 29755, 30554, 16476817, 605431957, 832401070, 873617242, 914205764,
90 1062628108, 1087581664, 1488498068, 1534668023, 1661587028, 1696896187, 90 1062628108, 1087581664, 1488498068, 1534668023, 1661587028, 1696896187,
91 1866841746, 2032089723, 2147483647}; 91 1866841746, 2032089723, 2147483647};
92 92
93 93
94 const uint32_t kUint32Values[] = {
95 0x0, 0x5, 0x8, 0xc, 0xd, 0x26,
96 0x28, 0x29, 0x30, 0x34, 0x3e, 0x42,
97 0x50, 0x5b, 0x63, 0x71, 0x77, 0x7c,
98 0x83, 0x88, 0x96, 0x9c, 0xa3, 0xfa,
99 0x7a7, 0x165d, 0x234d, 0x3acb, 0x43a5, 0x4573,
100 0x5b4f, 0x5f14, 0x6996, 0x6c6e, 0x7289, 0x7b9a,
101 0x7bc9, 0x86bb, 0xa839, 0xaa41, 0xb03b, 0xc942,
102 0xce68, 0xcf4c, 0xd3ad, 0xdea3, 0xe90c, 0xed86,
103 0xfba5, 0x172dcc6, 0x114d8fc1, 0x182d6c9d, 0x1b1e3fad, 0x1db033bf,
104 0x1e1de755, 0x1f625c80, 0x28f6cf00, 0x2acb6a94, 0x2c20240e, 0x2f0fe54e,
105 0x31863a7c, 0x33325474, 0x3532fae3, 0x3bab82ea, 0x4c4b83a2, 0x4cd93d1e,
106 0x4f7331d4, 0x5491b09b, 0x57cc6ff9, 0x60d3b4dc, 0x653f5904, 0x690ae256,
107 0x69fe3276, 0x6bebf0ba, 0x6e2c69a3, 0x73b84ff7, 0x7b3a1924, 0x7ed032d9,
108 0x84dd734b, 0x8552ea53, 0x8680754f, 0x8e9660eb, 0x94fe2b9c, 0x972d30cf,
109 0x9b98c482, 0xb158667e, 0xb432932c, 0xb5b70989, 0xb669971a, 0xb7c359d1,
110 0xbeb15c0d, 0xc171c53d, 0xc743dd38, 0xc8e2af50, 0xc98e2df0, 0xd9d1cdf9,
111 0xdcc91049, 0xe46f396d, 0xee991950, 0xef64e521, 0xf7aeefc9, 0xffffffff};
112
113
114 const double kNaNs[] = {-std::numeric_limits<double>::quiet_NaN(), 94 const double kNaNs[] = {-std::numeric_limits<double>::quiet_NaN(),
115 std::numeric_limits<double>::quiet_NaN(), 95 std::numeric_limits<double>::quiet_NaN(),
116 bit_cast<double>(V8_UINT64_C(0x7FFFFFFFFFFFFFFF)), 96 bit_cast<double>(V8_UINT64_C(0x7FFFFFFFFFFFFFFF)),
117 bit_cast<double>(V8_UINT64_C(0xFFFFFFFFFFFFFFFF))}; 97 bit_cast<double>(V8_UINT64_C(0xFFFFFFFFFFFFFFFF))};
118 98
119 } // namespace 99 } // namespace
120 100
121 101
122 // ----------------------------------------------------------------------------- 102 // -----------------------------------------------------------------------------
123 // BooleanNot 103 // BooleanNot
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 ChangeTaggedToInt32WithChangeInt32ToTagged) { 287 ChangeTaggedToInt32WithChangeInt32ToTagged) {
308 Node* param0 = Parameter(0); 288 Node* param0 = Parameter(0);
309 Reduction reduction = Reduce(graph()->NewNode( 289 Reduction reduction = Reduce(graph()->NewNode(
310 simplified()->ChangeTaggedToInt32(), 290 simplified()->ChangeTaggedToInt32(),
311 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0))); 291 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0)));
312 ASSERT_TRUE(reduction.Changed()); 292 ASSERT_TRUE(reduction.Changed());
313 EXPECT_EQ(param0, reduction.replacement()); 293 EXPECT_EQ(param0, reduction.replacement());
314 } 294 }
315 295
316 296
317 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToInt32WithConstant) {
318 TRACED_FOREACH(double, n, kFloat64Values) {
319 Reduction reduction = Reduce(graph()->NewNode(
320 simplified()->ChangeTaggedToInt32(), NumberConstant(n)));
321 ASSERT_TRUE(reduction.Changed());
322 EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n)));
323 }
324 }
325
326
327 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToInt32WithNaNConstant) {
328 TRACED_FOREACH(double, nan, kNaNs) {
329 Reduction reduction = Reduce(graph()->NewNode(
330 simplified()->ChangeTaggedToInt32(), NumberConstant(nan)));
331 ASSERT_TRUE(reduction.Changed());
332 EXPECT_THAT(reduction.replacement(), IsInt32Constant(0));
333 }
334 }
335
336
337 // ----------------------------------------------------------------------------- 297 // -----------------------------------------------------------------------------
338 // ChangeTaggedToUint32 298 // ChangeTaggedToUint32
339 299
340 300
341 TEST_F(SimplifiedOperatorReducerTest, 301 TEST_F(SimplifiedOperatorReducerTest,
342 ChangeTaggedToUint32WithChangeFloat64ToTagged) { 302 ChangeTaggedToUint32WithChangeFloat64ToTagged) {
343 Node* param0 = Parameter(0); 303 Node* param0 = Parameter(0);
344 Reduction reduction = Reduce(graph()->NewNode( 304 Reduction reduction = Reduce(graph()->NewNode(
345 simplified()->ChangeTaggedToUint32(), 305 simplified()->ChangeTaggedToUint32(),
346 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); 306 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0)));
347 ASSERT_TRUE(reduction.Changed()); 307 ASSERT_TRUE(reduction.Changed());
348 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToUint32(param0)); 308 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToUint32(param0));
349 } 309 }
350 310
351 311
352 TEST_F(SimplifiedOperatorReducerTest, 312 TEST_F(SimplifiedOperatorReducerTest,
353 ChangeTaggedToUint32WithChangeUint32ToTagged) { 313 ChangeTaggedToUint32WithChangeUint32ToTagged) {
354 Node* param0 = Parameter(0); 314 Node* param0 = Parameter(0);
355 Reduction reduction = Reduce(graph()->NewNode( 315 Reduction reduction = Reduce(graph()->NewNode(
356 simplified()->ChangeTaggedToUint32(), 316 simplified()->ChangeTaggedToUint32(),
357 graph()->NewNode(simplified()->ChangeUint32ToTagged(), param0))); 317 graph()->NewNode(simplified()->ChangeUint32ToTagged(), param0)));
358 ASSERT_TRUE(reduction.Changed()); 318 ASSERT_TRUE(reduction.Changed());
359 EXPECT_EQ(param0, reduction.replacement()); 319 EXPECT_EQ(param0, reduction.replacement());
360 } 320 }
361 321
362 322
363 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToUint32WithConstant) {
364 TRACED_FOREACH(double, n, kFloat64Values) {
365 Reduction reduction = Reduce(graph()->NewNode(
366 simplified()->ChangeTaggedToUint32(), NumberConstant(n)));
367 ASSERT_TRUE(reduction.Changed());
368 EXPECT_THAT(reduction.replacement(),
369 IsInt32Constant(bit_cast<int32_t>(DoubleToUint32(n))));
370 }
371 }
372
373
374 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToUint32WithNaNConstant) {
375 TRACED_FOREACH(double, nan, kNaNs) {
376 Reduction reduction = Reduce(graph()->NewNode(
377 simplified()->ChangeTaggedToUint32(), NumberConstant(nan)));
378 ASSERT_TRUE(reduction.Changed());
379 EXPECT_THAT(reduction.replacement(), IsInt32Constant(0));
380 }
381 }
382
383
384 // ----------------------------------------------------------------------------- 323 // -----------------------------------------------------------------------------
385 // ChangeUint32ToTagged
386
387
388 TEST_F(SimplifiedOperatorReducerTest, ChangeUint32ToTagged) {
389 TRACED_FOREACH(uint32_t, n, kUint32Values) {
390 Reduction reduction =
391 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(),
392 Int32Constant(bit_cast<int32_t>(n))));
393 ASSERT_TRUE(reduction.Changed());
394 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastUI2D(n))));
395 }
396 }
397
398 // -----------------------------------------------------------------------------
399 // TruncateTaggedToWord32 324 // TruncateTaggedToWord32
400 325
401 TEST_F(SimplifiedOperatorReducerTest, 326 TEST_F(SimplifiedOperatorReducerTest,
402 TruncateTaggedToWord3WithChangeFloat64ToTagged) { 327 TruncateTaggedToWord3WithChangeFloat64ToTagged) {
403 Node* param0 = Parameter(0); 328 Node* param0 = Parameter(0);
404 Reduction reduction = Reduce(graph()->NewNode( 329 Reduction reduction = Reduce(graph()->NewNode(
405 simplified()->TruncateTaggedToWord32(), 330 simplified()->TruncateTaggedToWord32(),
406 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); 331 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0)));
407 ASSERT_TRUE(reduction.Changed()); 332 ASSERT_TRUE(reduction.Changed());
408 EXPECT_THAT(reduction.replacement(), IsTruncateFloat64ToWord32(param0)); 333 EXPECT_THAT(reduction.replacement(), IsTruncateFloat64ToWord32(param0));
409 } 334 }
410 335
411 TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) { 336 TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) {
412 TRACED_FOREACH(double, n, kFloat64Values) { 337 TRACED_FOREACH(double, n, kFloat64Values) {
413 Reduction reduction = Reduce(graph()->NewNode( 338 Reduction reduction = Reduce(graph()->NewNode(
414 simplified()->TruncateTaggedToWord32(), NumberConstant(n))); 339 simplified()->TruncateTaggedToWord32(), NumberConstant(n)));
415 ASSERT_TRUE(reduction.Changed()); 340 ASSERT_TRUE(reduction.Changed());
416 EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n))); 341 EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n)));
417 } 342 }
418 } 343 }
419 344
420 } // namespace compiler 345 } // namespace compiler
421 } // namespace internal 346 } // namespace internal
422 } // namespace v8 347 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-simplified-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698