Ignore:
Timestamp:
Mar 24, 2017, 4:01:22 PM (2 years ago)
Author:
nmedfort
Message:

Bug fix for long advance

File:
1 edited

Legend:

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

    r5368 r5371  
    397397}
    398398
    399 Value * CBuilder::CreateCeilLog2(Value * value) {
     399Value * CBuilder::CreateCeilLog2(Value * const value) {
    400400    IntegerType * ty = cast<IntegerType>(value->getType());
    401401    CreateAssert(value, "CreateCeilLog2: value cannot be zero");
    402     Value * m = CreateCall(Intrinsic::getDeclaration(mMod, Intrinsic::ctlz, ty), {value, ConstantInt::getFalse(getContext())});
    403     Value * isPowOf2 = CreateICmpEQ(CreateAnd(value, CreateSub(value, ConstantInt::get(ty, 1))), ConstantInt::getNullValue(ty));
    404     m = CreateSub(ConstantInt::get(m->getType(), ty->getBitWidth() - 1), m);
    405     return CreateSelect(isPowOf2, m, CreateAdd(m, ConstantInt::get(m->getType(), 1)));
     402    Value * v = CreateSub(value, ConstantInt::get(ty, 1));
     403    Value * m = CreateCall(Intrinsic::getDeclaration(mMod, Intrinsic::ctlz, ty), {v, ConstantInt::getFalse(getContext())});
     404    return CreateSub(ConstantInt::get(m->getType(), ty->getBitWidth()), m);
    406405}
    407406
Note: See TracChangeset for help on using the changeset viewer.