| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.h" |
| 6 #include "test/cctest/cctest.h" | |
| 7 | 6 |
| 8 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
| 9 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
| 11 #include "src/compiler/generic-node.h" | 10 #include "src/compiler/generic-node.h" |
| 12 #include "src/compiler/graph.h" | 11 #include "src/compiler/graph.h" |
| 13 #include "src/compiler/graph-visualizer.h" | 12 #include "src/compiler/graph-visualizer.h" |
| 14 #include "src/compiler/js-operator.h" | 13 #include "src/compiler/js-operator.h" |
| 15 #include "src/compiler/machine-operator.h" | |
| 16 #include "src/compiler/node.h" | 14 #include "src/compiler/node.h" |
| 15 #include "src/compiler/opcodes.h" |
| 17 #include "src/compiler/operator.h" | 16 #include "src/compiler/operator.h" |
| 18 #include "src/compiler/schedule.h" | 17 #include "src/compiler/schedule.h" |
| 19 #include "src/compiler/scheduler.h" | 18 #include "src/compiler/scheduler.h" |
| 20 #include "src/compiler/simplified-operator.h" | 19 #include "src/compiler/simplified-operator.h" |
| 21 #include "src/compiler/verifier.h" | 20 #include "src/compiler/verifier.h" |
| 21 #include "test/cctest/cctest.h" |
| 22 | 22 |
| 23 using namespace v8::internal; | 23 using namespace v8::internal; |
| 24 using namespace v8::internal::compiler; | 24 using namespace v8::internal::compiler; |
| 25 | 25 |
| 26 Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0, 0, 1, |
| 27 0, 0); |
| 28 |
| 26 // TODO(titzer): pull RPO tests out to their own file. | 29 // TODO(titzer): pull RPO tests out to their own file. |
| 27 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, | 30 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, |
| 28 bool loops_allowed) { | 31 bool loops_allowed) { |
| 29 CHECK(expected == order->size()); | 32 CHECK(expected == order->size()); |
| 30 for (int i = 0; i < static_cast<int>(order->size()); i++) { | 33 for (int i = 0; i < static_cast<int>(order->size()); i++) { |
| 31 CHECK(order->at(i)->rpo_number() == i); | 34 CHECK(order->at(i)->rpo_number() == i); |
| 32 if (!loops_allowed) { | 35 if (!loops_allowed) { |
| 33 CHECK_EQ(NULL, order->at(i)->loop_end()); | 36 CHECK_EQ(NULL, order->at(i)->loop_end()); |
| 34 CHECK_EQ(NULL, order->at(i)->loop_header()); | 37 CHECK_EQ(NULL, order->at(i)->loop_header()); |
| 35 } | 38 } |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 ComputeAndVerifySchedule(62, &graph); | 1567 ComputeAndVerifySchedule(62, &graph); |
| 1565 } | 1568 } |
| 1566 | 1569 |
| 1567 | 1570 |
| 1568 TEST(BuildScheduleSimpleLoopWithCodeMotion) { | 1571 TEST(BuildScheduleSimpleLoopWithCodeMotion) { |
| 1569 HandleAndZoneScope scope; | 1572 HandleAndZoneScope scope; |
| 1570 Isolate* isolate = scope.main_isolate(); | 1573 Isolate* isolate = scope.main_isolate(); |
| 1571 Graph graph(scope.main_zone()); | 1574 Graph graph(scope.main_zone()); |
| 1572 CommonOperatorBuilder common_builder(scope.main_zone()); | 1575 CommonOperatorBuilder common_builder(scope.main_zone()); |
| 1573 JSOperatorBuilder js_builder(scope.main_zone()); | 1576 JSOperatorBuilder js_builder(scope.main_zone()); |
| 1574 MachineOperatorBuilder machine_builder; | |
| 1575 const Operator* op; | 1577 const Operator* op; |
| 1576 | 1578 |
| 1577 Handle<HeapObject> object = | 1579 Handle<HeapObject> object = |
| 1578 Handle<HeapObject>(isolate->heap()->undefined_value(), isolate); | 1580 Handle<HeapObject>(isolate->heap()->undefined_value(), isolate); |
| 1579 Unique<HeapObject> unique_constant = | 1581 Unique<HeapObject> unique_constant = |
| 1580 Unique<HeapObject>::CreateUninitialized(object); | 1582 Unique<HeapObject>::CreateUninitialized(object); |
| 1581 | 1583 |
| 1582 // Manually transcripted code for: | 1584 // Manually transcripted code for: |
| 1583 // function turbo_fan_test(a, b, c) { | 1585 // function turbo_fan_test(a, b, c) { |
| 1584 // while (a < b) { | 1586 // while (a < b) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1600 Node* n9 = graph.NewNode(op, nil, nil, nil); | 1602 Node* n9 = graph.NewNode(op, nil, nil, nil); |
| 1601 USE(n9); | 1603 USE(n9); |
| 1602 op = common_builder.Parameter(0); | 1604 op = common_builder.Parameter(0); |
| 1603 Node* n2 = graph.NewNode(op, n0); | 1605 Node* n2 = graph.NewNode(op, n0); |
| 1604 USE(n2); | 1606 USE(n2); |
| 1605 n9->ReplaceInput(0, n2); | 1607 n9->ReplaceInput(0, n2); |
| 1606 op = js_builder.Add(); | 1608 op = js_builder.Add(); |
| 1607 Node* n20 = graph.NewNode(op, nil, nil, nil, nil, nil); | 1609 Node* n20 = graph.NewNode(op, nil, nil, nil, nil, nil); |
| 1608 USE(n20); | 1610 USE(n20); |
| 1609 n20->ReplaceInput(0, n9); | 1611 n20->ReplaceInput(0, n9); |
| 1610 op = machine_builder.Int32Add(); | 1612 op = &kIntAdd; |
| 1611 Node* n19 = graph.NewNode(op, nil, nil); | 1613 Node* n19 = graph.NewNode(op, nil, nil); |
| 1612 USE(n19); | 1614 USE(n19); |
| 1613 op = common_builder.Phi(kMachAnyTagged, 2); | 1615 op = common_builder.Phi(kMachAnyTagged, 2); |
| 1614 Node* n10 = graph.NewNode(op, nil, nil, nil); | 1616 Node* n10 = graph.NewNode(op, nil, nil, nil); |
| 1615 USE(n10); | 1617 USE(n10); |
| 1616 op = common_builder.Parameter(0); | 1618 op = common_builder.Parameter(0); |
| 1617 Node* n3 = graph.NewNode(op, n0); | 1619 Node* n3 = graph.NewNode(op, n0); |
| 1618 USE(n3); | 1620 USE(n3); |
| 1619 n10->ReplaceInput(0, n3); | 1621 n10->ReplaceInput(0, n3); |
| 1620 n10->ReplaceInput(1, n10); | 1622 n10->ReplaceInput(1, n10); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 graph.SetEnd(end); | 1726 graph.SetEnd(end); |
| 1725 | 1727 |
| 1726 ComputeAndVerifySchedule(13, &graph); | 1728 ComputeAndVerifySchedule(13, &graph); |
| 1727 } | 1729 } |
| 1728 | 1730 |
| 1729 | 1731 |
| 1730 TEST(FloatingDiamond2) { | 1732 TEST(FloatingDiamond2) { |
| 1731 HandleAndZoneScope scope; | 1733 HandleAndZoneScope scope; |
| 1732 Graph graph(scope.main_zone()); | 1734 Graph graph(scope.main_zone()); |
| 1733 CommonOperatorBuilder common(scope.main_zone()); | 1735 CommonOperatorBuilder common(scope.main_zone()); |
| 1734 MachineOperatorBuilder machine; | |
| 1735 | 1736 |
| 1736 Node* start = graph.NewNode(common.Start(2)); | 1737 Node* start = graph.NewNode(common.Start(2)); |
| 1737 graph.SetStart(start); | 1738 graph.SetStart(start); |
| 1738 | 1739 |
| 1739 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1740 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1740 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1741 Node* p1 = graph.NewNode(common.Parameter(1), start); |
| 1741 Node* d1 = CreateDiamond(&graph, &common, p0); | 1742 Node* d1 = CreateDiamond(&graph, &common, p0); |
| 1742 Node* d2 = CreateDiamond(&graph, &common, p1); | 1743 Node* d2 = CreateDiamond(&graph, &common, p1); |
| 1743 Node* add = graph.NewNode(machine.Int32Add(), d1, d2); | 1744 Node* add = graph.NewNode(&kIntAdd, d1, d2); |
| 1744 Node* ret = graph.NewNode(common.Return(), add, start, start); | 1745 Node* ret = graph.NewNode(common.Return(), add, start, start); |
| 1745 Node* end = graph.NewNode(common.End(), ret, start); | 1746 Node* end = graph.NewNode(common.End(), ret, start); |
| 1746 | 1747 |
| 1747 graph.SetEnd(end); | 1748 graph.SetEnd(end); |
| 1748 | 1749 |
| 1749 ComputeAndVerifySchedule(24, &graph); | 1750 ComputeAndVerifySchedule(24, &graph); |
| 1750 } | 1751 } |
| 1751 | 1752 |
| 1752 | 1753 |
| 1753 TEST(FloatingDiamond3) { | 1754 TEST(FloatingDiamond3) { |
| 1754 HandleAndZoneScope scope; | 1755 HandleAndZoneScope scope; |
| 1755 Graph graph(scope.main_zone()); | 1756 Graph graph(scope.main_zone()); |
| 1756 CommonOperatorBuilder common(scope.main_zone()); | 1757 CommonOperatorBuilder common(scope.main_zone()); |
| 1757 MachineOperatorBuilder machine; | |
| 1758 | 1758 |
| 1759 Node* start = graph.NewNode(common.Start(2)); | 1759 Node* start = graph.NewNode(common.Start(2)); |
| 1760 graph.SetStart(start); | 1760 graph.SetStart(start); |
| 1761 | 1761 |
| 1762 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1762 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1763 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1763 Node* p1 = graph.NewNode(common.Parameter(1), start); |
| 1764 Node* d1 = CreateDiamond(&graph, &common, p0); | 1764 Node* d1 = CreateDiamond(&graph, &common, p0); |
| 1765 Node* d2 = CreateDiamond(&graph, &common, p1); | 1765 Node* d2 = CreateDiamond(&graph, &common, p1); |
| 1766 Node* add = graph.NewNode(machine.Int32Add(), d1, d2); | 1766 Node* add = graph.NewNode(&kIntAdd, d1, d2); |
| 1767 Node* d3 = CreateDiamond(&graph, &common, add); | 1767 Node* d3 = CreateDiamond(&graph, &common, add); |
| 1768 Node* ret = graph.NewNode(common.Return(), d3, start, start); | 1768 Node* ret = graph.NewNode(common.Return(), d3, start, start); |
| 1769 Node* end = graph.NewNode(common.End(), ret, start); | 1769 Node* end = graph.NewNode(common.End(), ret, start); |
| 1770 | 1770 |
| 1771 graph.SetEnd(end); | 1771 graph.SetEnd(end); |
| 1772 | 1772 |
| 1773 ComputeAndVerifySchedule(33, &graph); | 1773 ComputeAndVerifySchedule(33, &graph); |
| 1774 } | 1774 } |
| 1775 | 1775 |
| 1776 | 1776 |
| 1777 TEST(NestedFloatingDiamonds) { | 1777 TEST(NestedFloatingDiamonds) { |
| 1778 HandleAndZoneScope scope; | 1778 HandleAndZoneScope scope; |
| 1779 Graph graph(scope.main_zone()); | 1779 Graph graph(scope.main_zone()); |
| 1780 CommonOperatorBuilder common(scope.main_zone()); | 1780 CommonOperatorBuilder common(scope.main_zone()); |
| 1781 SimplifiedOperatorBuilder simplified(scope.main_zone()); | 1781 SimplifiedOperatorBuilder simplified(scope.main_zone()); |
| 1782 MachineOperatorBuilder machine; | |
| 1783 | 1782 |
| 1784 Node* start = graph.NewNode(common.Start(2)); | 1783 Node* start = graph.NewNode(common.Start(2)); |
| 1785 graph.SetStart(start); | 1784 graph.SetStart(start); |
| 1786 | 1785 |
| 1787 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1786 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1788 | 1787 |
| 1789 Node* fv = graph.NewNode(common.Int32Constant(7)); | 1788 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 1790 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); | 1789 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1791 Node* t = graph.NewNode(common.IfTrue(), br); | 1790 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1792 Node* f = graph.NewNode(common.IfFalse(), br); | 1791 Node* f = graph.NewNode(common.IfFalse(), br); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1814 | 1813 |
| 1815 ComputeAndVerifySchedule(23, &graph); | 1814 ComputeAndVerifySchedule(23, &graph); |
| 1816 } | 1815 } |
| 1817 | 1816 |
| 1818 | 1817 |
| 1819 TEST(NestedFloatingDiamondWithLoop) { | 1818 TEST(NestedFloatingDiamondWithLoop) { |
| 1820 HandleAndZoneScope scope; | 1819 HandleAndZoneScope scope; |
| 1821 Graph graph(scope.main_zone()); | 1820 Graph graph(scope.main_zone()); |
| 1822 CommonOperatorBuilder common(scope.main_zone()); | 1821 CommonOperatorBuilder common(scope.main_zone()); |
| 1823 SimplifiedOperatorBuilder simplified(scope.main_zone()); | 1822 SimplifiedOperatorBuilder simplified(scope.main_zone()); |
| 1824 MachineOperatorBuilder machine; | |
| 1825 | 1823 |
| 1826 Node* start = graph.NewNode(common.Start(2)); | 1824 Node* start = graph.NewNode(common.Start(2)); |
| 1827 graph.SetStart(start); | 1825 graph.SetStart(start); |
| 1828 | 1826 |
| 1829 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1827 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1830 | 1828 |
| 1831 Node* fv = graph.NewNode(common.Int32Constant(7)); | 1829 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 1832 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); | 1830 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1833 Node* t = graph.NewNode(common.IfTrue(), br); | 1831 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1834 Node* f = graph.NewNode(common.IfFalse(), br); | 1832 Node* f = graph.NewNode(common.IfFalse(), br); |
| 1835 | 1833 |
| 1836 Node* loop = graph.NewNode(common.Loop(2), f, start); | 1834 Node* loop = graph.NewNode(common.Loop(2), f, start); |
| 1837 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1835 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1838 | 1836 |
| 1839 // TODO(mstarzinger): Make scheduler deal with non-empty loops here. | 1837 // TODO(mstarzinger): Make scheduler deal with non-empty loops here. |
| 1840 // Node* add = graph.NewNode(machine.IntAdd(), ind, fv); | 1838 // Node* add = graph.NewNode(&kIntAdd, ind, fv); |
| 1841 | 1839 |
| 1842 Node* br1 = graph.NewNode(common.Branch(), ind, loop); | 1840 Node* br1 = graph.NewNode(common.Branch(), ind, loop); |
| 1843 Node* t1 = graph.NewNode(common.IfTrue(), br1); | 1841 Node* t1 = graph.NewNode(common.IfTrue(), br1); |
| 1844 Node* f1 = graph.NewNode(common.IfFalse(), br1); | 1842 Node* f1 = graph.NewNode(common.IfFalse(), br1); |
| 1845 | 1843 |
| 1846 loop->ReplaceInput(1, t1); // close loop. | 1844 loop->ReplaceInput(1, t1); // close loop. |
| 1847 ind->ReplaceInput(1, ind); // close induction variable. | 1845 ind->ReplaceInput(1, ind); // close induction variable. |
| 1848 | 1846 |
| 1849 Node* m = graph.NewNode(common.Merge(2), t, f1); | 1847 Node* m = graph.NewNode(common.Merge(2), t, f1); |
| 1850 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), fv, ind, m); | 1848 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), fv, ind, m); |
| 1851 | 1849 |
| 1852 Node* ret = graph.NewNode(common.Return(), phi, start, start); | 1850 Node* ret = graph.NewNode(common.Return(), phi, start, start); |
| 1853 Node* end = graph.NewNode(common.End(), ret, start); | 1851 Node* end = graph.NewNode(common.End(), ret, start); |
| 1854 | 1852 |
| 1855 graph.SetEnd(end); | 1853 graph.SetEnd(end); |
| 1856 | 1854 |
| 1857 ComputeAndVerifySchedule(19, &graph); | 1855 ComputeAndVerifySchedule(19, &graph); |
| 1858 } | 1856 } |
| 1859 | 1857 |
| 1860 | 1858 |
| 1861 TEST(LoopedFloatingDiamond1) { | 1859 TEST(LoopedFloatingDiamond1) { |
| 1862 HandleAndZoneScope scope; | 1860 HandleAndZoneScope scope; |
| 1863 Graph graph(scope.main_zone()); | 1861 Graph graph(scope.main_zone()); |
| 1864 CommonOperatorBuilder common(scope.main_zone()); | 1862 CommonOperatorBuilder common(scope.main_zone()); |
| 1865 SimplifiedOperatorBuilder simplified(scope.main_zone()); | 1863 SimplifiedOperatorBuilder simplified(scope.main_zone()); |
| 1866 MachineOperatorBuilder machine; | |
| 1867 | 1864 |
| 1868 Node* start = graph.NewNode(common.Start(2)); | 1865 Node* start = graph.NewNode(common.Start(2)); |
| 1869 graph.SetStart(start); | 1866 graph.SetStart(start); |
| 1870 | 1867 |
| 1871 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1868 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1872 | 1869 |
| 1873 Node* c = graph.NewNode(common.Int32Constant(7)); | 1870 Node* c = graph.NewNode(common.Int32Constant(7)); |
| 1874 Node* loop = graph.NewNode(common.Loop(2), start, start); | 1871 Node* loop = graph.NewNode(common.Loop(2), start, start); |
| 1875 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1872 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1876 Node* add = graph.NewNode(machine.IntAdd(), ind, c); | 1873 Node* add = graph.NewNode(&kIntAdd, ind, c); |
| 1877 | 1874 |
| 1878 Node* br = graph.NewNode(common.Branch(), add, loop); | 1875 Node* br = graph.NewNode(common.Branch(), add, loop); |
| 1879 Node* t = graph.NewNode(common.IfTrue(), br); | 1876 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1880 Node* f = graph.NewNode(common.IfFalse(), br); | 1877 Node* f = graph.NewNode(common.IfFalse(), br); |
| 1881 | 1878 |
| 1882 Node* br1 = graph.NewNode(common.Branch(), p0, graph.start()); | 1879 Node* br1 = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1883 Node* t1 = graph.NewNode(common.IfTrue(), br1); | 1880 Node* t1 = graph.NewNode(common.IfTrue(), br1); |
| 1884 Node* f1 = graph.NewNode(common.IfFalse(), br1); | 1881 Node* f1 = graph.NewNode(common.IfFalse(), br1); |
| 1885 Node* m1 = graph.NewNode(common.Merge(2), t1, f1); | 1882 Node* m1 = graph.NewNode(common.Merge(2), t1, f1); |
| 1886 Node* phi1 = graph.NewNode(common.Phi(kMachAnyTagged, 2), add, p0, m1); | 1883 Node* phi1 = graph.NewNode(common.Phi(kMachAnyTagged, 2), add, p0, m1); |
| 1887 | 1884 |
| 1888 loop->ReplaceInput(1, t); // close loop. | 1885 loop->ReplaceInput(1, t); // close loop. |
| 1889 ind->ReplaceInput(1, phi1); // close induction variable. | 1886 ind->ReplaceInput(1, phi1); // close induction variable. |
| 1890 | 1887 |
| 1891 Node* ret = graph.NewNode(common.Return(), ind, start, f); | 1888 Node* ret = graph.NewNode(common.Return(), ind, start, f); |
| 1892 Node* end = graph.NewNode(common.End(), ret, f); | 1889 Node* end = graph.NewNode(common.End(), ret, f); |
| 1893 | 1890 |
| 1894 graph.SetEnd(end); | 1891 graph.SetEnd(end); |
| 1895 | 1892 |
| 1896 ComputeAndVerifySchedule(20, &graph); | 1893 ComputeAndVerifySchedule(20, &graph); |
| 1897 } | 1894 } |
| 1898 | 1895 |
| 1899 | 1896 |
| 1900 TEST(LoopedFloatingDiamond2) { | 1897 TEST(LoopedFloatingDiamond2) { |
| 1901 HandleAndZoneScope scope; | 1898 HandleAndZoneScope scope; |
| 1902 Graph graph(scope.main_zone()); | 1899 Graph graph(scope.main_zone()); |
| 1903 CommonOperatorBuilder common(scope.main_zone()); | 1900 CommonOperatorBuilder common(scope.main_zone()); |
| 1904 SimplifiedOperatorBuilder simplified(scope.main_zone()); | 1901 SimplifiedOperatorBuilder simplified(scope.main_zone()); |
| 1905 MachineOperatorBuilder machine; | |
| 1906 | 1902 |
| 1907 Node* start = graph.NewNode(common.Start(2)); | 1903 Node* start = graph.NewNode(common.Start(2)); |
| 1908 graph.SetStart(start); | 1904 graph.SetStart(start); |
| 1909 | 1905 |
| 1910 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1906 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1911 | 1907 |
| 1912 Node* c = graph.NewNode(common.Int32Constant(7)); | 1908 Node* c = graph.NewNode(common.Int32Constant(7)); |
| 1913 Node* loop = graph.NewNode(common.Loop(2), start, start); | 1909 Node* loop = graph.NewNode(common.Loop(2), start, start); |
| 1914 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1910 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1915 | 1911 |
| 1916 Node* br1 = graph.NewNode(common.Branch(), p0, graph.start()); | 1912 Node* br1 = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1917 Node* t1 = graph.NewNode(common.IfTrue(), br1); | 1913 Node* t1 = graph.NewNode(common.IfTrue(), br1); |
| 1918 Node* f1 = graph.NewNode(common.IfFalse(), br1); | 1914 Node* f1 = graph.NewNode(common.IfFalse(), br1); |
| 1919 Node* m1 = graph.NewNode(common.Merge(2), t1, f1); | 1915 Node* m1 = graph.NewNode(common.Merge(2), t1, f1); |
| 1920 Node* phi1 = graph.NewNode(common.Phi(kMachAnyTagged, 2), c, ind, m1); | 1916 Node* phi1 = graph.NewNode(common.Phi(kMachAnyTagged, 2), c, ind, m1); |
| 1921 | 1917 |
| 1922 Node* add = graph.NewNode(machine.IntAdd(), ind, phi1); | 1918 Node* add = graph.NewNode(&kIntAdd, ind, phi1); |
| 1923 | 1919 |
| 1924 Node* br = graph.NewNode(common.Branch(), add, loop); | 1920 Node* br = graph.NewNode(common.Branch(), add, loop); |
| 1925 Node* t = graph.NewNode(common.IfTrue(), br); | 1921 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1926 Node* f = graph.NewNode(common.IfFalse(), br); | 1922 Node* f = graph.NewNode(common.IfFalse(), br); |
| 1927 | 1923 |
| 1928 loop->ReplaceInput(1, t); // close loop. | 1924 loop->ReplaceInput(1, t); // close loop. |
| 1929 ind->ReplaceInput(1, add); // close induction variable. | 1925 ind->ReplaceInput(1, add); // close induction variable. |
| 1930 | 1926 |
| 1931 Node* ret = graph.NewNode(common.Return(), ind, start, f); | 1927 Node* ret = graph.NewNode(common.Return(), ind, start, f); |
| 1932 Node* end = graph.NewNode(common.End(), ret, f); | 1928 Node* end = graph.NewNode(common.End(), ret, f); |
| 1933 | 1929 |
| 1934 graph.SetEnd(end); | 1930 graph.SetEnd(end); |
| 1935 | 1931 |
| 1936 ComputeAndVerifySchedule(20, &graph); | 1932 ComputeAndVerifySchedule(20, &graph); |
| 1937 } | 1933 } |
| 1938 | 1934 |
| 1939 | 1935 |
| 1940 TEST(PhisPushedDownToDifferentBranches) { | 1936 TEST(PhisPushedDownToDifferentBranches) { |
| 1941 HandleAndZoneScope scope; | 1937 HandleAndZoneScope scope; |
| 1942 Graph graph(scope.main_zone()); | 1938 Graph graph(scope.main_zone()); |
| 1943 CommonOperatorBuilder common(scope.main_zone()); | 1939 CommonOperatorBuilder common(scope.main_zone()); |
| 1944 SimplifiedOperatorBuilder simplified(scope.main_zone()); | 1940 SimplifiedOperatorBuilder simplified(scope.main_zone()); |
| 1945 MachineOperatorBuilder machine; | |
| 1946 | 1941 |
| 1947 Node* start = graph.NewNode(common.Start(2)); | 1942 Node* start = graph.NewNode(common.Start(2)); |
| 1948 graph.SetStart(start); | 1943 graph.SetStart(start); |
| 1949 | 1944 |
| 1950 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1945 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1951 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1946 Node* p1 = graph.NewNode(common.Parameter(1), start); |
| 1952 | 1947 |
| 1953 Node* v1 = graph.NewNode(common.Int32Constant(1)); | 1948 Node* v1 = graph.NewNode(common.Int32Constant(1)); |
| 1954 Node* v2 = graph.NewNode(common.Int32Constant(2)); | 1949 Node* v2 = graph.NewNode(common.Int32Constant(2)); |
| 1955 Node* v3 = graph.NewNode(common.Int32Constant(3)); | 1950 Node* v3 = graph.NewNode(common.Int32Constant(3)); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2052 graph.SetEnd(end); | 2047 graph.SetEnd(end); |
| 2053 | 2048 |
| 2054 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); | 2049 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); |
| 2055 BasicBlock* block = schedule->block(loop); | 2050 BasicBlock* block = schedule->block(loop); |
| 2056 CHECK_NE(NULL, loop); | 2051 CHECK_NE(NULL, loop); |
| 2057 CHECK_EQ(block, schedule->block(effect)); | 2052 CHECK_EQ(block, schedule->block(effect)); |
| 2058 CHECK_GE(block->rpo_number(), 0); | 2053 CHECK_GE(block->rpo_number(), 0); |
| 2059 } | 2054 } |
| 2060 | 2055 |
| 2061 #endif | 2056 #endif |
| OLD | NEW |