Ignore:
Timestamp:
Oct 22, 2011, 6:46:08 PM (8 years ago)
Author:
cameron
Message:

FW=1 operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/idisa_cpp/idisa_sse2.cpp

    r1570 r1573  
    191191template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<64>::popcount(bitblock128_t arg1);
    192192template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<128>::popcount(bitblock128_t arg1);
    193 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::neg(bitblock128_t arg1);
    194193template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1);
    195194template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<4>::neg(bitblock128_t arg1);
     
    300299template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<64>::add(bitblock128_t arg1, bitblock128_t arg2);
    301300template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<128>::add(bitblock128_t arg1, bitblock128_t arg2);
    302 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::abs(bitblock128_t arg1);
    303301template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::abs(bitblock128_t arg1);
    304302template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<4>::abs(bitblock128_t arg1);
     
    528526}
    529527
    530 //The total number of operations is 39
     528//The total number of operations is 1
    531529template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::max(bitblock128_t arg1, bitblock128_t arg2)
    532530{
    533         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    534         return simd_xor(simd128<1>::umax(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
    535 }
    536 
    537 //The total number of operations is 19
     531        return simd_and(arg1, arg2);
     532}
     533
     534//The total number of operations is 18
    538535template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::max(bitblock128_t arg1, bitblock128_t arg2)
    539536{
    540         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)))));
     537        return simd128<1>::ifh(simd128<2>::lt(arg1, arg2), arg2, arg1);
    541538}
    542539
     
    582579}
    583580
    584 //The total number of operations is 57
     581//The total number of operations is 1
    585582template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::mult(bitblock128_t arg1, bitblock128_t arg2)
    586583{
    587         bitblock128_t loMask = simd128<(2)>::lomask();
    588         bitblock128_t tmpAns1 = simd128<(2)>::mult(simd_and(loMask, arg1), simd_and(loMask, arg2));
    589         bitblock128_t tmpAns2 = simd128<(2)>::mult(simd128<(2)>::srli<1>(arg1), simd128<(2)>::srli<1>(arg2));
    590         return simd128<1>::ifh(loMask, tmpAns1, simd128<(2)>::slli<1>(tmpAns2));
     584        return simd_and(arg1, arg2);
    591585}
    592586
     
    660654}
    661655
    662 //The total number of operations is 42
     656//The total number of operations is 1
    663657template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::gt(bitblock128_t arg1, bitblock128_t arg2)
    664658{
    665         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    666         return simd128<1>::ugt(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    667 }
    668 
    669 //The total number of operations is 18
     659        return simd_andc(arg2, arg1);
     660}
     661
     662//The total number of operations is 15
    670663template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::gt(bitblock128_t arg1, bitblock128_t arg2)
    671664{
    672         bitblock128_t tmp = simd_not(arg1);
    673         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)));
    674         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     665        bitblock128_t hiAns = simd128<(1)>::gt(arg1, arg2);
     666        bitblock128_t loAns = simd128<(1)>::ugt(arg1, arg2);
     667        bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     668        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     669        return simd_or(simd128<2>::srai<(1)>(hiAns), mask);
    675670}
    676671
     
    788783}
    789784
    790 //The total number of operations is 40
     785//The total number of operations is 1
    791786template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ult(bitblock128_t arg1, bitblock128_t arg2)
    792787{
    793         return simd128<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())));
    794 }
    795 
    796 //The total number of operations is 17
     788        return simd_andc(arg2, arg1);
     789}
     790
     791//The total number of operations is 14
    797792template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ult(bitblock128_t arg1, bitblock128_t arg2)
    798793{
    799         bitblock128_t tmp = simd_not(arg1);
    800         bitblock128_t tmpAns = simd_or(simd_and(tmp, arg2), simd_and(simd128<128>::slli<1>(simd_and(tmp, arg2)), simd_or(tmp, arg2)));
    801         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     794        bitblock128_t tmpAns = simd128<(1)>::ult(arg1, arg2);
     795        bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     796        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     797        return simd_or(simd128<2>::srai<(1)>(tmpAns), mask);
    802798}
    803799
     
    844840}
    845841
    846 //The total number of operations is 42
     842//The total number of operations is 1
    847843template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::lt(bitblock128_t arg1, bitblock128_t arg2)
    848844{
    849         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    850         return simd128<1>::ult(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    851 }
    852 
    853 //The total number of operations is 18
     845        return simd_andc(arg1, arg2);
     846}
     847
     848//The total number of operations is 15
    854849template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::lt(bitblock128_t arg1, bitblock128_t arg2)
    855850{
    856         bitblock128_t tmp = simd_not(arg2);
    857         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)));
    858         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     851        bitblock128_t hiAns = simd128<(1)>::lt(arg1, arg2);
     852        bitblock128_t loAns = simd128<(1)>::ult(arg1, arg2);
     853        bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     854        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     855        return simd_or(simd128<2>::srai<(1)>(hiAns), mask);
    859856}
    860857
     
    10031000}
    10041001
    1005 //The total number of operations is 40
     1002//The total number of operations is 1
    10061003template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10071004{
    1008         return simd128<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())));
    1009 }
    1010 
    1011 //The total number of operations is 17
     1005        return simd_andc(arg1, arg2);
     1006}
     1007
     1008//The total number of operations is 14
    10121009template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10131010{
    1014         bitblock128_t tmp = simd_not(arg2);
    1015         bitblock128_t tmpAns = simd_or(simd_and(arg1, tmp), simd_and(simd128<128>::slli<1>(simd_and(arg1, tmp)), simd_or(arg1, tmp)));
    1016         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     1011        bitblock128_t tmpAns = simd128<(1)>::ugt(arg1, arg2);
     1012        bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     1013        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     1014        return simd_or(simd128<2>::srai<(1)>(tmpAns), mask);
    10171015}
    10181016
     
    11531151}
    11541152
    1155 //The total number of operations is 1
    1156 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::neg(bitblock128_t arg1)
    1157 {
    1158         return simd128<1>::sub(simd128<1>::constant<0>(), arg1);
    1159 }
    1160 
    11611153//The total number of operations is 8
    11621154template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1)
     
    14871479}
    14881480
    1489 //The total number of operations is 39
     1481//The total number of operations is 1
    14901482template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::min(bitblock128_t arg1, bitblock128_t arg2)
    14911483{
    1492         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    1493         return simd_xor(simd128<1>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
    1494 }
    1495 
    1496 //The total number of operations is 19
     1484        return simd_or(arg1, arg2);
     1485}
     1486
     1487//The total number of operations is 18
    14971488template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::min(bitblock128_t arg1, bitblock128_t arg2)
    14981489{
    1499         bitblock128_t high_bit = simd128<2>::constant<(2)>();
    1500         return simd_xor(simd128<2>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
     1490        return simd128<1>::ifh(simd128<2>::lt(arg1, arg2), arg1, arg2);
    15011491}
    15021492
     
    15421532}
    15431533
    1544 //The total number of operations is 36
     1534//The total number of operations is 1
    15451535template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umin(bitblock128_t arg1, bitblock128_t arg2)
    15461536{
    1547         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)));
     1537        return simd_and(arg1, arg2);
    15481538}
    15491539
     
    15981588}
    15991589
    1600 //The total number of operations is 36
     1590//The total number of operations is 1
    16011591template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umax(bitblock128_t arg1, bitblock128_t arg2)
    16021592{
    1603         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)));
     1593        return simd_or(arg1, arg2);
    16041594}
    16051595
     
    16541644}
    16551645
    1656 //The total number of operations is 37
     1646//The total number of operations is 2
    16571647template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16581648{
    1659         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))));
    1660 }
    1661 
    1662 //The total number of operations is 15
     1649        return simd_not(simd_xor(arg1, arg2));
     1650}
     1651
     1652//The total number of operations is 8
    16631653template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16641654{
    1665         bitblock128_t tmp = simd_xor(arg1, arg2);
    1666         bitblock128_t tmpAns = simd_and(simd_not(simd128<128>::slli<1>(tmp)), simd_not(tmp));
    1667         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     1655        bitblock128_t tmpAns = simd128<(1)>::eq(arg1, arg2);
     1656        bitblock128_t loMask = simd_and(tmpAns, simd128<2>::srli<(1)>(tmpAns));
     1657        bitblock128_t hiMask = simd128<2>::slli<(1)>(loMask);
     1658        return simd_or(loMask, hiMask);
    16681659}
    16691660
     
    18501841}
    18511842
    1852 //The total number of operations is 46
    1853 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::abs(bitblock128_t arg1)
    1854 {
    1855         bitblock128_t gtMask = simd128<1>::gt(arg1, simd128<1>::constant<0>());
    1856         return simd128<1>::ifh(gtMask, arg1, simd128<1>::sub(gtMask, arg1));
    1857 }
    1858 
    18591843//The total number of operations is 9
    18601844template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::abs(bitblock128_t arg1)
     
    19051889}
    19061890
    1907 //The total number of operations is 128
     1891//The total number of operations is 93
    19081892template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::umin_hl(bitblock128_t arg1, bitblock128_t arg2)
    19091893{
     
    19891973}
    19901974
    1991 //The total number of operations is 132
     1975//The total number of operations is 120
    19921976template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packss(bitblock128_t arg1, bitblock128_t arg2)
    19931977{
     
    21632147}
    21642148
    2165 //The total number of operations is 131
     2149//The total number of operations is 93
    21662150template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::min_hl(bitblock128_t arg1, bitblock128_t arg2)
    21672151{
     
    21692153}
    21702154
    2171 //The total number of operations is 83
     2155//The total number of operations is 82
    21722156template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<4>::min_hl(bitblock128_t arg1, bitblock128_t arg2)
    21732157{
     
    22052189}
    22062190
    2207 //The total number of operations is 99
     2191//The total number of operations is 85
    22082192template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packus(bitblock128_t arg1, bitblock128_t arg2)
    22092193{
Note: See TracChangeset for help on using the changeset viewer.