Changeset 1573 for trunk/lib/idisa_cpp/idisa_ssse3.cpp
 Timestamp:
 Oct 22, 2011, 6:46:08 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/lib/idisa_cpp/idisa_ssse3.cpp
r1570 r1573 192 192 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<64>::popcount(bitblock128_t arg1); 193 193 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<128>::popcount(bitblock128_t arg1); 194 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::neg(bitblock128_t arg1);195 194 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1); 196 195 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<4>::neg(bitblock128_t arg1); … … 301 300 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<64>::add(bitblock128_t arg1, bitblock128_t arg2); 302 301 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<128>::add(bitblock128_t arg1, bitblock128_t arg2); 303 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::abs(bitblock128_t arg1);304 302 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::abs(bitblock128_t arg1); 305 303 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<4>::abs(bitblock128_t arg1); … … 533 531 } 534 532 535 //The total number of operations is 39533 //The total number of operations is 1 536 534 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::max(bitblock128_t arg1, bitblock128_t arg2) 537 535 { 538 bitblock128_t high_bit = simd128<1>::constant<(1)>(); 539 return simd_xor(simd128<1>::umax(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit); 540 } 541 542 //The total number of operations is 19 536 return simd_and(arg1, arg2); 537 } 538 539 //The total number of operations is 18 543 540 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::max(bitblock128_t arg1, bitblock128_t arg2) 544 541 { 545 return simd128<1>::ifh(simd128<2>:: himask(), simd_and(arg1, arg2), simd_or(simd_and(arg2, simd128<128>::srli<1>(simd_or(arg1, simd_not(arg2)))), simd_and(arg1, simd128<128>::srli<1>(simd_or(simd_not(arg1), arg2)))));542 return simd128<1>::ifh(simd128<2>::lt(arg1, arg2), arg2, arg1); 546 543 } 547 544 … … 587 584 } 588 585 589 //The total number of operations is 57586 //The total number of operations is 1 590 587 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::mult(bitblock128_t arg1, bitblock128_t arg2) 591 588 { 592 bitblock128_t loMask = simd128<(2)>::lomask(); 593 bitblock128_t tmpAns1 = simd128<(2)>::mult(simd_and(loMask, arg1), simd_and(loMask, arg2)); 594 bitblock128_t tmpAns2 = simd128<(2)>::mult(simd128<(2)>::srli<1>(arg1), simd128<(2)>::srli<1>(arg2)); 595 return simd128<1>::ifh(loMask, tmpAns1, simd128<(2)>::slli<1>(tmpAns2)); 589 return simd_and(arg1, arg2); 596 590 } 597 591 … … 665 659 } 666 660 667 //The total number of operations is 42661 //The total number of operations is 1 668 662 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::gt(bitblock128_t arg1, bitblock128_t arg2) 669 663 { 670 bitblock128_t high_bit = simd128<1>::constant<(1)>(); 671 return simd128<1>::ugt(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)); 672 } 673 674 //The total number of operations is 18 664 return simd_andc(arg2, arg1); 665 } 666 667 //The total number of operations is 15 675 668 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::gt(bitblock128_t arg1, bitblock128_t arg2) 676 669 { 677 bitblock128_t tmp = simd_not(arg1); 678 bitblock128_t tmpAns = simd_or(simd_and(tmp, arg2), simd_and(simd128<128>::slli<1>(simd_and(arg1, simd_not(arg2))), simd_or(tmp, arg2))); 679 return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns)); 670 bitblock128_t hiAns = simd128<(1)>::gt(arg1, arg2); 671 bitblock128_t loAns = simd128<(1)>::ugt(arg1, arg2); 672 bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2))); 673 mask = simd_or(mask, simd128<2>::slli<(1)>(mask)); 674 return simd_or(simd128<2>::srai<(1)>(hiAns), mask); 680 675 } 681 676 … … 793 788 } 794 789 795 //The total number of operations is 40790 //The total number of operations is 1 796 791 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ult(bitblock128_t arg1, bitblock128_t arg2) 797 792 { 798 return simd 128<1>::ifh(simd128<(2)>::himask(), simd128<(2)>::ult(arg1, simd_and(simd128<(2)>::himask(), arg2)), simd128<(2)>::ult(simd_andc(arg1, simd128<(2)>::himask()), simd_andc(arg2, simd128<(2)>::himask())));799 } 800 801 //The total number of operations is 1 7793 return simd_andc(arg2, arg1); 794 } 795 796 //The total number of operations is 14 802 797 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ult(bitblock128_t arg1, bitblock128_t arg2) 803 798 { 804 bitblock128_t tmp = simd_not(arg1); 805 bitblock128_t tmpAns = simd_or(simd_and(tmp, arg2), simd_and(simd128<128>::slli<1>(simd_and(tmp, arg2)), simd_or(tmp, arg2))); 806 return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns)); 799 bitblock128_t tmpAns = simd128<(1)>::ult(arg1, arg2); 800 bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2))); 801 mask = simd_or(mask, simd128<2>::slli<(1)>(mask)); 802 return simd_or(simd128<2>::srai<(1)>(tmpAns), mask); 807 803 } 808 804 … … 849 845 } 850 846 851 //The total number of operations is 42847 //The total number of operations is 1 852 848 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::lt(bitblock128_t arg1, bitblock128_t arg2) 853 849 { 854 bitblock128_t high_bit = simd128<1>::constant<(1)>(); 855 return simd128<1>::ult(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)); 856 } 857 858 //The total number of operations is 18 850 return simd_andc(arg1, arg2); 851 } 852 853 //The total number of operations is 15 859 854 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::lt(bitblock128_t arg1, bitblock128_t arg2) 860 855 { 861 bitblock128_t tmp = simd_not(arg2); 862 bitblock128_t tmpAns = simd_or(simd_and(arg1, tmp), simd_and(simd128<128>::slli<1>(simd_and(simd_not(arg1), arg2)), simd_or(arg1, tmp))); 863 return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns)); 856 bitblock128_t hiAns = simd128<(1)>::lt(arg1, arg2); 857 bitblock128_t loAns = simd128<(1)>::ult(arg1, arg2); 858 bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2))); 859 mask = simd_or(mask, simd128<2>::slli<(1)>(mask)); 860 return simd_or(simd128<2>::srai<(1)>(hiAns), mask); 864 861 } 865 862 … … 1008 1005 } 1009 1006 1010 //The total number of operations is 401007 //The total number of operations is 1 1011 1008 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ugt(bitblock128_t arg1, bitblock128_t arg2) 1012 1009 { 1013 return simd 128<1>::ifh(simd128<(2)>::himask(), simd128<(2)>::ugt(simd_and(simd128<(2)>::himask(), arg1), arg2), simd128<(2)>::ugt(simd_andc(arg1, simd128<(2)>::himask()), simd_andc(arg2, simd128<(2)>::himask())));1014 } 1015 1016 //The total number of operations is 1 71010 return simd_andc(arg1, arg2); 1011 } 1012 1013 //The total number of operations is 14 1017 1014 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ugt(bitblock128_t arg1, bitblock128_t arg2) 1018 1015 { 1019 bitblock128_t tmp = simd_not(arg2); 1020 bitblock128_t tmpAns = simd_or(simd_and(arg1, tmp), simd_and(simd128<128>::slli<1>(simd_and(arg1, tmp)), simd_or(arg1, tmp))); 1021 return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns)); 1016 bitblock128_t tmpAns = simd128<(1)>::ugt(arg1, arg2); 1017 bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2))); 1018 mask = simd_or(mask, simd128<2>::slli<(1)>(mask)); 1019 return simd_or(simd128<2>::srai<(1)>(tmpAns), mask); 1022 1020 } 1023 1021 … … 1158 1156 } 1159 1157 1160 //The total number of operations is 11161 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::neg(bitblock128_t arg1)1162 {1163 return simd128<1>::sub(simd128<1>::constant<0>(), arg1);1164 }1165 1166 1158 //The total number of operations is 8 1167 1159 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1) … … 1492 1484 } 1493 1485 1494 //The total number of operations is 391486 //The total number of operations is 1 1495 1487 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::min(bitblock128_t arg1, bitblock128_t arg2) 1496 1488 { 1497 bitblock128_t high_bit = simd128<1>::constant<(1)>(); 1498 return simd_xor(simd128<1>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit); 1499 } 1500 1501 //The total number of operations is 19 1489 return simd_or(arg1, arg2); 1490 } 1491 1492 //The total number of operations is 18 1502 1493 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::min(bitblock128_t arg1, bitblock128_t arg2) 1503 1494 { 1504 bitblock128_t high_bit = simd128<2>::constant<(2)>(); 1505 return simd_xor(simd128<2>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit); 1495 return simd128<1>::ifh(simd128<2>::lt(arg1, arg2), arg1, arg2); 1506 1496 } 1507 1497 … … 1547 1537 } 1548 1538 1549 //The total number of operations is 361539 //The total number of operations is 1 1550 1540 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umin(bitblock128_t arg1, bitblock128_t arg2) 1551 1541 { 1552 return simd_ or(simd_and(simd128<(2)>::himask(), simd128<(2)>::umin(arg1, arg2)), simd128<(2)>::umin(simd_and(simd128<(2)>::lomask(), arg1), simd_and(simd128<(2)>::lomask(), arg2)));1542 return simd_and(arg1, arg2); 1553 1543 } 1554 1544 … … 1603 1593 } 1604 1594 1605 //The total number of operations is 361595 //The total number of operations is 1 1606 1596 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umax(bitblock128_t arg1, bitblock128_t arg2) 1607 1597 { 1608 return simd_or( simd_and(simd128<(2)>::himask(), simd128<(2)>::umax(arg1, arg2)), simd128<(2)>::umax(simd_and(simd128<(2)>::lomask(), arg1), simd_and(simd128<(2)>::lomask(), arg2)));1598 return simd_or(arg1, arg2); 1609 1599 } 1610 1600 … … 1659 1649 } 1660 1650 1661 //The total number of operations is 371651 //The total number of operations is 2 1662 1652 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::eq(bitblock128_t arg1, bitblock128_t arg2) 1663 1653 { 1664 return simd_ or(simd_and(simd128<(2)>::himask(), simd128<(2)>::eq(simd_and(simd128<(2)>::himask(), arg1), simd_and(simd128<(2)>::himask(), arg2))), simd_and(simd128<(2)>::lomask(), simd128<(2)>::eq(simd_and(simd128<(2)>::lomask(), arg1), simd_and(simd128<(2)>::lomask(), arg2))));1665 } 1666 1667 //The total number of operations is 151654 return simd_not(simd_xor(arg1, arg2)); 1655 } 1656 1657 //The total number of operations is 8 1668 1658 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::eq(bitblock128_t arg1, bitblock128_t arg2) 1669 1659 { 1670 bitblock128_t tmp = simd_xor(arg1, arg2); 1671 bitblock128_t tmpAns = simd_and(simd_not(simd128<128>::slli<1>(tmp)), simd_not(tmp)); 1672 return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns)); 1660 bitblock128_t tmpAns = simd128<(1)>::eq(arg1, arg2); 1661 bitblock128_t loMask = simd_and(tmpAns, simd128<2>::srli<(1)>(tmpAns)); 1662 bitblock128_t hiMask = simd128<2>::slli<(1)>(loMask); 1663 return simd_or(loMask, hiMask); 1673 1664 } 1674 1665 … … 1855 1846 } 1856 1847 1857 //The total number of operations is 461858 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::abs(bitblock128_t arg1)1859 {1860 bitblock128_t gtMask = simd128<1>::gt(arg1, simd128<1>::constant<0>());1861 return simd128<1>::ifh(gtMask, arg1, simd128<1>::sub(gtMask, arg1));1862 }1863 1864 1848 //The total number of operations is 9 1865 1849 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::abs(bitblock128_t arg1) … … 1907 1891 } 1908 1892 1909 //The total number of operations is 1281893 //The total number of operations is 93 1910 1894 template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::umin_hl(bitblock128_t arg1, bitblock128_t arg2) 1911 1895 { … … 1991 1975 } 1992 1976 1993 //The total number of operations is 1 321977 //The total number of operations is 120 1994 1978 template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packss(bitblock128_t arg1, bitblock128_t arg2) 1995 1979 { … … 2165 2149 } 2166 2150 2167 //The total number of operations is 1312151 //The total number of operations is 93 2168 2152 template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::min_hl(bitblock128_t arg1, bitblock128_t arg2) 2169 2153 { … … 2171 2155 } 2172 2156 2173 //The total number of operations is 8 32157 //The total number of operations is 82 2174 2158 template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<4>::min_hl(bitblock128_t arg1, bitblock128_t arg2) 2175 2159 { … … 2207 2191 } 2208 2192 2209 //The total number of operations is 992193 //The total number of operations is 85 2210 2194 template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packus(bitblock128_t arg1, bitblock128_t arg2) 2211 2195 {
Note: See TracChangeset
for help on using the changeset viewer.