Changeset 1525


Ignore:
Timestamp:
Oct 11, 2011, 3:51:55 PM (8 years ago)
Author:
huah
Message:

regenrated the library based on the new strategies

Location:
trunk/libgen/idisa_lib/cpp
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libgen/idisa_lib/cpp/idisa_sse2.cpp

    r1521 r1525  
    562562}
    563563
    564 //The total number of operations is 87
     564//The total number of operations is 84
    565565template <> inline bitblock128_t simd<128>::max(bitblock128_t arg1, bitblock128_t arg2)
    566566{
     
    632632}
    633633
    634 //The total number of operations is 249
     634//The total number of operations is 205
    635635template <> inline bitblock128_t simd<128>::mult(bitblock128_t arg1, bitblock128_t arg2)
    636636{
     
    694694}
    695695
    696 //The total number of operations is 84
     696//The total number of operations is 81
    697697template <> inline bitblock128_t simd<128>::gt(bitblock128_t arg1, bitblock128_t arg2)
    698698{
     
    755755}
    756756
    757 //The total number of operations is 67
     757//The total number of operations is 55
    758758template <> inline bitblock128_t simd<64>::umult(bitblock128_t arg1, bitblock128_t arg2)
    759759{
     
    817817}
    818818
    819 //The total number of operations is 59
     819//The total number of operations is 55
    820820template <> inline bitblock128_t simd<128>::ult(bitblock128_t arg1, bitblock128_t arg2)
    821821{
    822         bitblock128_t tmpAns = simd<(64)>::ult(arg1, arg2);
    823         bitblock128_t mask = simd_and(tmpAns, simd<128>::srli<(64)>(simd<(64)>::eq(arg1, arg2)));
    824         mask = simd_or(mask, simd<128>::slli<(64)>(mask));
    825         return simd_or(simd<128>::srai<(64)>(tmpAns), mask);
     822        return simd_and(simd<128>::srai<(127)>(simd_or(simd_and(simd_not(arg1), arg2), simd_and(simd_not(simd_xor(arg1, arg2)), simd<128>::sub(arg1, arg2)))), simd_not(simd<128>::eq(arg1, arg2)));
    826823}
    827824
     
    874871}
    875872
    876 //The total number of operations is 86
     873//The total number of operations is 83
    877874template <> inline bitblock128_t simd<128>::lt(bitblock128_t arg1, bitblock128_t arg2)
    878875{
     
    969966}
    970967
    971 //The total number of operations is 34
     968//The total number of operations is 30
    972969template <> inline bitblock128_t simd<128>::ctz(bitblock128_t arg1)
    973970{
     
    10311028}
    10321029
    1033 //The total number of operations is 60
     1030//The total number of operations is 56
    10341031template <> inline bitblock128_t simd<128>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10351032{
    1036         bitblock128_t tmpAns = simd<(64)>::ugt(arg1, arg2);
    1037         bitblock128_t mask = simd_and(tmpAns, simd<128>::srli<(64)>(simd<(64)>::eq(arg1, arg2)));
    1038         mask = simd_or(mask, simd<128>::slli<(64)>(mask));
    1039         return simd_or(simd<128>::srai<(64)>(tmpAns), mask);
     1033        return simd_and(simd<128>::srai<(127)>(simd_or(simd_and(arg1, simd_not(arg2)), simd_and(simd_not(simd_xor(arg1, arg2)), simd_not(simd<128>::sub(arg1, arg2))))), simd_not(simd<128>::eq(arg1, arg2)));
    10401034}
    10411035
     
    11731167}
    11741168
    1175 //The total number of operations is 15
     1169//The total number of operations is 11
    11761170template <> inline bitblock128_t simd<128>::neg(bitblock128_t arg1)
    11771171{
     
    13121306}
    13131307
    1314 //The total number of operations is 15
     1308//The total number of operations is 11
    13151309template <> inline bitblock128_t simd<128>::sub(bitblock128_t arg1, bitblock128_t arg2)
    13161310{
    1317         bitblock128_t ans = simd<(64)>::sub(arg1, arg2);
    1318         bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_and(simd_not(simd_xor(arg1, arg2)), ans));
    1319         bitblock128_t loMask = simd<128>::lomask();
    1320         bitblock128_t borrow = simd<128>::slli<1>(simd_and(borrowMask, loMask));
    1321         return simd<1>::ifh(loMask, ans, simd<(64)>::sub(ans, borrow));
     1311        bitblock128_t partial = simd<(64)>::sub(arg1, arg2);
     1312        bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_andc(partial, simd_xor(arg1, arg2)));
     1313        bitblock128_t borrow = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(borrowMask));
     1314        return simd<(64)>::sub(partial, borrow);
    13221315}
    13231316
     
    13581351}
    13591352
    1360 //The total number of operations is 20
     1353//The total number of operations is 16
    13611354template <> inline bitblock128_t simd<128>::add_hl(bitblock128_t arg1)
    13621355{
     
    15101503}
    15111504
    1512 //The total number of operations is 87
     1505//The total number of operations is 84
    15131506template <> inline bitblock128_t simd<128>::min(bitblock128_t arg1, bitblock128_t arg2)
    15141507{
     
    17311724}
    17321725
    1733 //The total number of operations is 24
     1726//The total number of operations is 21
    17341727template <> template <uint64_t sh> inline bitblock128_t simd<128>::srai(bitblock128_t arg1)
    17351728{
    1736         return simd_or(simd_and(simd<128>::himask(), simd<(64)>::srai<sh>(arg1)), simd<1>::ifh(simd<32>::gt(simd<32>::constant<sh>(), simd<32>::constant<(64)>()), simd<(64)>::srai<(sh-(64))>(simd<128>::srli<(64)>(arg1)), simd<128>::srli<sh>(arg1)));
     1729        bitblock128_t tmp = simd<128>::srli<((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh))>(arg1);
     1730        return simd_or(tmp, simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::slli<((128-((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh)))-1)>(simd<128>::constant<1>()), tmp)));
    17371731}
    17381732
     
    18221816}
    18231817
    1824 //The total number of operations is 15
     1818//The total number of operations is 11
    18251819template <> inline bitblock128_t simd<128>::add(bitblock128_t arg1, bitblock128_t arg2)
    18261820{
    1827         bitblock128_t ans = simd<(64)>::add(arg1, arg2);
    1828         bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_and(simd_xor(arg1, arg2), simd_not(ans)));
    1829         bitblock128_t loMask = simd<128>::lomask();
    1830         bitblock128_t carry = simd<128>::slli<1>(simd_and(carryMask, loMask));
    1831         return simd<1>::ifh(loMask, ans, simd<(64)>::add(ans, carry));
     1821        bitblock128_t partial = simd<(64)>::add(arg1, arg2);
     1822        bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_andc(simd_xor(arg1, arg2), partial));
     1823        bitblock128_t carry = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(carryMask));
     1824        return simd<(64)>::add(partial, carry);
    18321825}
    18331826
     
    18801873}
    18811874
    1882 //The total number of operations is 53
     1875//The total number of operations is 49
    18831876template <> inline bitblock128_t simd<128>::abs(bitblock128_t arg1)
    18841877{
     
    20152008}
    20162009
    2017 //The total number of operations is 360
     2010//The total number of operations is 348
    20182011template <> inline bitblock128_t hsimd<128>::packss(bitblock128_t arg1, bitblock128_t arg2)
    20192012{
     
    24512444}
    24522445
    2453 //The total number of operations is 24
     2446//The total number of operations is 21
    24542447template <> inline bitblock128_t esimd<64>::signextendh(bitblock128_t arg1)
    24552448{
     
    24932486}
    24942487
    2495 //The total number of operations is 28
     2488//The total number of operations is 25
    24962489template <> inline bitblock128_t esimd<64>::signextendl(bitblock128_t arg1)
    24972490{
     
    26612654}
    26622655
    2663 //The total number of operations is 17
     2656//The total number of operations is 16
    26642657template <> template <uint64_t pos> inline bitblock128_t mvmd<1>::splat(bitblock128_t arg1)
    26652658{
    2666         bitblock128_t tmpArg = (((pos%2) == 0) ? simd<(2)>::slli<1>(arg1) : simd<(2)>::srli<1>(arg1));
    2667         bitblock128_t arg11 = (((pos%2) == 0) ? simd_and(simd<(2)>::lomask(), arg1) : simd_and(simd<(2)>::himask(), arg1));
    2668         return mvmd<(2)>::splat<(pos/2)>(simd_or(tmpArg, arg11));
     2659        return simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::constant<1>(), simd<128>::srli<pos>(arg1)));
    26692660}
    26702661
  • trunk/libgen/idisa_lib/cpp/idisa_sse3.cpp

    r1521 r1525  
    562562}
    563563
    564 //The total number of operations is 87
     564//The total number of operations is 84
    565565template <> inline bitblock128_t simd<128>::max(bitblock128_t arg1, bitblock128_t arg2)
    566566{
     
    632632}
    633633
    634 //The total number of operations is 249
     634//The total number of operations is 205
    635635template <> inline bitblock128_t simd<128>::mult(bitblock128_t arg1, bitblock128_t arg2)
    636636{
     
    694694}
    695695
    696 //The total number of operations is 84
     696//The total number of operations is 81
    697697template <> inline bitblock128_t simd<128>::gt(bitblock128_t arg1, bitblock128_t arg2)
    698698{
     
    755755}
    756756
    757 //The total number of operations is 67
     757//The total number of operations is 55
    758758template <> inline bitblock128_t simd<64>::umult(bitblock128_t arg1, bitblock128_t arg2)
    759759{
     
    817817}
    818818
    819 //The total number of operations is 59
     819//The total number of operations is 55
    820820template <> inline bitblock128_t simd<128>::ult(bitblock128_t arg1, bitblock128_t arg2)
    821821{
    822         bitblock128_t tmpAns = simd<(64)>::ult(arg1, arg2);
    823         bitblock128_t mask = simd_and(tmpAns, simd<128>::srli<(64)>(simd<(64)>::eq(arg1, arg2)));
    824         mask = simd_or(mask, simd<128>::slli<(64)>(mask));
    825         return simd_or(simd<128>::srai<(64)>(tmpAns), mask);
     822        return simd_and(simd<128>::srai<(127)>(simd_or(simd_and(simd_not(arg1), arg2), simd_and(simd_not(simd_xor(arg1, arg2)), simd<128>::sub(arg1, arg2)))), simd_not(simd<128>::eq(arg1, arg2)));
    826823}
    827824
     
    874871}
    875872
    876 //The total number of operations is 86
     873//The total number of operations is 83
    877874template <> inline bitblock128_t simd<128>::lt(bitblock128_t arg1, bitblock128_t arg2)
    878875{
     
    969966}
    970967
    971 //The total number of operations is 34
     968//The total number of operations is 30
    972969template <> inline bitblock128_t simd<128>::ctz(bitblock128_t arg1)
    973970{
     
    10311028}
    10321029
    1033 //The total number of operations is 60
     1030//The total number of operations is 56
    10341031template <> inline bitblock128_t simd<128>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10351032{
    1036         bitblock128_t tmpAns = simd<(64)>::ugt(arg1, arg2);
    1037         bitblock128_t mask = simd_and(tmpAns, simd<128>::srli<(64)>(simd<(64)>::eq(arg1, arg2)));
    1038         mask = simd_or(mask, simd<128>::slli<(64)>(mask));
    1039         return simd_or(simd<128>::srai<(64)>(tmpAns), mask);
     1033        return simd_and(simd<128>::srai<(127)>(simd_or(simd_and(arg1, simd_not(arg2)), simd_and(simd_not(simd_xor(arg1, arg2)), simd_not(simd<128>::sub(arg1, arg2))))), simd_not(simd<128>::eq(arg1, arg2)));
    10401034}
    10411035
     
    11731167}
    11741168
    1175 //The total number of operations is 15
     1169//The total number of operations is 11
    11761170template <> inline bitblock128_t simd<128>::neg(bitblock128_t arg1)
    11771171{
     
    13121306}
    13131307
    1314 //The total number of operations is 15
     1308//The total number of operations is 11
    13151309template <> inline bitblock128_t simd<128>::sub(bitblock128_t arg1, bitblock128_t arg2)
    13161310{
    1317         bitblock128_t ans = simd<(64)>::sub(arg1, arg2);
    1318         bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_and(simd_not(simd_xor(arg1, arg2)), ans));
    1319         bitblock128_t loMask = simd<128>::lomask();
    1320         bitblock128_t borrow = simd<128>::slli<1>(simd_and(borrowMask, loMask));
    1321         return simd<1>::ifh(loMask, ans, simd<(64)>::sub(ans, borrow));
     1311        bitblock128_t partial = simd<(64)>::sub(arg1, arg2);
     1312        bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_andc(partial, simd_xor(arg1, arg2)));
     1313        bitblock128_t borrow = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(borrowMask));
     1314        return simd<(64)>::sub(partial, borrow);
    13221315}
    13231316
     
    13581351}
    13591352
    1360 //The total number of operations is 20
     1353//The total number of operations is 16
    13611354template <> inline bitblock128_t simd<128>::add_hl(bitblock128_t arg1)
    13621355{
     
    15101503}
    15111504
    1512 //The total number of operations is 87
     1505//The total number of operations is 84
    15131506template <> inline bitblock128_t simd<128>::min(bitblock128_t arg1, bitblock128_t arg2)
    15141507{
     
    17311724}
    17321725
    1733 //The total number of operations is 24
     1726//The total number of operations is 21
    17341727template <> template <uint64_t sh> inline bitblock128_t simd<128>::srai(bitblock128_t arg1)
    17351728{
    1736         return simd_or(simd_and(simd<128>::himask(), simd<(64)>::srai<sh>(arg1)), simd<1>::ifh(simd<32>::gt(simd<32>::constant<sh>(), simd<32>::constant<(64)>()), simd<(64)>::srai<(sh-(64))>(simd<128>::srli<(64)>(arg1)), simd<128>::srli<sh>(arg1)));
     1729        bitblock128_t tmp = simd<128>::srli<((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh))>(arg1);
     1730        return simd_or(tmp, simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::slli<((128-((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh)))-1)>(simd<128>::constant<1>()), tmp)));
    17371731}
    17381732
     
    18221816}
    18231817
    1824 //The total number of operations is 15
     1818//The total number of operations is 11
    18251819template <> inline bitblock128_t simd<128>::add(bitblock128_t arg1, bitblock128_t arg2)
    18261820{
    1827         bitblock128_t ans = simd<(64)>::add(arg1, arg2);
    1828         bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_and(simd_xor(arg1, arg2), simd_not(ans)));
    1829         bitblock128_t loMask = simd<128>::lomask();
    1830         bitblock128_t carry = simd<128>::slli<1>(simd_and(carryMask, loMask));
    1831         return simd<1>::ifh(loMask, ans, simd<(64)>::add(ans, carry));
     1821        bitblock128_t partial = simd<(64)>::add(arg1, arg2);
     1822        bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_andc(simd_xor(arg1, arg2), partial));
     1823        bitblock128_t carry = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(carryMask));
     1824        return simd<(64)>::add(partial, carry);
    18321825}
    18331826
     
    18801873}
    18811874
    1882 //The total number of operations is 53
     1875//The total number of operations is 49
    18831876template <> inline bitblock128_t simd<128>::abs(bitblock128_t arg1)
    18841877{
     
    20152008}
    20162009
    2017 //The total number of operations is 360
     2010//The total number of operations is 348
    20182011template <> inline bitblock128_t hsimd<128>::packss(bitblock128_t arg1, bitblock128_t arg2)
    20192012{
     
    24512444}
    24522445
    2453 //The total number of operations is 24
     2446//The total number of operations is 21
    24542447template <> inline bitblock128_t esimd<64>::signextendh(bitblock128_t arg1)
    24552448{
     
    24932486}
    24942487
    2495 //The total number of operations is 28
     2488//The total number of operations is 25
    24962489template <> inline bitblock128_t esimd<64>::signextendl(bitblock128_t arg1)
    24972490{
     
    26612654}
    26622655
    2663 //The total number of operations is 17
     2656//The total number of operations is 16
    26642657template <> template <uint64_t pos> inline bitblock128_t mvmd<1>::splat(bitblock128_t arg1)
    26652658{
    2666         bitblock128_t tmpArg = (((pos%2) == 0) ? simd<(2)>::slli<1>(arg1) : simd<(2)>::srli<1>(arg1));
    2667         bitblock128_t arg11 = (((pos%2) == 0) ? simd_and(simd<(2)>::lomask(), arg1) : simd_and(simd<(2)>::himask(), arg1));
    2668         return mvmd<(2)>::splat<(pos/2)>(simd_or(tmpArg, arg11));
     2659        return simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::constant<1>(), simd<128>::srli<pos>(arg1)));
    26692660}
    26702661
  • trunk/libgen/idisa_lib/cpp/idisa_sse4_1.cpp

    r1521 r1525  
    642642}
    643643
    644 //The total number of operations is 249
     644//The total number of operations is 205
    645645template <> inline bitblock128_t simd<128>::mult(bitblock128_t arg1, bitblock128_t arg2)
    646646{
     
    704704}
    705705
    706 //The total number of operations is 76
     706//The total number of operations is 73
    707707template <> inline bitblock128_t simd<128>::gt(bitblock128_t arg1, bitblock128_t arg2)
    708708{
     
    765765}
    766766
    767 //The total number of operations is 67
     767//The total number of operations is 55
    768768template <> inline bitblock128_t simd<64>::umult(bitblock128_t arg1, bitblock128_t arg2)
    769769{
     
    827827}
    828828
    829 //The total number of operations is 51
     829//The total number of operations is 48
    830830template <> inline bitblock128_t simd<128>::ult(bitblock128_t arg1, bitblock128_t arg2)
    831831{
     
    884884}
    885885
    886 //The total number of operations is 78
     886//The total number of operations is 75
    887887template <> inline bitblock128_t simd<128>::lt(bitblock128_t arg1, bitblock128_t arg2)
    888888{
     
    979979}
    980980
    981 //The total number of operations is 34
     981//The total number of operations is 30
    982982template <> inline bitblock128_t simd<128>::ctz(bitblock128_t arg1)
    983983{
     
    10411041}
    10421042
    1043 //The total number of operations is 52
     1043//The total number of operations is 49
    10441044template <> inline bitblock128_t simd<128>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10451045{
     
    11831183}
    11841184
    1185 //The total number of operations is 15
     1185//The total number of operations is 11
    11861186template <> inline bitblock128_t simd<128>::neg(bitblock128_t arg1)
    11871187{
     
    13221322}
    13231323
    1324 //The total number of operations is 15
     1324//The total number of operations is 11
    13251325template <> inline bitblock128_t simd<128>::sub(bitblock128_t arg1, bitblock128_t arg2)
    13261326{
    1327         bitblock128_t ans = simd<(64)>::sub(arg1, arg2);
    1328         bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_and(simd_not(simd_xor(arg1, arg2)), ans));
    1329         bitblock128_t loMask = simd<128>::lomask();
    1330         bitblock128_t borrow = simd<128>::slli<1>(simd_and(borrowMask, loMask));
    1331         return simd<1>::ifh(loMask, ans, simd<(64)>::sub(ans, borrow));
     1327        bitblock128_t partial = simd<(64)>::sub(arg1, arg2);
     1328        bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_andc(partial, simd_xor(arg1, arg2)));
     1329        bitblock128_t borrow = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(borrowMask));
     1330        return simd<(64)>::sub(partial, borrow);
    13321331}
    13331332
     
    13681367}
    13691368
    1370 //The total number of operations is 20
     1369//The total number of operations is 16
    13711370template <> inline bitblock128_t simd<128>::add_hl(bitblock128_t arg1)
    13721371{
     
    17341733}
    17351734
    1736 //The total number of operations is 24
     1735//The total number of operations is 21
    17371736template <> template <uint64_t sh> inline bitblock128_t simd<128>::srai(bitblock128_t arg1)
    17381737{
    1739         return simd_or(simd_and(simd<128>::himask(), simd<(64)>::srai<sh>(arg1)), simd<1>::ifh(simd<32>::gt(simd<32>::constant<sh>(), simd<32>::constant<(64)>()), simd<(64)>::srai<(sh-(64))>(simd<128>::srli<(64)>(arg1)), simd<128>::srli<sh>(arg1)));
     1738        bitblock128_t tmp = simd<128>::srli<((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh))>(arg1);
     1739        return simd_or(tmp, simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::slli<((128-((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh)))-1)>(simd<128>::constant<1>()), tmp)));
    17401740}
    17411741
     
    18251825}
    18261826
    1827 //The total number of operations is 15
     1827//The total number of operations is 11
    18281828template <> inline bitblock128_t simd<128>::add(bitblock128_t arg1, bitblock128_t arg2)
    18291829{
    1830         bitblock128_t ans = simd<(64)>::add(arg1, arg2);
    1831         bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_and(simd_xor(arg1, arg2), simd_not(ans)));
    1832         bitblock128_t loMask = simd<128>::lomask();
    1833         bitblock128_t carry = simd<128>::slli<1>(simd_and(carryMask, loMask));
    1834         return simd<1>::ifh(loMask, ans, simd<(64)>::add(ans, carry));
     1830        bitblock128_t partial = simd<(64)>::add(arg1, arg2);
     1831        bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_andc(simd_xor(arg1, arg2), partial));
     1832        bitblock128_t carry = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(carryMask));
     1833        return simd<(64)>::add(partial, carry);
    18351834}
    18361835
     
    18801879}
    18811880
    1882 //The total number of operations is 41
     1881//The total number of operations is 37
    18831882template <> inline bitblock128_t simd<128>::abs(bitblock128_t arg1)
    18841883{
     
    20152014}
    20162015
    2017 //The total number of operations is 328
     2016//The total number of operations is 316
    20182017template <> inline bitblock128_t hsimd<128>::packss(bitblock128_t arg1, bitblock128_t arg2)
    20192018{
     
    24472446}
    24482447
    2449 //The total number of operations is 24
     2448//The total number of operations is 21
    24502449template <> inline bitblock128_t esimd<64>::signextendh(bitblock128_t arg1)
    24512450{
     
    24892488}
    24902489
    2491 //The total number of operations is 28
     2490//The total number of operations is 25
    24922491template <> inline bitblock128_t esimd<64>::signextendl(bitblock128_t arg1)
    24932492{
  • trunk/libgen/idisa_lib/cpp/idisa_sse4_2.cpp

    r1521 r1525  
    638638}
    639639
    640 //The total number of operations is 249
     640//The total number of operations is 205
    641641template <> inline bitblock128_t simd<128>::mult(bitblock128_t arg1, bitblock128_t arg2)
    642642{
     
    696696}
    697697
    698 //The total number of operations is 53
     698//The total number of operations is 50
    699699template <> inline bitblock128_t simd<128>::gt(bitblock128_t arg1, bitblock128_t arg2)
    700700{
     
    757757}
    758758
    759 //The total number of operations is 67
     759//The total number of operations is 55
    760760template <> inline bitblock128_t simd<64>::umult(bitblock128_t arg1, bitblock128_t arg2)
    761761{
     
    819819}
    820820
    821 //The total number of operations is 51
     821//The total number of operations is 48
    822822template <> inline bitblock128_t simd<128>::ult(bitblock128_t arg1, bitblock128_t arg2)
    823823{
     
    872872}
    873873
    874 //The total number of operations is 56
     874//The total number of operations is 53
    875875template <> inline bitblock128_t simd<128>::lt(bitblock128_t arg1, bitblock128_t arg2)
    876876{
     
    967967}
    968968
    969 //The total number of operations is 34
     969//The total number of operations is 30
    970970template <> inline bitblock128_t simd<128>::ctz(bitblock128_t arg1)
    971971{
     
    10291029}
    10301030
    1031 //The total number of operations is 52
     1031//The total number of operations is 49
    10321032template <> inline bitblock128_t simd<128>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10331033{
     
    11711171}
    11721172
    1173 //The total number of operations is 15
     1173//The total number of operations is 11
    11741174template <> inline bitblock128_t simd<128>::neg(bitblock128_t arg1)
    11751175{
     
    13101310}
    13111311
    1312 //The total number of operations is 15
     1312//The total number of operations is 11
    13131313template <> inline bitblock128_t simd<128>::sub(bitblock128_t arg1, bitblock128_t arg2)
    13141314{
    1315         bitblock128_t ans = simd<(64)>::sub(arg1, arg2);
    1316         bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_and(simd_not(simd_xor(arg1, arg2)), ans));
    1317         bitblock128_t loMask = simd<128>::lomask();
    1318         bitblock128_t borrow = simd<128>::slli<1>(simd_and(borrowMask, loMask));
    1319         return simd<1>::ifh(loMask, ans, simd<(64)>::sub(ans, borrow));
     1315        bitblock128_t partial = simd<(64)>::sub(arg1, arg2);
     1316        bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_andc(partial, simd_xor(arg1, arg2)));
     1317        bitblock128_t borrow = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(borrowMask));
     1318        return simd<(64)>::sub(partial, borrow);
    13201319}
    13211320
     
    13561355}
    13571356
    1358 //The total number of operations is 20
     1357//The total number of operations is 16
    13591358template <> inline bitblock128_t simd<128>::add_hl(bitblock128_t arg1)
    13601359{
     
    17181717}
    17191718
    1720 //The total number of operations is 24
     1719//The total number of operations is 21
    17211720template <> template <uint64_t sh> inline bitblock128_t simd<128>::srai(bitblock128_t arg1)
    17221721{
    1723         return simd_or(simd_and(simd<128>::himask(), simd<(64)>::srai<sh>(arg1)), simd<1>::ifh(simd<32>::gt(simd<32>::constant<sh>(), simd<32>::constant<(64)>()), simd<(64)>::srai<(sh-(64))>(simd<128>::srli<(64)>(arg1)), simd<128>::srli<sh>(arg1)));
     1722        bitblock128_t tmp = simd<128>::srli<((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh))>(arg1);
     1723        return simd_or(tmp, simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::slli<((128-((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh)))-1)>(simd<128>::constant<1>()), tmp)));
    17241724}
    17251725
     
    18091809}
    18101810
    1811 //The total number of operations is 15
     1811//The total number of operations is 11
    18121812template <> inline bitblock128_t simd<128>::add(bitblock128_t arg1, bitblock128_t arg2)
    18131813{
    1814         bitblock128_t ans = simd<(64)>::add(arg1, arg2);
    1815         bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_and(simd_xor(arg1, arg2), simd_not(ans)));
    1816         bitblock128_t loMask = simd<128>::lomask();
    1817         bitblock128_t carry = simd<128>::slli<1>(simd_and(carryMask, loMask));
    1818         return simd<1>::ifh(loMask, ans, simd<(64)>::add(ans, carry));
     1814        bitblock128_t partial = simd<(64)>::add(arg1, arg2);
     1815        bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_andc(simd_xor(arg1, arg2), partial));
     1816        bitblock128_t carry = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(carryMask));
     1817        return simd<(64)>::add(partial, carry);
    18191818}
    18201819
     
    18641863}
    18651864
    1866 //The total number of operations is 37
     1865//The total number of operations is 33
    18671866template <> inline bitblock128_t simd<128>::abs(bitblock128_t arg1)
    18681867{
     
    19991998}
    20001999
    2001 //The total number of operations is 236
     2000//The total number of operations is 224
    20022001template <> inline bitblock128_t hsimd<128>::packss(bitblock128_t arg1, bitblock128_t arg2)
    20032002{
     
    24312430}
    24322431
    2433 //The total number of operations is 24
     2432//The total number of operations is 21
    24342433template <> inline bitblock128_t esimd<64>::signextendh(bitblock128_t arg1)
    24352434{
     
    24732472}
    24742473
    2475 //The total number of operations is 28
     2474//The total number of operations is 25
    24762475template <> inline bitblock128_t esimd<64>::signextendl(bitblock128_t arg1)
    24772476{
  • trunk/libgen/idisa_lib/cpp/idisa_ssse3.cpp

    r1521 r1525  
    567567}
    568568
    569 //The total number of operations is 87
     569//The total number of operations is 84
    570570template <> inline bitblock128_t simd<128>::max(bitblock128_t arg1, bitblock128_t arg2)
    571571{
     
    637637}
    638638
    639 //The total number of operations is 249
     639//The total number of operations is 205
    640640template <> inline bitblock128_t simd<128>::mult(bitblock128_t arg1, bitblock128_t arg2)
    641641{
     
    699699}
    700700
    701 //The total number of operations is 84
     701//The total number of operations is 81
    702702template <> inline bitblock128_t simd<128>::gt(bitblock128_t arg1, bitblock128_t arg2)
    703703{
     
    760760}
    761761
    762 //The total number of operations is 67
     762//The total number of operations is 55
    763763template <> inline bitblock128_t simd<64>::umult(bitblock128_t arg1, bitblock128_t arg2)
    764764{
     
    822822}
    823823
    824 //The total number of operations is 59
     824//The total number of operations is 55
    825825template <> inline bitblock128_t simd<128>::ult(bitblock128_t arg1, bitblock128_t arg2)
    826826{
    827         bitblock128_t tmpAns = simd<(64)>::ult(arg1, arg2);
    828         bitblock128_t mask = simd_and(tmpAns, simd<128>::srli<(64)>(simd<(64)>::eq(arg1, arg2)));
    829         mask = simd_or(mask, simd<128>::slli<(64)>(mask));
    830         return simd_or(simd<128>::srai<(64)>(tmpAns), mask);
     827        return simd_and(simd<128>::srai<(127)>(simd_or(simd_and(simd_not(arg1), arg2), simd_and(simd_not(simd_xor(arg1, arg2)), simd<128>::sub(arg1, arg2)))), simd_not(simd<128>::eq(arg1, arg2)));
    831828}
    832829
     
    879876}
    880877
    881 //The total number of operations is 86
     878//The total number of operations is 83
    882879template <> inline bitblock128_t simd<128>::lt(bitblock128_t arg1, bitblock128_t arg2)
    883880{
     
    974971}
    975972
    976 //The total number of operations is 34
     973//The total number of operations is 30
    977974template <> inline bitblock128_t simd<128>::ctz(bitblock128_t arg1)
    978975{
     
    10361033}
    10371034
    1038 //The total number of operations is 60
     1035//The total number of operations is 56
    10391036template <> inline bitblock128_t simd<128>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10401037{
    1041         bitblock128_t tmpAns = simd<(64)>::ugt(arg1, arg2);
    1042         bitblock128_t mask = simd_and(tmpAns, simd<128>::srli<(64)>(simd<(64)>::eq(arg1, arg2)));
    1043         mask = simd_or(mask, simd<128>::slli<(64)>(mask));
    1044         return simd_or(simd<128>::srai<(64)>(tmpAns), mask);
     1038        return simd_and(simd<128>::srai<(127)>(simd_or(simd_and(arg1, simd_not(arg2)), simd_and(simd_not(simd_xor(arg1, arg2)), simd_not(simd<128>::sub(arg1, arg2))))), simd_not(simd<128>::eq(arg1, arg2)));
    10451039}
    10461040
     
    11781172}
    11791173
    1180 //The total number of operations is 15
     1174//The total number of operations is 11
    11811175template <> inline bitblock128_t simd<128>::neg(bitblock128_t arg1)
    11821176{
     
    13171311}
    13181312
    1319 //The total number of operations is 15
     1313//The total number of operations is 11
    13201314template <> inline bitblock128_t simd<128>::sub(bitblock128_t arg1, bitblock128_t arg2)
    13211315{
    1322         bitblock128_t ans = simd<(64)>::sub(arg1, arg2);
    1323         bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_and(simd_not(simd_xor(arg1, arg2)), ans));
    1324         bitblock128_t loMask = simd<128>::lomask();
    1325         bitblock128_t borrow = simd<128>::slli<1>(simd_and(borrowMask, loMask));
    1326         return simd<1>::ifh(loMask, ans, simd<(64)>::sub(ans, borrow));
     1316        bitblock128_t partial = simd<(64)>::sub(arg1, arg2);
     1317        bitblock128_t borrowMask = simd_or(simd_andc(arg2, arg1), simd_andc(partial, simd_xor(arg1, arg2)));
     1318        bitblock128_t borrow = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(borrowMask));
     1319        return simd<(64)>::sub(partial, borrow);
    13271320}
    13281321
     
    13631356}
    13641357
    1365 //The total number of operations is 20
     1358//The total number of operations is 16
    13661359template <> inline bitblock128_t simd<128>::add_hl(bitblock128_t arg1)
    13671360{
     
    15151508}
    15161509
    1517 //The total number of operations is 87
     1510//The total number of operations is 84
    15181511template <> inline bitblock128_t simd<128>::min(bitblock128_t arg1, bitblock128_t arg2)
    15191512{
     
    17361729}
    17371730
    1738 //The total number of operations is 24
     1731//The total number of operations is 21
    17391732template <> template <uint64_t sh> inline bitblock128_t simd<128>::srai(bitblock128_t arg1)
    17401733{
    1741         return simd_or(simd_and(simd<128>::himask(), simd<(64)>::srai<sh>(arg1)), simd<1>::ifh(simd<32>::gt(simd<32>::constant<sh>(), simd<32>::constant<(64)>()), simd<(64)>::srai<(sh-(64))>(simd<128>::srli<(64)>(arg1)), simd<128>::srli<sh>(arg1)));
     1734        bitblock128_t tmp = simd<128>::srli<((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh))>(arg1);
     1735        return simd_or(tmp, simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::slli<((128-((sh >= 128) ? (127) : ((sh < 0) ? 0 : sh)))-1)>(simd<128>::constant<1>()), tmp)));
    17421736}
    17431737
     
    18271821}
    18281822
    1829 //The total number of operations is 15
     1823//The total number of operations is 11
    18301824template <> inline bitblock128_t simd<128>::add(bitblock128_t arg1, bitblock128_t arg2)
    18311825{
    1832         bitblock128_t ans = simd<(64)>::add(arg1, arg2);
    1833         bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_and(simd_xor(arg1, arg2), simd_not(ans)));
    1834         bitblock128_t loMask = simd<128>::lomask();
    1835         bitblock128_t carry = simd<128>::slli<1>(simd_and(carryMask, loMask));
    1836         return simd<1>::ifh(loMask, ans, simd<(64)>::add(ans, carry));
     1826        bitblock128_t partial = simd<(64)>::add(arg1, arg2);
     1827        bitblock128_t carryMask = simd_or(simd_and(arg1, arg2), simd_andc(simd_xor(arg1, arg2), partial));
     1828        bitblock128_t carry = simd<128>::slli<(64)>(simd<(64)>::srli<(63)>(carryMask));
     1829        return simd<(64)>::add(partial, carry);
    18371830}
    18381831
     
    18821875}
    18831876
    1884 //The total number of operations is 49
     1877//The total number of operations is 45
    18851878template <> inline bitblock128_t simd<128>::abs(bitblock128_t arg1)
    18861879{
     
    20172010}
    20182011
    2019 //The total number of operations is 360
     2012//The total number of operations is 348
    20202013template <> inline bitblock128_t hsimd<128>::packss(bitblock128_t arg1, bitblock128_t arg2)
    20212014{
     
    24502443}
    24512444
    2452 //The total number of operations is 24
     2445//The total number of operations is 21
    24532446template <> inline bitblock128_t esimd<64>::signextendh(bitblock128_t arg1)
    24542447{
     
    24922485}
    24932486
    2494 //The total number of operations is 28
     2487//The total number of operations is 25
    24952488template <> inline bitblock128_t esimd<64>::signextendl(bitblock128_t arg1)
    24962489{
     
    26962689}
    26972690
    2698 //The total number of operations is 17
     2691//The total number of operations is 16
    26992692template <> template <uint64_t pos> inline bitblock128_t mvmd<1>::splat(bitblock128_t arg1)
    27002693{
    2701         bitblock128_t tmpArg = (((pos%2) == 0) ? simd<(2)>::slli<1>(arg1) : simd<(2)>::srli<1>(arg1));
    2702         bitblock128_t arg11 = (((pos%2) == 0) ? simd_and(simd<(2)>::lomask(), arg1) : simd_and(simd<(2)>::himask(), arg1));
    2703         return mvmd<(2)>::splat<(pos/2)>(simd_or(tmpArg, arg11));
     2694        return simd<128>::sub(simd<128>::constant<0>(), simd_and(simd<128>::constant<1>(), simd<128>::srli<pos>(arg1)));
    27042695}
    27052696
Note: See TracChangeset for help on using the changeset viewer.