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_sse4_2.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
     
    662656}
    663657
    664 //The total number of operations is 42
     658//The total number of operations is 1
    665659template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::gt(bitblock128_t arg1, bitblock128_t arg2)
    666660{
    667         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    668         return simd128<1>::ugt(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    669 }
    670 
    671 //The total number of operations is 18
     661        return simd_andc(arg2, arg1);
     662}
     663
     664//The total number of operations is 15
    672665template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::gt(bitblock128_t arg1, bitblock128_t arg2)
    673666{
    674         bitblock128_t tmp = simd_not(arg1);
    675         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)));
    676         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     667        bitblock128_t hiAns = simd128<(1)>::gt(arg1, arg2);
     668        bitblock128_t loAns = simd128<(1)>::ugt(arg1, arg2);
     669        bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     670        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     671        return simd_or(simd128<2>::srai<(1)>(hiAns), mask);
    677672}
    678673
     
    786781}
    787782
    788 //The total number of operations is 40
     783//The total number of operations is 1
    789784template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ult(bitblock128_t arg1, bitblock128_t arg2)
    790785{
    791         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())));
    792 }
    793 
    794 //The total number of operations is 17
     786        return simd_andc(arg2, arg1);
     787}
     788
     789//The total number of operations is 14
    795790template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ult(bitblock128_t arg1, bitblock128_t arg2)
    796791{
    797         bitblock128_t tmp = simd_not(arg1);
    798         bitblock128_t tmpAns = simd_or(simd_and(tmp, arg2), simd_and(simd128<128>::slli<1>(simd_and(tmp, arg2)), simd_or(tmp, arg2)));
    799         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     792        bitblock128_t tmpAns = simd128<(1)>::ult(arg1, arg2);
     793        bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     794        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     795        return simd_or(simd128<2>::srai<(1)>(tmpAns), mask);
    800796}
    801797
     
    843839}
    844840
    845 //The total number of operations is 42
     841//The total number of operations is 1
    846842template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::lt(bitblock128_t arg1, bitblock128_t arg2)
    847843{
    848         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    849         return simd128<1>::ult(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    850 }
    851 
    852 //The total number of operations is 18
     844        return simd_andc(arg1, arg2);
     845}
     846
     847//The total number of operations is 15
    853848template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::lt(bitblock128_t arg1, bitblock128_t arg2)
    854849{
    855         bitblock128_t tmp = simd_not(arg2);
    856         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)));
    857         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     850        bitblock128_t hiAns = simd128<(1)>::lt(arg1, arg2);
     851        bitblock128_t loAns = simd128<(1)>::ult(arg1, arg2);
     852        bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     853        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     854        return simd_or(simd128<2>::srai<(1)>(hiAns), mask);
    858855}
    859856
     
    1001998}
    1002999
    1003 //The total number of operations is 40
     1000//The total number of operations is 1
    10041001template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10051002{
    1006         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())));
    1007 }
    1008 
    1009 //The total number of operations is 17
     1003        return simd_andc(arg1, arg2);
     1004}
     1005
     1006//The total number of operations is 14
    10101007template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10111008{
    1012         bitblock128_t tmp = simd_not(arg2);
    1013         bitblock128_t tmpAns = simd_or(simd_and(arg1, tmp), simd_and(simd128<128>::slli<1>(simd_and(arg1, tmp)), simd_or(arg1, tmp)));
    1014         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     1009        bitblock128_t tmpAns = simd128<(1)>::ugt(arg1, arg2);
     1010        bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     1011        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     1012        return simd_or(simd128<2>::srai<(1)>(tmpAns), mask);
    10151013}
    10161014
     
    11491147}
    11501148
    1151 //The total number of operations is 1
    1152 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::neg(bitblock128_t arg1)
    1153 {
    1154         return simd128<1>::sub(simd128<1>::constant<0>(), arg1);
    1155 }
    1156 
    11571149//The total number of operations is 8
    11581150template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1)
     
    14831475}
    14841476
    1485 //The total number of operations is 39
     1477//The total number of operations is 1
    14861478template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::min(bitblock128_t arg1, bitblock128_t arg2)
    14871479{
    1488         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    1489         return simd_xor(simd128<1>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
    1490 }
    1491 
    1492 //The total number of operations is 19
     1480        return simd_or(arg1, arg2);
     1481}
     1482
     1483//The total number of operations is 18
    14931484template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::min(bitblock128_t arg1, bitblock128_t arg2)
    14941485{
    1495         bitblock128_t high_bit = simd128<2>::constant<(2)>();
    1496         return simd_xor(simd128<2>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
     1486        return simd128<1>::ifh(simd128<2>::lt(arg1, arg2), arg1, arg2);
    14971487}
    14981488
     
    15381528}
    15391529
    1540 //The total number of operations is 36
     1530//The total number of operations is 1
    15411531template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umin(bitblock128_t arg1, bitblock128_t arg2)
    15421532{
    1543         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)));
     1533        return simd_and(arg1, arg2);
    15441534}
    15451535
     
    15901580}
    15911581
    1592 //The total number of operations is 36
     1582//The total number of operations is 1
    15931583template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umax(bitblock128_t arg1, bitblock128_t arg2)
    15941584{
    1595         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)));
     1585        return simd_or(arg1, arg2);
    15961586}
    15971587
     
    16421632}
    16431633
    1644 //The total number of operations is 37
     1634//The total number of operations is 2
    16451635template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16461636{
    1647         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))));
    1648 }
    1649 
    1650 //The total number of operations is 15
     1637        return simd_not(simd_xor(arg1, arg2));
     1638}
     1639
     1640//The total number of operations is 8
    16511641template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16521642{
    1653         bitblock128_t tmp = simd_xor(arg1, arg2);
    1654         bitblock128_t tmpAns = simd_and(simd_not(simd128<128>::slli<1>(tmp)), simd_not(tmp));
    1655         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     1643        bitblock128_t tmpAns = simd128<(1)>::eq(arg1, arg2);
     1644        bitblock128_t loMask = simd_and(tmpAns, simd128<2>::srli<(1)>(tmpAns));
     1645        bitblock128_t hiMask = simd128<2>::slli<(1)>(loMask);
     1646        return simd_or(loMask, hiMask);
    16561647}
    16571648
     
    18351826}
    18361827
    1837 //The total number of operations is 46
    1838 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::abs(bitblock128_t arg1)
    1839 {
    1840         bitblock128_t gtMask = simd128<1>::gt(arg1, simd128<1>::constant<0>());
    1841         return simd128<1>::ifh(gtMask, arg1, simd128<1>::sub(gtMask, arg1));
    1842 }
    1843 
    18441828//The total number of operations is 9
    18451829template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::abs(bitblock128_t arg1)
     
    18871871}
    18881872
    1889 //The total number of operations is 128
     1873//The total number of operations is 93
    18901874template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::umin_hl(bitblock128_t arg1, bitblock128_t arg2)
    18911875{
     
    19711955}
    19721956
    1973 //The total number of operations is 132
     1957//The total number of operations is 120
    19741958template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packss(bitblock128_t arg1, bitblock128_t arg2)
    19751959{
     
    21452129}
    21462130
    2147 //The total number of operations is 131
     2131//The total number of operations is 93
    21482132template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::min_hl(bitblock128_t arg1, bitblock128_t arg2)
    21492133{
     
    21512135}
    21522136
    2153 //The total number of operations is 83
     2137//The total number of operations is 82
    21542138template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<4>::min_hl(bitblock128_t arg1, bitblock128_t arg2)
    21552139{
     
    21872171}
    21882172
    2189 //The total number of operations is 99
     2173//The total number of operations is 85
    21902174template <> IDISA_ALWAYS_INLINE bitblock128_t hsimd128<2>::packus(bitblock128_t arg1, bitblock128_t arg2)
    21912175{
Note: See TracChangeset for help on using the changeset viewer.