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_1.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
     
    591588}
    592589
    593 //The total number of operations is 57
     590//The total number of operations is 1
    594591template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::mult(bitblock128_t arg1, bitblock128_t arg2)
    595592{
    596         bitblock128_t loMask = simd128<(2)>::lomask();
    597         bitblock128_t tmpAns1 = simd128<(2)>::mult(simd_and(loMask, arg1), simd_and(loMask, arg2));
    598         bitblock128_t tmpAns2 = simd128<(2)>::mult(simd128<(2)>::srli<1>(arg1), simd128<(2)>::srli<1>(arg2));
    599         return simd128<1>::ifh(loMask, tmpAns1, simd128<(2)>::slli<1>(tmpAns2));
     593        return simd_and(arg1, arg2);
    600594}
    601595
     
    666660}
    667661
    668 //The total number of operations is 42
     662//The total number of operations is 1
    669663template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::gt(bitblock128_t arg1, bitblock128_t arg2)
    670664{
    671         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    672         return simd128<1>::ugt(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    673 }
    674 
    675 //The total number of operations is 18
     665        return simd_andc(arg2, arg1);
     666}
     667
     668//The total number of operations is 15
    676669template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::gt(bitblock128_t arg1, bitblock128_t arg2)
    677670{
    678         bitblock128_t tmp = simd_not(arg1);
    679         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)));
    680         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     671        bitblock128_t hiAns = simd128<(1)>::gt(arg1, arg2);
     672        bitblock128_t loAns = simd128<(1)>::ugt(arg1, arg2);
     673        bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     674        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     675        return simd_or(simd128<2>::srai<(1)>(hiAns), mask);
    681676}
    682677
     
    794789}
    795790
    796 //The total number of operations is 40
     791//The total number of operations is 1
    797792template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ult(bitblock128_t arg1, bitblock128_t arg2)
    798793{
    799         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())));
    800 }
    801 
    802 //The total number of operations is 17
     794        return simd_andc(arg2, arg1);
     795}
     796
     797//The total number of operations is 14
    803798template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ult(bitblock128_t arg1, bitblock128_t arg2)
    804799{
    805         bitblock128_t tmp = simd_not(arg1);
    806         bitblock128_t tmpAns = simd_or(simd_and(tmp, arg2), simd_and(simd128<128>::slli<1>(simd_and(tmp, arg2)), simd_or(tmp, arg2)));
    807         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     800        bitblock128_t tmpAns = simd128<(1)>::ult(arg1, arg2);
     801        bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     802        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     803        return simd_or(simd128<2>::srai<(1)>(tmpAns), mask);
    808804}
    809805
     
    850846}
    851847
    852 //The total number of operations is 42
     848//The total number of operations is 1
    853849template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::lt(bitblock128_t arg1, bitblock128_t arg2)
    854850{
    855         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    856         return simd128<1>::ult(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit));
    857 }
    858 
    859 //The total number of operations is 18
     851        return simd_andc(arg1, arg2);
     852}
     853
     854//The total number of operations is 15
    860855template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::lt(bitblock128_t arg1, bitblock128_t arg2)
    861856{
    862         bitblock128_t tmp = simd_not(arg2);
    863         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)));
    864         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     857        bitblock128_t hiAns = simd128<(1)>::lt(arg1, arg2);
     858        bitblock128_t loAns = simd128<(1)>::ult(arg1, arg2);
     859        bitblock128_t mask = simd_and(loAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     860        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     861        return simd_or(simd128<2>::srai<(1)>(hiAns), mask);
    865862}
    866863
     
    10091006}
    10101007
    1011 //The total number of operations is 40
     1008//The total number of operations is 1
    10121009template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10131010{
    1014         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())));
    1015 }
    1016 
    1017 //The total number of operations is 17
     1011        return simd_andc(arg1, arg2);
     1012}
     1013
     1014//The total number of operations is 14
    10181015template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::ugt(bitblock128_t arg1, bitblock128_t arg2)
    10191016{
    1020         bitblock128_t tmp = simd_not(arg2);
    1021         bitblock128_t tmpAns = simd_or(simd_and(arg1, tmp), simd_and(simd128<128>::slli<1>(simd_and(arg1, tmp)), simd_or(arg1, tmp)));
    1022         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     1017        bitblock128_t tmpAns = simd128<(1)>::ugt(arg1, arg2);
     1018        bitblock128_t mask = simd_and(tmpAns, simd128<2>::srli<(1)>(simd128<(1)>::eq(arg1, arg2)));
     1019        mask = simd_or(mask, simd128<2>::slli<(1)>(mask));
     1020        return simd_or(simd128<2>::srai<(1)>(tmpAns), mask);
    10231021}
    10241022
     
    11591157}
    11601158
    1161 //The total number of operations is 1
    1162 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::neg(bitblock128_t arg1)
    1163 {
    1164         return simd128<1>::sub(simd128<1>::constant<0>(), arg1);
    1165 }
    1166 
    11671159//The total number of operations is 8
    11681160template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::neg(bitblock128_t arg1)
     
    14931485}
    14941486
    1495 //The total number of operations is 39
     1487//The total number of operations is 1
    14961488template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::min(bitblock128_t arg1, bitblock128_t arg2)
    14971489{
    1498         bitblock128_t high_bit = simd128<1>::constant<(1)>();
    1499         return simd_xor(simd128<1>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
    1500 }
    1501 
    1502 //The total number of operations is 19
     1490        return simd_or(arg1, arg2);
     1491}
     1492
     1493//The total number of operations is 18
    15031494template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::min(bitblock128_t arg1, bitblock128_t arg2)
    15041495{
    1505         bitblock128_t high_bit = simd128<2>::constant<(2)>();
    1506         return simd_xor(simd128<2>::umin(simd_xor(arg1, high_bit), simd_xor(arg2, high_bit)), high_bit);
     1496        return simd128<1>::ifh(simd128<2>::lt(arg1, arg2), arg1, arg2);
    15071497}
    15081498
     
    15521542}
    15531543
    1554 //The total number of operations is 36
     1544//The total number of operations is 1
    15551545template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umin(bitblock128_t arg1, bitblock128_t arg2)
    15561546{
    1557         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)));
     1547        return simd_and(arg1, arg2);
    15581548}
    15591549
     
    16061596}
    16071597
    1608 //The total number of operations is 36
     1598//The total number of operations is 1
    16091599template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::umax(bitblock128_t arg1, bitblock128_t arg2)
    16101600{
    1611         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)));
     1601        return simd_or(arg1, arg2);
    16121602}
    16131603
     
    16601650}
    16611651
    1662 //The total number of operations is 37
     1652//The total number of operations is 2
    16631653template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16641654{
    1665         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))));
    1666 }
    1667 
    1668 //The total number of operations is 15
     1655        return simd_not(simd_xor(arg1, arg2));
     1656}
     1657
     1658//The total number of operations is 8
    16691659template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<2>::eq(bitblock128_t arg1, bitblock128_t arg2)
    16701660{
    1671         bitblock128_t tmp = simd_xor(arg1, arg2);
    1672         bitblock128_t tmpAns = simd_and(simd_not(simd128<128>::slli<1>(tmp)), simd_not(tmp));
    1673         return simd128<1>::ifh(simd128<2>::himask(), tmpAns, simd128<128>::srli<1>(tmpAns));
     1661        bitblock128_t tmpAns = simd128<(1)>::eq(arg1, arg2);
     1662        bitblock128_t loMask = simd_and(tmpAns, simd128<2>::srli<(1)>(tmpAns));
     1663        bitblock128_t hiMask = simd128<2>::slli<(1)>(loMask);
     1664        return simd_or(loMask, hiMask);
    16741665}
    16751666
     
    18531844}
    18541845
    1855 //The total number of operations is 46
    1856 template <> IDISA_ALWAYS_INLINE bitblock128_t simd128<1>::abs(bitblock128_t arg1)
    1857 {
    1858         bitblock128_t gtMask = simd128<1>::gt(arg1, simd128<1>::constant<0>());
    1859         return simd128<1>::ifh(gtMask, arg1, simd128<1>::sub(gtMask, arg1));
    1860 }
    1861 
    18621846//The total number of operations is 9
    18631847template <> 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.