Ignore:
Timestamp:
Dec 6, 2017, 5:41:27 PM (20 months ago)
Author:
nmedfort
Message:

Bug fixes + more assertions to prevent similar errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/scanmatchgen.cpp

    r5755 r5757  
    4242    const unsigned fieldCount = iBuilder->getBitBlockWidth() / sizeTy->getBitWidth();
    4343    VectorType * const scanwordVectorType =  VectorType::get(sizeTy, fieldCount);
     44    Constant * const ZERO = ConstantInt::getNullValue(sizeTy);
    4445
    4546    Value * match_result = iBuilder->getInputStreamBlockPtr("matchResult", iBuilder->getInt32(0));
     
    101102        phiRecordNum->addIncoming(phiLineNum, scanWordIteration);
    102103        phiRecordStart->addIncoming(phiLineStart, scanWordIteration);
    103         Value * anyMatches = iBuilder->CreateICmpNE(phiMatchWord, ConstantInt::getNullValue(sizeTy));
     104        Value * anyMatches = iBuilder->CreateICmpNE(phiMatchWord, ZERO);
    104105        iBuilder->CreateCondBr(anyMatches, processMatchesEntry, processMatchesExit);
    105106
     
    109110            Value * prior_breaks = iBuilder->CreateAnd(iBuilder->CreateMaskToLowestBitExclusive(phiMatchWord), phiRecordBreaks);
    110111            // Within the loop we have a conditional block that is executed if there are any prior record breaks.
    111             Value * prior_breaks_cond = iBuilder->CreateICmpNE(prior_breaks, ConstantInt::getNullValue(sizeTy));
     112            Value * prior_breaks_cond = iBuilder->CreateICmpNE(prior_breaks, ZERO);
    112113            iBuilder->CreateCondBr(prior_breaks_cond, prior_breaks_block, loop_final_block);
    113114
     
    116117                iBuilder->SetInsertPoint(prior_breaks_block);
    117118                Value * matchedRecordNum = iBuilder->CreateAdd(iBuilder->CreatePopcount(prior_breaks), phiRecordNum);
    118                 Value * reverseDistance = iBuilder->CreateCountReverseZeroes(prior_breaks);
     119                Value * reverseDistance = iBuilder->CreateCountReverseZeroes(prior_breaks, true);
    119120                Value * width = ConstantInt::get(sizeTy, sizeTy->getBitWidth());
    120                 Value * priorRecordStart = iBuilder->CreateAdd(phiScanwordPos, iBuilder->CreateSub(width, reverseDistance));
     121                Value * priorRecordStart = iBuilder->CreateAdd(phiScanwordPos, iBuilder->CreateSub(width, reverseDistance));               
    121122                iBuilder->CreateBr(loop_final_block);
    122123
     
    130131            phiRecordNum->addIncoming(matchRecordNum, loop_final_block);
    131132
    132             PHINode * matchRecordStart = iBuilder->CreatePHI(sizeTy, 2, "matchRecordStart");
     133            PHINode * const matchRecordStart = iBuilder->CreatePHI(sizeTy, 2, "matchRecordStart");
    133134            matchRecordStart->addIncoming(phiRecordStart, processMatchesEntry);
    134135            matchRecordStart->addIncoming(priorRecordStart, prior_breaks_block);
    135136            phiRecordStart->addIncoming(matchRecordStart, loop_final_block);
    136             Value * matchRecordEnd = iBuilder->CreateAdd(phiScanwordPos, iBuilder->CreateCountForwardZeroes(phiMatchWord));
    137             Value * const inputStream = iBuilder->getRawInputPointer("InputStream", iBuilder->getInt32(0));
    138             Function * dispatcher = m->getFunction("accumulate_match_wrapper"); assert (dispatcher);
    139             Value * start_ptr = iBuilder->CreateGEP(inputStream, matchRecordStart);
    140             Value * end_ptr = iBuilder->CreateGEP(inputStream, matchRecordEnd);
    141             iBuilder->CreateCall(dispatcher, {accumulator, matchRecordNum, start_ptr, end_ptr});
     137            Value * const matchRecordEnd = iBuilder->CreateAdd(phiScanwordPos, iBuilder->CreateCountForwardZeroes(phiMatchWord, true));
     138            Function * const dispatcher = m->getFunction("accumulate_match_wrapper"); assert (dispatcher);
     139            Value * const startPtr = iBuilder->getRawInputPointer("InputStream", matchRecordStart);
     140            Value * const endPtr = iBuilder->getRawInputPointer("InputStream", matchRecordEnd);
     141            iBuilder->CreateCall(dispatcher, {accumulator, matchRecordNum, startPtr, endPtr});
    142142            Value * remaining_matches = iBuilder->CreateResetLowestBit(phiMatchWord);
    143143            phiMatchWord->addIncoming(remaining_matches, loop_final_block);
     
    151151        iBuilder->SetInsertPoint(processMatchesExit);
    152152        // When the matches are done, there may be additional record breaks remaining
    153         Value * more_breaks_cond = iBuilder->CreateICmpNE(phiRecordBreaks, ConstantInt::getNullValue(sizeTy));
     153        Value * more_breaks_cond = iBuilder->CreateICmpNE(phiRecordBreaks, ZERO);
    154154        iBuilder->CreateCondBr(more_breaks_cond, remaining_breaks_block, return_block);
    155155
Note: See TracChangeset for help on using the changeset viewer.