Ignore:
Timestamp:
Oct 26, 2017, 5:28:05 PM (2 years ago)
Author:
cameron
Message:

Enabling Unicode log2 bounded repetition uwing indexed advance (for n<64 and AVX2 only)

File:
1 edited

Legend:

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

    r5708 r5710  
    632632            llvm::report_fatal_error("indexed_advance unsupported bit width");
    633633        }
     634        Value * shiftVal = b->getSize(shiftAmount);
    634635        Value * carry = b->mvmd_extract(bitWidth, carryIn, 0);
    635636        Value * result = b->allZeroes();
     
    640641            Value * bits = b->CreateCall(PEXT_f, {s, ix});
    641642            Value * adv = b->CreateOr(b->CreateShl(bits, shiftAmount), carry);
    642             Value * overflow = b->CreateLShr(bits, bitWidth - shiftAmount);
     643            Value * popcount_small = b->CreateICmpULT(ix_popcnt, shiftVal);
     644            Value * carry_if_popcount_small =
     645                b->CreateOr(b->CreateShl(bits, b->CreateSub(shiftVal, ix_popcnt)),
     646                            b->CreateLShr(carry, ix_popcnt));
     647            Value * carry_if_popcount_large = b->CreateLShr(bits, b->CreateSub(ix_popcnt, shiftVal));
     648            carry = b->CreateSelect(popcount_small, carry_if_popcount_small, carry_if_popcount_large);
    643649            result = b->mvmd_insert(bitWidth, result, b->CreateCall(PDEP_f, {adv, ix}), i);
    644             carry = b->CreateOr(b->CreateLShr(adv, ix_popcnt), b->CreateShl(overflow, b->CreateSub(b->getSize(bitWidth), ix_popcnt)));
    645         }
    646         setNextCarryOut(b, carry);
     650        }
     651        Value * carryOut = b->mvmd_insert(bitWidth, b->allZeroes(), carry, 0);
     652        setNextCarryOut(b, carryOut);
    647653        return result;
    648654    } else {
Note: See TracChangeset for help on using the changeset viewer.