Ignore:
Timestamp:
Oct 28, 2017, 5:03:07 PM (18 months ago)
Author:
cameron
Message:

Arbitrary long indexed advance progress

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_avx_builder.cpp

    r5713 r5715  
    199199        return std::pair<Value *, Value *>{bitCast(carryOut), bitCast(result)};
    200200    }
    201     else {
     201    else if (shiftAmount <= mBitBlockWidth) {
    202202        // The shift amount is always greater than the popcount of the individual
    203203        // elements that we deal with.   This simplifies some of the logic.
    204        Value * carry = CreateBitCast(shiftIn, iBitBlock);
    205        Value * result = allZeroes();
     204        Value * carry = CreateBitCast(shiftIn, iBitBlock);
     205        Value * result = allZeroes();
    206206        for (unsigned i = 0; i < getBitBlockWidth()/bitWidth; i++) {
    207207            Value * s = mvmd_extract(bitWidth, strm, i);
     
    215215        return std::pair<Value *, Value *>{bitCast(carry), bitCast(result)};
    216216    }
    217 }
    218 
    219 }
     217    else {
     218        // The shift amount is greater than the total popcount.   We will consume popcount
     219        // bits from the shiftIn value only, and produce a carry out value of the selected bits.
     220        // elements that we deal with.   This simplifies some of the logic.
     221        Value * carry = CreateBitCast(shiftIn, iBitBlock);
     222        Value * result = allZeroes();
     223        Value * carryOut = CreateBitCast(allZeroes(), iBitBlock);
     224        Value * generated = getSize(0);
     225        for (unsigned i = 0; i < getBitBlockWidth()/bitWidth; i++) {
     226            Value * s = mvmd_extract(bitWidth, strm, i);
     227            Value * ix = mvmd_extract(bitWidth, index_strm, i);
     228            Value * ix_popcnt = CreateCall(popcount_f, {ix});
     229            Value * bits = CreateCall(PEXT_f, {s, ix});  // All these bits are shifted out (appended to carry).
     230            result = mvmd_insert(bitWidth, result, CreateCall(PDEP_f, {mvmd_extract(bitWidth, carry, 0), ix}), i);
     231            carry = CreateLShr(carry, CreateZExt(ix_popcnt, iBitBlock)); // Remove the carry bits consumed, make room for new bits.
     232            carryOut = CreateOr(carryOut, CreateShl(CreateZExt(bits, iBitBlock), generated));
     233            generated = CreateAdd(generated, ix_popcnt);
     234        }
     235        return std::pair<Value *, Value *>{bitCast(carryOut), bitCast(result)};
     236    }
     237}
     238
     239}
Note: See TracChangeset for help on using the changeset viewer.