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

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

Issue 669133004: [turbofan] Improve code generation for inline comparisons with zero. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 years, 1 month 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 | Annotate | Revision Log
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 <functional> 5 #include <functional>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/compiler/generic-node-inl.h" 9 #include "src/compiler/generic-node-inl.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 FOR_INT32_INPUTS(i) { 549 FOR_INT32_INPUTS(i) {
550 FOR_INT32_INPUTS(j) { 550 FOR_INT32_INPUTS(j) {
551 // Use uint32_t because signed overflow is UB in C. 551 // Use uint32_t because signed overflow is UB in C.
552 int expected = static_cast<int32_t>(*i + *j); 552 int expected = static_cast<int32_t>(*i + *j);
553 CHECK_EQ(expected, bt.call(*i, *j)); 553 CHECK_EQ(expected, bt.call(*i, *j));
554 } 554 }
555 } 555 }
556 } 556 }
557 557
558 558
559 TEST(RunInt32AddAndWord32EqualP) {
560 {
561 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32);
562 m.Return(m.Int32Add(m.Parameter(0),
563 m.Word32Equal(m.Parameter(1), m.Parameter(2))));
564 FOR_INT32_INPUTS(i) {
565 FOR_INT32_INPUTS(j) {
566 FOR_INT32_INPUTS(k) {
567 // Use uint32_t because signed overflow is UB in C.
568 int32_t const expected =
569 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k));
570 CHECK_EQ(expected, m.Call(*i, *j, *k));
571 }
572 }
573 }
574 }
575 {
576 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32);
577 m.Return(m.Int32Add(m.Word32Equal(m.Parameter(0), m.Parameter(1)),
578 m.Parameter(2)));
579 FOR_INT32_INPUTS(i) {
580 FOR_INT32_INPUTS(j) {
581 FOR_INT32_INPUTS(k) {
582 // Use uint32_t because signed overflow is UB in C.
583 int32_t const expected =
584 bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k));
585 CHECK_EQ(expected, m.Call(*i, *j, *k));
586 }
587 }
588 }
589 }
590 }
591
592
593 TEST(RunInt32AddAndWord32EqualImm) {
594 {
595 FOR_INT32_INPUTS(i) {
596 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
597 m.Return(m.Int32Add(m.Int32Constant(*i),
598 m.Word32Equal(m.Parameter(0), m.Parameter(1))));
599 FOR_INT32_INPUTS(j) {
600 FOR_INT32_INPUTS(k) {
601 // Use uint32_t because signed overflow is UB in C.
602 int32_t const expected =
603 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j == *k));
604 CHECK_EQ(expected, m.Call(*j, *k));
605 }
606 }
607 }
608 }
609 {
610 FOR_INT32_INPUTS(i) {
611 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
612 m.Return(m.Int32Add(m.Word32Equal(m.Int32Constant(*i), m.Parameter(0)),
613 m.Parameter(1)));
614 FOR_INT32_INPUTS(j) {
615 FOR_INT32_INPUTS(k) {
616 // Use uint32_t because signed overflow is UB in C.
617 int32_t const expected =
618 bit_cast<int32_t>((*i == *j) + bit_cast<uint32_t>(*k));
619 CHECK_EQ(expected, m.Call(*j, *k));
620 }
621 }
622 }
623 }
624 }
625
626
627 TEST(RunInt32AddAndWord32NotEqualP) {
628 {
629 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32);
630 m.Return(m.Int32Add(m.Parameter(0),
631 m.Word32NotEqual(m.Parameter(1), m.Parameter(2))));
632 FOR_INT32_INPUTS(i) {
633 FOR_INT32_INPUTS(j) {
634 FOR_INT32_INPUTS(k) {
635 // Use uint32_t because signed overflow is UB in C.
636 int32_t const expected =
637 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k));
638 CHECK_EQ(expected, m.Call(*i, *j, *k));
639 }
640 }
641 }
642 }
643 {
644 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32);
645 m.Return(m.Int32Add(m.Word32NotEqual(m.Parameter(0), m.Parameter(1)),
646 m.Parameter(2)));
647 FOR_INT32_INPUTS(i) {
648 FOR_INT32_INPUTS(j) {
649 FOR_INT32_INPUTS(k) {
650 // Use uint32_t because signed overflow is UB in C.
651 int32_t const expected =
652 bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k));
653 CHECK_EQ(expected, m.Call(*i, *j, *k));
654 }
655 }
656 }
657 }
658 }
659
660
661 TEST(RunInt32AddAndWord32NotEqualImm) {
662 {
663 FOR_INT32_INPUTS(i) {
664 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
665 m.Return(m.Int32Add(m.Int32Constant(*i),
666 m.Word32NotEqual(m.Parameter(0), m.Parameter(1))));
667 FOR_INT32_INPUTS(j) {
668 FOR_INT32_INPUTS(k) {
669 // Use uint32_t because signed overflow is UB in C.
670 int32_t const expected =
671 bit_cast<int32_t>(bit_cast<uint32_t>(*i) + (*j != *k));
672 CHECK_EQ(expected, m.Call(*j, *k));
673 }
674 }
675 }
676 }
677 {
678 FOR_INT32_INPUTS(i) {
679 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
680 m.Return(m.Int32Add(m.Word32NotEqual(m.Int32Constant(*i), m.Parameter(0)),
681 m.Parameter(1)));
682 FOR_INT32_INPUTS(j) {
683 FOR_INT32_INPUTS(k) {
684 // Use uint32_t because signed overflow is UB in C.
685 int32_t const expected =
686 bit_cast<int32_t>((*i != *j) + bit_cast<uint32_t>(*k));
687 CHECK_EQ(expected, m.Call(*j, *k));
688 }
689 }
690 }
691 }
692 }
693
694
559 TEST(RunInt32AddAndWord32SarP) { 695 TEST(RunInt32AddAndWord32SarP) {
560 { 696 {
561 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); 697 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32);
562 m.Return(m.Int32Add(m.Parameter(0), 698 m.Return(m.Int32Add(m.Parameter(0),
563 m.Word32Sar(m.Parameter(1), m.Parameter(2)))); 699 m.Word32Sar(m.Parameter(1), m.Parameter(2))));
564 FOR_UINT32_INPUTS(i) { 700 FOR_UINT32_INPUTS(i) {
565 FOR_INT32_INPUTS(j) { 701 FOR_INT32_INPUTS(j) {
566 FOR_UINT32_SHIFTS(shift) { 702 FOR_UINT32_SHIFTS(shift) {
567 // Use uint32_t because signed overflow is UB in C. 703 // Use uint32_t because signed overflow is UB in C.
568 int32_t expected = *i + (*j >> shift); 704 int32_t expected = *i + (*j >> shift);
(...skipping 3824 matching lines...) Expand 10 before | Expand all | Expand 10 after
4393 float actual = *i; 4529 float actual = *i;
4394 RawMachineAssemblerTester<int32_t> m; 4530 RawMachineAssemblerTester<int32_t> m;
4395 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); 4531 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected));
4396 m.Return(m.Int32Constant(0)); 4532 m.Return(m.Int32Constant(0));
4397 CHECK_EQ(0, m.Call()); 4533 CHECK_EQ(0, m.Call());
4398 CHECK_EQ(expected, actual); 4534 CHECK_EQ(expected, actual);
4399 } 4535 }
4400 } 4536 }
4401 4537
4402 #endif // V8_TURBOFAN_TARGET 4538 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698