Ignore:
Timestamp:
Oct 18, 2015, 1:59:31 PM (4 years ago)
Author:
cameron
Message:

Improved shifts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4838 r4845  
    406406}
    407407
     408#define DSSLI_FIELDWIDTH 64
     409
    408410Value * CarryManager::unitAdvanceCarryInCarryOut(int localIndex, Value * strm) {
    409411    unsigned posn = advance1Position(localIndex);
     
    421423        storeCarryPack(posn);
    422424    }
    423     Value* result_value;
    424    
    425     if (mBITBLOCK_WIDTH == 128) {
    426         Value * ahead64 = iBuilder->mvmd_dslli(64, carry_in, strm, 1);
    427         result_value = iBuilder->simd_or(iBuilder->simd_srli(64, ahead64, 63), iBuilder->simd_slli(64, strm, 1));
    428     }
    429     else {
    430         Value* advanceq_longint = mBuilder->CreateBitCast(carry_in, mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    431         Value* strm_longint = mBuilder->CreateBitCast(strm, mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    432         Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, 1), mBuilder->CreateLShr(advanceq_longint, mBITBLOCK_WIDTH - 1), "advance");
    433         result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
    434     }
    435     return result_value;
     425    Value * ahead = iBuilder->mvmd_dslli(DSSLI_FIELDWIDTH, strm, carry_in, iBuilder->getBitBlockWidth()/DSSLI_FIELDWIDTH -1);
     426    return iBuilder->simd_or(iBuilder->simd_srli(DSSLI_FIELDWIDTH, ahead, DSSLI_FIELDWIDTH-1), iBuilder->simd_slli(DSSLI_FIELDWIDTH, strm, 1));
    436427}
    437428
     
    451442    if (mCarryInfo->getWhileDepth() == 0) {
    452443        storeCarryPack(posn);
     444    }
     445    // Use a single whole-byte shift, if possible.
     446    if (shift_amount % 8 == 0) {
     447        return iBuilder->mvmd_dslli(8, strm, carry_in, iBuilder->getBitBlockWidth()/8 - shift_amount/8);
     448    }
     449    else if (shift_amount < DSSLI_FIELDWIDTH) {
     450        Value * ahead = iBuilder->mvmd_dslli(DSSLI_FIELDWIDTH, strm, carry_in, iBuilder->getBitBlockWidth()/DSSLI_FIELDWIDTH - 1);
     451        return iBuilder->simd_or(iBuilder->simd_srli(DSSLI_FIELDWIDTH, ahead, DSSLI_FIELDWIDTH-shift_amount), iBuilder->simd_slli(DSSLI_FIELDWIDTH, strm, shift_amount));
    453452    }
    454453    Value* advanceq_longint = mBuilder->CreateBitCast(carry_in, mBuilder->getIntNTy(mBITBLOCK_WIDTH));
Note: See TracChangeset for help on using the changeset viewer.