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

Side by Side Diff: test/cctest/compiler/test-branch-combine.cc

Issue 2065243005: [arm64] Generate adds/ands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove static Created 4 years, 5 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
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 "test/cctest/cctest.h" 5 #include "test/cctest/cctest.h"
6 #include "test/cctest/compiler/codegen-tester.h" 6 #include "test/cctest/compiler/codegen-tester.h"
7 #include "test/cctest/compiler/value-helper.h" 7 #include "test/cctest/compiler/value-helper.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 RawMachineLabel blocka, blockb; 471 RawMachineLabel blocka, blockb;
472 m.Branch(equal, &blocka, &blockb); 472 m.Branch(equal, &blocka, &blockb);
473 m.Bind(&blocka); 473 m.Bind(&blocka);
474 m.Return(m.Int32Constant(42)); 474 m.Return(m.Int32Constant(42));
475 m.Bind(&blockb); 475 m.Bind(&blockb);
476 m.Return(m.Int32Constant(0)); 476 m.Return(m.Int32Constant(0));
477 477
478 CHECK_EQ(42, m.Call()); 478 CHECK_EQ(42, m.Call());
479 } 479 }
480 480
481 TEST(BranchCombineInt32AddLessThanZero) {
482 int32_t t_constant = -1033;
483 int32_t f_constant = 825118;
484
485 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
486 MachineType::Int32());
487 Node* a = m.Parameter(0);
488 Node* b = m.Parameter(1);
489 Node* add = m.Int32Add(a, b);
490 Node* compare = m.Int32LessThan(add, m.Int32Constant(0));
491
492 RawMachineLabel blocka, blockb;
493 m.Branch(compare, &blocka, &blockb);
494 m.Bind(&blocka);
495 m.Return(m.Int32Constant(t_constant));
496 m.Bind(&blockb);
497 m.Return(m.Int32Constant(f_constant));
498
499 FOR_INT32_INPUTS(i) {
500 FOR_INT32_INPUTS(j) {
501 int32_t a = *i;
502 int32_t b = *j;
503 int32_t expect = (a + b < 0) ? t_constant : f_constant;
504 CHECK_EQ(expect, m.Call(a, b));
505 }
506 }
507 }
508
509 TEST(BranchCombineInt32AddGreaterThanOrEqualZero) {
510 int32_t t_constant = -1033;
511 int32_t f_constant = 825118;
512
513 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
514 MachineType::Int32());
515 Node* a = m.Parameter(0);
516 Node* b = m.Parameter(1);
517 Node* add = m.Int32Add(a, b);
518 Node* compare = m.Int32GreaterThanOrEqual(add, m.Int32Constant(0));
519
520 RawMachineLabel blocka, blockb;
521 m.Branch(compare, &blocka, &blockb);
522 m.Bind(&blocka);
523 m.Return(m.Int32Constant(t_constant));
524 m.Bind(&blockb);
525 m.Return(m.Int32Constant(f_constant));
526
527 FOR_INT32_INPUTS(i) {
528 FOR_INT32_INPUTS(j) {
529 int32_t a = *i;
530 int32_t b = *j;
531 int32_t expect = (a + b >= 0) ? t_constant : f_constant;
532 CHECK_EQ(expect, m.Call(a, b));
533 }
534 }
535 }
536
537 TEST(BranchCombineInt32ZeroGreaterThanAdd) {
538 int32_t t_constant = -1033;
539 int32_t f_constant = 825118;
540
541 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
542 MachineType::Int32());
543 Node* a = m.Parameter(0);
544 Node* b = m.Parameter(1);
545 Node* add = m.Int32Add(a, b);
546 Node* compare = m.Int32GreaterThan(m.Int32Constant(0), add);
547
548 RawMachineLabel blocka, blockb;
549 m.Branch(compare, &blocka, &blockb);
550 m.Bind(&blocka);
551 m.Return(m.Int32Constant(t_constant));
552 m.Bind(&blockb);
553 m.Return(m.Int32Constant(f_constant));
554
555 FOR_INT32_INPUTS(i) {
556 FOR_INT32_INPUTS(j) {
557 int32_t a = *i;
558 int32_t b = *j;
559 int32_t expect = (0 > a + b) ? t_constant : f_constant;
560 CHECK_EQ(expect, m.Call(a, b));
561 }
562 }
563 }
564
565 TEST(BranchCombineInt32ZeroLessThanOrEqualAdd) {
566 int32_t t_constant = -1033;
567 int32_t f_constant = 825118;
568
569 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
570 MachineType::Int32());
571 Node* a = m.Parameter(0);
572 Node* b = m.Parameter(1);
573 Node* add = m.Int32Add(a, b);
574 Node* compare = m.Int32LessThanOrEqual(m.Int32Constant(0), add);
575
576 RawMachineLabel blocka, blockb;
577 m.Branch(compare, &blocka, &blockb);
578 m.Bind(&blocka);
579 m.Return(m.Int32Constant(t_constant));
580 m.Bind(&blockb);
581 m.Return(m.Int32Constant(f_constant));
582
583 FOR_INT32_INPUTS(i) {
584 FOR_INT32_INPUTS(j) {
585 int32_t a = *i;
586 int32_t b = *j;
587 int32_t expect = (0 <= a + b) ? t_constant : f_constant;
588 CHECK_EQ(expect, m.Call(a, b));
589 }
590 }
591 }
592
593 TEST(BranchCombineUint32AddLessThanOrEqualZero) {
594 int32_t t_constant = -1033;
595 int32_t f_constant = 825118;
596
597 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
598 MachineType::Uint32());
599 Node* a = m.Parameter(0);
600 Node* b = m.Parameter(1);
601 Node* add = m.Int32Add(a, b);
602 Node* compare = m.Uint32LessThanOrEqual(add, m.Int32Constant(0));
603
604 RawMachineLabel blocka, blockb;
605 m.Branch(compare, &blocka, &blockb);
606 m.Bind(&blocka);
607 m.Return(m.Int32Constant(t_constant));
608 m.Bind(&blockb);
609 m.Return(m.Int32Constant(f_constant));
610
611 FOR_INT32_INPUTS(i) {
612 FOR_INT32_INPUTS(j) {
613 uint32_t a = *i;
614 uint32_t b = *j;
615 int32_t expect = (a + b <= 0) ? t_constant : f_constant;
616 CHECK_EQ(expect, m.Call(a, b));
617 }
618 }
619 }
620
621 TEST(BranchCombineUint32AddGreaterThanZero) {
622 int32_t t_constant = -1033;
623 int32_t f_constant = 825118;
624
625 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
626 MachineType::Uint32());
627 Node* a = m.Parameter(0);
628 Node* b = m.Parameter(1);
629 Node* add = m.Int32Add(a, b);
630 Node* compare = m.Uint32GreaterThan(add, m.Int32Constant(0));
631
632 RawMachineLabel blocka, blockb;
633 m.Branch(compare, &blocka, &blockb);
634 m.Bind(&blocka);
635 m.Return(m.Int32Constant(t_constant));
636 m.Bind(&blockb);
637 m.Return(m.Int32Constant(f_constant));
638
639 FOR_INT32_INPUTS(i) {
640 FOR_INT32_INPUTS(j) {
641 uint32_t a = *i;
642 uint32_t b = *j;
643 int32_t expect = (a + b > 0) ? t_constant : f_constant;
644 CHECK_EQ(expect, m.Call(a, b));
645 }
646 }
647 }
648
649 TEST(BranchCombineUint32ZeroGreaterThanOrEqualAdd) {
650 int32_t t_constant = -1033;
651 int32_t f_constant = 825118;
652
653 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
654 MachineType::Uint32());
655 Node* a = m.Parameter(0);
656 Node* b = m.Parameter(1);
657 Node* add = m.Int32Add(a, b);
658 Node* compare = m.Uint32GreaterThanOrEqual(m.Int32Constant(0), add);
659
660 RawMachineLabel blocka, blockb;
661 m.Branch(compare, &blocka, &blockb);
662 m.Bind(&blocka);
663 m.Return(m.Int32Constant(t_constant));
664 m.Bind(&blockb);
665 m.Return(m.Int32Constant(f_constant));
666
667 FOR_INT32_INPUTS(i) {
668 FOR_INT32_INPUTS(j) {
669 uint32_t a = *i;
670 uint32_t b = *j;
671 int32_t expect = (0 >= a + b) ? t_constant : f_constant;
672 CHECK_EQ(expect, m.Call(a, b));
673 }
674 }
675 }
676
677 TEST(BranchCombineUint32ZeroLessThanAdd) {
678 int32_t t_constant = -1033;
679 int32_t f_constant = 825118;
680
681 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
682 MachineType::Uint32());
683 Node* a = m.Parameter(0);
684 Node* b = m.Parameter(1);
685 Node* add = m.Int32Add(a, b);
686 Node* compare = m.Uint32LessThan(m.Int32Constant(0), add);
687
688 RawMachineLabel blocka, blockb;
689 m.Branch(compare, &blocka, &blockb);
690 m.Bind(&blocka);
691 m.Return(m.Int32Constant(t_constant));
692 m.Bind(&blockb);
693 m.Return(m.Int32Constant(f_constant));
694
695 FOR_INT32_INPUTS(i) {
696 FOR_INT32_INPUTS(j) {
697 uint32_t a = *i;
698 uint32_t b = *j;
699 int32_t expect = (0 < a + b) ? t_constant : f_constant;
700 CHECK_EQ(expect, m.Call(a, b));
701 }
702 }
703 }
704
705 TEST(BranchCombineWord32AndLessThanZero) {
706 int32_t t_constant = -1033;
707 int32_t f_constant = 825118;
708
709 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
710 MachineType::Int32());
711 Node* a = m.Parameter(0);
712 Node* b = m.Parameter(1);
713 Node* add = m.Word32And(a, b);
714 Node* compare = m.Int32LessThan(add, m.Int32Constant(0));
715
716 RawMachineLabel blocka, blockb;
717 m.Branch(compare, &blocka, &blockb);
718 m.Bind(&blocka);
719 m.Return(m.Int32Constant(t_constant));
720 m.Bind(&blockb);
721 m.Return(m.Int32Constant(f_constant));
722
723 FOR_INT32_INPUTS(i) {
724 FOR_INT32_INPUTS(j) {
725 int32_t a = *i;
726 int32_t b = *j;
727 int32_t expect = ((a & b) < 0) ? t_constant : f_constant;
728 CHECK_EQ(expect, m.Call(a, b));
729 }
730 }
731 }
732
733 TEST(BranchCombineWord32AndGreaterThanOrEqualZero) {
734 int32_t t_constant = -1033;
735 int32_t f_constant = 825118;
736
737 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
738 MachineType::Int32());
739 Node* a = m.Parameter(0);
740 Node* b = m.Parameter(1);
741 Node* add = m.Word32And(a, b);
742 Node* compare = m.Int32GreaterThanOrEqual(add, m.Int32Constant(0));
743
744 RawMachineLabel blocka, blockb;
745 m.Branch(compare, &blocka, &blockb);
746 m.Bind(&blocka);
747 m.Return(m.Int32Constant(t_constant));
748 m.Bind(&blockb);
749 m.Return(m.Int32Constant(f_constant));
750
751 FOR_INT32_INPUTS(i) {
752 FOR_INT32_INPUTS(j) {
753 int32_t a = *i;
754 int32_t b = *j;
755 int32_t expect = ((a & b) >= 0) ? t_constant : f_constant;
756 CHECK_EQ(expect, m.Call(a, b));
757 }
758 }
759 }
760
761 TEST(BranchCombineInt32ZeroGreaterThanAnd) {
762 int32_t t_constant = -1033;
763 int32_t f_constant = 825118;
764
765 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
766 MachineType::Int32());
767 Node* a = m.Parameter(0);
768 Node* b = m.Parameter(1);
769 Node* add = m.Word32And(a, b);
770 Node* compare = m.Int32GreaterThan(m.Int32Constant(0), add);
771
772 RawMachineLabel blocka, blockb;
773 m.Branch(compare, &blocka, &blockb);
774 m.Bind(&blocka);
775 m.Return(m.Int32Constant(t_constant));
776 m.Bind(&blockb);
777 m.Return(m.Int32Constant(f_constant));
778
779 FOR_INT32_INPUTS(i) {
780 FOR_INT32_INPUTS(j) {
781 int32_t a = *i;
782 int32_t b = *j;
783 int32_t expect = (0 > (a & b)) ? t_constant : f_constant;
784 CHECK_EQ(expect, m.Call(a, b));
785 }
786 }
787 }
788
789 TEST(BranchCombineInt32ZeroLessThanOrEqualAnd) {
790 int32_t t_constant = -1033;
791 int32_t f_constant = 825118;
792
793 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(),
794 MachineType::Int32());
795 Node* a = m.Parameter(0);
796 Node* b = m.Parameter(1);
797 Node* add = m.Word32And(a, b);
798 Node* compare = m.Int32LessThanOrEqual(m.Int32Constant(0), add);
799
800 RawMachineLabel blocka, blockb;
801 m.Branch(compare, &blocka, &blockb);
802 m.Bind(&blocka);
803 m.Return(m.Int32Constant(t_constant));
804 m.Bind(&blockb);
805 m.Return(m.Int32Constant(f_constant));
806
807 FOR_INT32_INPUTS(i) {
808 FOR_INT32_INPUTS(j) {
809 int32_t a = *i;
810 int32_t b = *j;
811 int32_t expect = (0 <= (a & b)) ? t_constant : f_constant;
812 CHECK_EQ(expect, m.Call(a, b));
813 }
814 }
815 }
816
817 TEST(BranchCombineUint32AndLessThanOrEqualZero) {
818 int32_t t_constant = -1033;
819 int32_t f_constant = 825118;
820
821 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
822 MachineType::Uint32());
823 Node* a = m.Parameter(0);
824 Node* b = m.Parameter(1);
825 Node* add = m.Word32And(a, b);
826 Node* compare = m.Uint32LessThanOrEqual(add, m.Int32Constant(0));
827
828 RawMachineLabel blocka, blockb;
829 m.Branch(compare, &blocka, &blockb);
830 m.Bind(&blocka);
831 m.Return(m.Int32Constant(t_constant));
832 m.Bind(&blockb);
833 m.Return(m.Int32Constant(f_constant));
834
835 FOR_INT32_INPUTS(i) {
836 FOR_INT32_INPUTS(j) {
837 uint32_t a = *i;
838 uint32_t b = *j;
839 int32_t expect = ((a & b) <= 0) ? t_constant : f_constant;
840 CHECK_EQ(expect, m.Call(a, b));
841 }
842 }
843 }
844
845 TEST(BranchCombineUint32AndGreaterThanZero) {
846 int32_t t_constant = -1033;
847 int32_t f_constant = 825118;
848
849 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
850 MachineType::Uint32());
851 Node* a = m.Parameter(0);
852 Node* b = m.Parameter(1);
853 Node* add = m.Word32And(a, b);
854 Node* compare = m.Uint32GreaterThan(add, m.Int32Constant(0));
855
856 RawMachineLabel blocka, blockb;
857 m.Branch(compare, &blocka, &blockb);
858 m.Bind(&blocka);
859 m.Return(m.Int32Constant(t_constant));
860 m.Bind(&blockb);
861 m.Return(m.Int32Constant(f_constant));
862
863 FOR_INT32_INPUTS(i) {
864 FOR_INT32_INPUTS(j) {
865 uint32_t a = *i;
866 uint32_t b = *j;
867 int32_t expect = ((a & b) > 0) ? t_constant : f_constant;
868 CHECK_EQ(expect, m.Call(a, b));
869 }
870 }
871 }
872
873 TEST(BranchCombineUint32ZeroGreaterThanOrEqualAnd) {
874 int32_t t_constant = -1033;
875 int32_t f_constant = 825118;
876
877 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
878 MachineType::Uint32());
879 Node* a = m.Parameter(0);
880 Node* b = m.Parameter(1);
881 Node* add = m.Word32And(a, b);
882 Node* compare = m.Uint32GreaterThanOrEqual(m.Int32Constant(0), add);
883
884 RawMachineLabel blocka, blockb;
885 m.Branch(compare, &blocka, &blockb);
886 m.Bind(&blocka);
887 m.Return(m.Int32Constant(t_constant));
888 m.Bind(&blockb);
889 m.Return(m.Int32Constant(f_constant));
890
891 FOR_INT32_INPUTS(i) {
892 FOR_INT32_INPUTS(j) {
893 uint32_t a = *i;
894 uint32_t b = *j;
895 int32_t expect = (0 >= (a & b)) ? t_constant : f_constant;
896 CHECK_EQ(expect, m.Call(a, b));
897 }
898 }
899 }
900
901 TEST(BranchCombineUint32ZeroLessThanAnd) {
902 int32_t t_constant = -1033;
903 int32_t f_constant = 825118;
904
905 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
906 MachineType::Uint32());
907 Node* a = m.Parameter(0);
908 Node* b = m.Parameter(1);
909 Node* add = m.Word32And(a, b);
910 Node* compare = m.Uint32LessThan(m.Int32Constant(0), add);
911
912 RawMachineLabel blocka, blockb;
913 m.Branch(compare, &blocka, &blockb);
914 m.Bind(&blocka);
915 m.Return(m.Int32Constant(t_constant));
916 m.Bind(&blockb);
917 m.Return(m.Int32Constant(f_constant));
918
919 FOR_INT32_INPUTS(i) {
920 FOR_INT32_INPUTS(j) {
921 uint32_t a = *i;
922 uint32_t b = *j;
923 int32_t expect = (0 < (a & b)) ? t_constant : f_constant;
924 CHECK_EQ(expect, m.Call(a, b));
925 }
926 }
927 }
928
481 } // namespace compiler 929 } // namespace compiler
482 } // namespace internal 930 } // namespace internal
483 } // namespace v8 931 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector-impl.h ('k') | test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698