Changeset 4975


Ignore:
Timestamp:
Mar 16, 2016, 8:56:20 AM (3 years ago)
Author:
cameron
Message:

Improved packh/packl for i64

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_i64_builder.cpp

    r4958 r4975  
    4040*/
    4141
    42 Value * IDISA_I64_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {
     42/*Value * IDISA_I64_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {
    4343    Value * mask02 = getInt64(0xFF000000FF000000);
    4444    Value * mask13 = getInt64(0x0000FF000000FF00);
     
    5555    return simd_or(b2, a2);
    5656}
    57 
    58 Value * IDISA_I64_Builder::hsimd_packl(unsigned fw, Value * a, Value * b) {
    59     Value * mask02 = getInt64(0x00FF000000FF0000);
    60     Value * mask13 = getInt64(0x000000FF000000FF);
    61 
    62     Value * b1 = simd_or(simd_srli(64, simd_and(b, mask02), 8), simd_and(b, mask13));
    63     Value * a1 = simd_or(simd_srli(64, simd_and(a, mask02), 8), simd_and(a, mask13));
    64 
    65     Value * mask01 = getInt64(0x0000FFFF00000000);
    66     Value * mask23 = getInt64(0x000000000000FFFF);
    67 
    68     Value * b2 = simd_or(simd_slli(64, simd_and(b1, mask01), 16), simd_slli(64, simd_and(b1, mask23), 32));
    69     Value * a2 = simd_or(simd_srli(64, simd_and(a1, mask01), 16), simd_and(a1, mask23));
    70 
    71     return simd_or(b2, a2);
    72 }
     57*/
     58    Value * IDISA_I64_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {
     59        Value * a_ = a;
     60        Value * b_ = b;
     61        for (unsigned w = fw; w < mBitBlockWidth; w *= 2) {
     62            Value * himask_odd = simd_and(simd_himask(w), simd_himask(2*w));  // high half of odd fields
     63            Value * himask_even = simd_and(simd_himask(w), simd_lomask(2*w));  // high half of even fields
     64            b_ = simd_or(simd_and(b_, himask_odd), simd_slli(mBitBlockWidth, simd_and(b_, himask_even), w/2));
     65            a_ = simd_or(simd_and(a_, himask_odd), simd_slli(mBitBlockWidth, simd_and(a_, himask_even), w/2));
     66        }
     67        Value * pk = simd_or(b_, simd_srli(mBitBlockWidth, a_, mBitBlockWidth/2));
     68        return pk;
     69    }
     70   
     71   
     72    Value * IDISA_I64_Builder::hsimd_packl(unsigned fw, Value * a, Value * b) {
     73        Value * a_ = a;
     74        Value * b_ = b;
     75        for (unsigned w = fw; w < mBitBlockWidth; w *= 2) {
     76            Value * lomask_odd = simd_and(simd_lomask(w), simd_himask(2*w));  // high half of odd fields
     77            Value * lomask_even = simd_and(simd_lomask(w), simd_lomask(2*w));  // high half of even fields
     78            b_ = simd_or(simd_and(b_, lomask_even), simd_srli(mBitBlockWidth, simd_and(b_, lomask_odd), w/2));
     79            a_ = simd_or(simd_and(a_, lomask_even), simd_srli(mBitBlockWidth, simd_and(a_, lomask_odd), w/2));
     80        }
     81        Value * pk = simd_or(simd_slli(mBitBlockWidth, b_, mBitBlockWidth/2), a_);
     82        return pk;
     83    }
    7384
    7485}
Note: See TracChangeset for help on using the changeset viewer.