Changeset 4845


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

Improved shifts

Location:
icGREP/icgrep-devel/icgrep
Files:
3 edited

Legend:

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

    r4843 r4845  
    1212
    1313namespace IDISA {
    14 
    15 Value * IDISA_Builder::bitBlockCast(Value * a) {
    16     return a->getType() == mBitBlockType ? a : mLLVMBuilder->CreateBitCast(a, mBitBlockType);
    17 }
    1814
    1915VectorType * IDISA_Builder::fwVectorType(unsigned fw) {
     
    3733                                                   /*Initializer=*/ regNameData);
    3834    Value * regStrPtr = mLLVMBuilder->CreateGEP(regStrVar, std::vector<Value *>({mLLVMBuilder->getInt64(0), mLLVMBuilder->getInt32(0)}));
    39     mLLVMBuilder->CreateCall(mPrintRegisterFunction, std::vector<Value *>({regStrPtr, bitblockValue}));
     35    mLLVMBuilder->CreateCall(mPrintRegisterFunction, std::vector<Value *>({regStrPtr, bitCast(bitblockValue)}));
    4036}
    4137
     
    182178    Value * bVec = fwCast(fw, b);
    183179    std::vector<Constant*> Idxs;
    184     for (unsigned i = shift; i < field_count + shift; i++) {
    185         Idxs.push_back(mLLVMBuilder->getInt32(i));
    186     }
    187     return mLLVMBuilder->CreateShuffleVector(aVec, bVec, ConstantVector::get(Idxs));
     180    for (unsigned i = 0; i < field_count; i++) {
     181        Idxs.push_back(mLLVMBuilder->getInt32(i + shift));
     182    }
     183    return mLLVMBuilder->CreateShuffleVector(bVec, aVec, ConstantVector::get(Idxs));
    188184}
    189185
     
    194190
    195191Value * IDISA_Builder::simd_and(Value * a, Value * b) {
    196     return a->getType() == b->getType() ? mLLVMBuilder->CreateAnd(a, b) : mLLVMBuilder->CreateAnd(bitBlockCast(a), bitBlockCast(b));
     192    return a->getType() == b->getType() ? mLLVMBuilder->CreateAnd(a, b) : mLLVMBuilder->CreateAnd(bitCast(a), bitCast(b));
    197193}
    198194
    199195Value * IDISA_Builder::simd_or(Value * a, Value * b) {
    200     return a->getType() == b->getType() ? mLLVMBuilder->CreateOr(a, b) : mLLVMBuilder->CreateOr(bitBlockCast(a), bitBlockCast(b));
     196    return a->getType() == b->getType() ? mLLVMBuilder->CreateOr(a, b) : mLLVMBuilder->CreateOr(bitCast(a), bitCast(b));
    201197}
    202198   
    203199Value * IDISA_Builder::simd_xor(Value * a, Value * b) {
    204     return a->getType() == b->getType() ? mLLVMBuilder->CreateXor(a, b) : mLLVMBuilder->CreateXor(bitBlockCast(a), bitBlockCast(b));
     200    return a->getType() == b->getType() ? mLLVMBuilder->CreateXor(a, b) : mLLVMBuilder->CreateXor(bitCast(a), bitCast(b));
    205201}
    206202
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r4843 r4845  
    9191    Constant * mPrintRegisterFunction;
    9292   
    93     Value * bitBlockCast(Value * a);
    9493    VectorType * fwVectorType(unsigned fw);
    9594    Value * fwCast(unsigned fw, Value * a);
  • 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.