Ignore:
Timestamp:
Apr 28, 2018, 3:54:43 PM (12 months ago)
Author:
nmedfort
Message:

Added temporary buffer functionality to the pipeline for single stream source buffers. Fixed memory leak from UCD::UnicodeBreakRE()

File:
1 edited

Legend:

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

    r5988 r5998  
    167167}
    168168
    169 Value * CBuilder::CreateRoundUp(Value * const number, Value * const divisor, const Twine &Name) {
     169Value * CBuilder::CreateRoundUp(Value * const number, Value * const divisor, const Twine & Name) {
     170    if (isa<ConstantInt>(divisor)) {
     171        const auto d = cast<ConstantInt>(divisor)->getZExtValue();
     172        if (is_power_2(d)) {
     173            Constant * const ONE = ConstantInt::get(divisor->getType(), 1);
     174            Constant * const toAdd = ConstantExpr::getSub(cast<ConstantInt>(divisor), ONE);
     175            return CreateAnd(CreateAdd(number, toAdd), ConstantExpr::getNeg(cast<ConstantInt>(divisor)));
     176        }
     177    }
    170178    return CreateMul(CreateCeilUDiv(number, divisor), divisor, Name);
    171179}
Note: See TracChangeset for help on using the changeset viewer.