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

Side by Side Diff: test/cctest/compiler/test-representation-change.cc

Issue 2410883003: [turbofan] Remove minus zero check for rhs of CheckedInt32Sub. (Closed)
Patch Set: Adding TODO. Created 4 years, 2 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 | « src/compiler/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 <limits> 5 #include <limits>
6 6
7 #include "test/cctest/cctest.h" 7 #include "test/cctest/cctest.h"
8 #include "test/cctest/compiler/codegen-tester.h" 8 #include "test/cctest/compiler/codegen-tester.h"
9 #include "test/cctest/compiler/graph-builder-tester.h" 9 #include "test/cctest/compiler/graph-builder-tester.h"
10 #include "test/cctest/compiler/value-helper.h" 10 #include "test/cctest/compiler/value-helper.h"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 Node* use = r.Return(n); 436 Node* use = r.Return(n);
437 Node* c = r.changer()->GetRepresentationFor( 437 Node* c = r.changer()->GetRepresentationFor(
438 n, MachineRepresentation::kTagged, Type::Unsigned32(), use, 438 n, MachineRepresentation::kTagged, Type::Unsigned32(), use,
439 UseInfo(MachineRepresentation::kWord32, Truncation::None())); 439 UseInfo(MachineRepresentation::kWord32, Truncation::None()));
440 r.CheckUint32Constant(c, *i); 440 r.CheckUint32Constant(c, *i);
441 } 441 }
442 } 442 }
443 } 443 }
444 444
445 static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, 445 static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
446 Type* from_type, UseInfo use_info) {
447 RepresentationChangerTester r;
448
449 Node* n = r.Parameter();
450 Node* use = r.Return(n);
451 Node* c =
452 r.changer()->GetRepresentationFor(n, from, from_type, use, use_info);
453
454 CHECK_NE(c, n);
455 CHECK_EQ(expected, c->opcode());
456 CHECK_EQ(n, c->InputAt(0));
457
458 if (expected == IrOpcode::kCheckedFloat64ToInt32) {
459 CheckForMinusZeroMode mode =
460 from_type->Maybe(Type::MinusZero())
461 ? use_info.minus_zero_check()
462 : CheckForMinusZeroMode::kDontCheckForMinusZero;
463 CHECK_EQ(mode, CheckMinusZeroModeOf(c->op()));
464 }
465 }
466
467 static void CheckChange(IrOpcode::Value expected, MachineRepresentation from,
446 Type* from_type, MachineRepresentation to) { 468 Type* from_type, MachineRepresentation to) {
447 RepresentationChangerTester r; 469 CheckChange(expected, from, from_type, UseInfo(to, Truncation::None()));
448
449 Node* n = r.Parameter();
450 Node* use = r.Return(n);
451 Node* c = r.changer()->GetRepresentationFor(n, from, from_type, use,
452 UseInfo(to, Truncation::None()));
453
454 CHECK_NE(c, n);
455 CHECK_EQ(expected, c->opcode());
456 CHECK_EQ(n, c->InputAt(0));
457 } 470 }
458 471
459
460 static void CheckTwoChanges(IrOpcode::Value expected2, 472 static void CheckTwoChanges(IrOpcode::Value expected2,
461 IrOpcode::Value expected1, 473 IrOpcode::Value expected1,
462 MachineRepresentation from, Type* from_type, 474 MachineRepresentation from, Type* from_type,
463 MachineRepresentation to) { 475 MachineRepresentation to) {
464 RepresentationChangerTester r; 476 RepresentationChangerTester r;
465 477
466 Node* n = r.Parameter(); 478 Node* n = r.Parameter();
467 Node* use = r.Return(n); 479 Node* use = r.Return(n);
468 Node* c1 = r.changer()->GetRepresentationFor(n, from, from_type, use, 480 Node* c1 = r.changer()->GetRepresentationFor(n, from, from_type, use,
469 UseInfo(to, Truncation::None())); 481 UseInfo(to, Truncation::None()));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, 609 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64,
598 IrOpcode::kTruncateFloat64ToFloat32, 610 IrOpcode::kTruncateFloat64ToFloat32,
599 MachineRepresentation::kWord32, Type::Signed32(), 611 MachineRepresentation::kWord32, Type::Signed32(),
600 MachineRepresentation::kFloat32); 612 MachineRepresentation::kFloat32);
601 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, 613 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
602 IrOpcode::kTruncateFloat64ToWord32, 614 IrOpcode::kTruncateFloat64ToWord32,
603 MachineRepresentation::kFloat32, Type::Number(), 615 MachineRepresentation::kFloat32, Type::Number(),
604 MachineRepresentation::kWord32); 616 MachineRepresentation::kWord32);
605 } 617 }
606 618
619 static void TestMinusZeroCheck(IrOpcode::Value expected, Type* from_type) {
620 RepresentationChangerTester r;
621
622 CheckChange(expected, MachineRepresentation::kFloat64, from_type,
623 UseInfo::CheckedSignedSmallAsWord32(
624 CheckForMinusZeroMode::kCheckForMinusZero));
625
626 CheckChange(expected, MachineRepresentation::kFloat64, from_type,
627 UseInfo::CheckedSignedSmallAsWord32(
628 CheckForMinusZeroMode::kDontCheckForMinusZero));
629
630 CheckChange(expected, MachineRepresentation::kFloat64, from_type,
631 UseInfo::CheckedSigned32AsWord32(
632 CheckForMinusZeroMode::kCheckForMinusZero));
633
634 CheckChange(expected, MachineRepresentation::kFloat64, from_type,
635 UseInfo::CheckedSigned32AsWord32(
636 CheckForMinusZeroMode::kDontCheckForMinusZero));
637 }
638
639 TEST(MinusZeroCheck) {
640 TestMinusZeroCheck(IrOpcode::kCheckedFloat64ToInt32, Type::NumberOrOddball());
641 // PlainNumber cannot be minus zero so the minus zero check should be
642 // eliminated.
643 TestMinusZeroCheck(IrOpcode::kCheckedFloat64ToInt32, Type::PlainNumber());
644 }
607 645
608 TEST(Nops) { 646 TEST(Nops) {
609 RepresentationChangerTester r; 647 RepresentationChangerTester r;
610 648
611 // X -> X is always a nop for any single representation X. 649 // X -> X is always a nop for any single representation X.
612 for (size_t i = 0; i < arraysize(kMachineTypes); i++) { 650 for (size_t i = 0; i < arraysize(kMachineTypes); i++) {
613 r.CheckNop(kMachineTypes[i].representation(), Type::Number(), 651 r.CheckNop(kMachineTypes[i].representation(), Type::Number(),
614 kMachineTypes[i].representation()); 652 kMachineTypes[i].representation());
615 } 653 }
616 654
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 MachineRepresentation::kWord64); 706 MachineRepresentation::kWord64);
669 r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(), 707 r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(),
670 MachineRepresentation::kWord64); 708 MachineRepresentation::kWord64);
671 r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(), 709 r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(),
672 MachineRepresentation::kWord64); 710 MachineRepresentation::kWord64);
673 } 711 }
674 712
675 } // namespace compiler 713 } // namespace compiler
676 } // namespace internal 714 } // namespace internal
677 } // namespace v8 715 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698