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_ssse3.cpp

    r1570 r1573  
    192192template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<64>::popcount(bitblock128_t arg1);
    193193template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<128>::popcount(bitblock128_t arg1);
    194 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::neg(bitblock128_t arg1);
    195194template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1);
    196195template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<4>::neg(bitblock128_t arg1);
     
    301300template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<64>::add(bitblock128_t arg1, bitblock128_t arg2);
    302301template <> 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);
    304302template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::abs(bitblock128_t arg1);
    305303template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<4>::abs(bitblock128_t arg1);
     
    533531}
    534532
    535 //The total number of operations is 39
     533//The total number of operations is 1
    536534template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::max(bitblock128_t arg1, bitblock128_t arg2)
    537535{
    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
    543540template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::max(bitblock128_t arg1, bitblock128_t arg2)
    544541{
    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);
    546543}
    547544
     
    587584}
    588585
    589 //The total number of operations is 57
     586//The total number of operations is 1
    590587template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::mult(bitblock128_t arg1, bitblock128_t arg2)
    591588{
    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);
    596590}
    597591
     
    665659}
    666660
    667 //The total number of operations is 42
     661//The total number of operations is 1
    668662template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::gt(bitblock128_t arg1, bitblock128_t arg2)
    669663{
    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
    675668template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::gt(bitblock128_t arg1, bitblock128_t arg2)
    676669{
    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);
    680675}
    681676
     
    793788}
    794789
    795 //The total number of operations is 40
     790//The total number of operations is 1
    796791template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ult(bitblock128_t arg1, bitblock128_t arg2)
    797792{
    798         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())));
    799 }
    800 
    801 //The total number of operations is 17
     793        return simd_andc(arg2, arg1);
     794}
     795
     796//The total number of operations is 14
    802797template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ult(bitblock128_t arg1, bitblock128_t arg2)
    803798{
    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);
    807803}
    808804
     
    849845}
    850846
    851 //The total number of operations is 42
     847//The total number of operations is 1
    852848template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::lt(bitblock128_t arg1, bitblock128_t arg2)
    853849{
    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
    859854template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::lt(bitblock128_t arg1, bitblock128_t arg2)
    860855{
    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);
    864861}
    865862
     
    10081005}
    10091006
    1010 //The total number of operations is 40
     1007//The total number of operations is 1
    10111008template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10121009{
    1013         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())));
    1014 }
    1015 
    1016 //The total number of operations is 17
     1010        return simd_andc(arg1, arg2);
     1011}
     1012
     1013//The total number of operations is 14
    10171014template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10181015{
    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);
    10221020}
    10231021
     
    11581156}
    11591157
    1160 //The total number of operations is 1
    1161 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 
    11661158//The total number of operations is 8
    11671159template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1)
     
    14921484}
    14931485
    1494 //The total number of operations is 39
     1486//The total number of operations is 1
    14951487template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::min(bitblock128_t arg1, bitblock128_t arg2)
    14961488{
    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
    15021493template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::min(bitblock128_t arg1, bitblock128_t arg2)
    15031494{
    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);
    15061496}
    15071497
     
    15471537}
    15481538
    1549 //The total number of operations is 36
     1539//The total number of operations is 1
    15501540template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umin(bitblock128_t arg1, bitblock128_t arg2)
    15511541{
    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);
    15531543}
    15541544
     
    16031593}
    16041594
    1605 //The total number of operations is 36
     1595//The total number of operations is 1
    16061596template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umax(bitblock128_t arg1, bitblock128_t arg2)
    16071597{
    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);
    16091599}
    16101600
     
    16591649}
    16601650
    1661 //The total number of operations is 37
     1651//The total number of operations is 2
    16621652template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16631653{
    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 15
     1654        return simd_not(simd_xor(arg1, arg2));
     1655}
     1656
     1657//The total number of operations is 8
    16681658template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16691659{
    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);
    16731664}
    16741665
     
    18551846}
    18561847
    1857 //The total number of operations is 46
    1858 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 
    18641848//The total number of operations is 9
    18651849template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::abs(bitblock128_t arg1)
     
    19071891}
    19081892
    1909 //The total number of operations is 128
     1893//The total number of operations is 93
    19101894template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::umin_hl(bitblock128_t arg1, bitblock128_t arg2)
    19111895{
     
    19911975}
    19921976
    1993 //The total number of operations is 132
     1977//The total number of operations is 120
    19941978template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packss(bitblock128_t arg1, bitblock128_t arg2)
    19951979{
     
    21652149}
    21662150
    2167 //The total number of operations is 131
     2151//The total number of operations is 93
    21682152template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::min_hl(bitblock128_t arg1, bitblock128_t arg2)
    21692153{
     
    21712155}
    21722156
    2173 //The total number of operations is 83
     2157//The total number of operations is 82
    21742158template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<4>::min_hl(bitblock128_t arg1, bitblock128_t arg2)
    21752159{
     
    22072191}
    22082192
    2209 //The total number of operations is 99
     2193//The total number of operations is 85
    22102194template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packus(bitblock128_t arg1, bitblock128_t arg2)
    22112195{
Note: See TracChangeset for help on using the changeset viewer.