Ignore:
Timestamp:
Jan 29, 2016, 3:38:47 PM (4 years ago)
Author:
nmedfort
Message:

Incorporated a few common case boolean optimizations in the Simplifier.

File:
1 edited

Legend:

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

    r4909 r4922  
    1212#include <pablo/carry_manager.h>
    1313#include <pablo/pabloAST.h>
     14#ifdef CARRY_DEBUG
    1415#include <iostream>
     16#endif
    1517#include <llvm/Support/CommandLine.h>
    1618#include <llvm/IR/BasicBlock.h>
     
    2729namespace pablo {
    2830 
    29     unsigned doScopeCount(PabloBlock * pb) {
    30         unsigned count = 1;
    31        
    32         for (Statement * stmt : *pb) {
    33             if (If * ifStatement = dyn_cast<If>(stmt)) {
    34                 count += doScopeCount(ifStatement->getBody());
    35             }
    36             else if (While * whileStatement = dyn_cast<While>(stmt)) {
    37                 count += doScopeCount(whileStatement->getBody());
    38             }
    39         }
    40         return count;
    41        
    42     }
     31unsigned doScopeCount(PabloBlock * pb) {
     32    unsigned count = 1;
     33
     34    for (Statement * stmt : *pb) {
     35        if (If * ifStatement = dyn_cast<If>(stmt)) {
     36            count += doScopeCount(ifStatement->getBody());
     37        }
     38        else if (While * whileStatement = dyn_cast<While>(stmt)) {
     39            count += doScopeCount(whileStatement->getBody());
     40        }
     41    }
     42    return count;
     43
     44}
    4345   
    4446void CarryManager::generateCarryDataInitializer(Module * m) {
     
    7981    unsigned totalPackCount = (totalCarryDataSize + mITEMS_PER_PACK - 1)/mITEMS_PER_PACK;
    8082
    81     mCarryPackPtr.resize(totalPackCount);
    82     mCarryInPack.resize(totalPackCount);
    83     mCarryOutPack.resize(totalPackCount);
    84     for (unsigned i = 0; i < totalPackCount; i++) mCarryInPack[i]=nullptr;
     83    mCarryPackPtr.resize(totalPackCount, nullptr);
     84    mCarryInPack.resize(totalPackCount, nullptr);
     85    mCarryOutPack.resize(totalPackCount, nullptr);
    8586
    8687    if (Strategy == SequentialFullyPackedStrategy) {
     
    133134
    134135unsigned CarryManager::enumerate(PabloBlock * blk, unsigned ifDepth, unsigned whileDepth) {
     136#ifdef CARRY_DEBUG
    135137    llvm::raw_os_ostream cerr(std::cerr);
     138#endif
    136139    unsigned idx = blk->getScopeIndex();
    137140    PabloBlockCarryData * cd = new PabloBlockCarryData(blk, mPACK_SIZE, mITEMS_PER_PACK);
     
    635638    const unsigned carrySummaryIndex = summaryPackIndex();
    636639   
    637     Value * carry_summary = Constant::getNullValue(mCarryPackType);
     640    Value * carry_summary = nullptr;
    638641    if (mCarryInfo->blockHasLongAdvances()) { // Force if entry
    639642        carry_summary = Constant::getAllOnesValue(mCarryPackType);
    640643    }
    641644    else {
     645        carry_summary = Constant::getNullValue(mCarryPackType);
    642646        unsigned localCarryIndex = localBasePack();
    643647        unsigned localCarryPacks = mCarryInfo->getLocalCarryPackCount();
     
    645649            carry_summary = mCarryOutPack[localCarryIndex];
    646650            for (unsigned i = 1; i < localCarryPacks; i++) {
    647                 carry_summary = iBuilder->CreateOr(carry_summary, mCarryOutPack[localCarryIndex+i]);
     651                carry_summary = iBuilder->CreateOr(carry_summary, mCarryOutPack[localCarryIndex + i]);
    648652            }
    649653        }
     654
     655
     656        // iBuilder->SetInsertPoint(&(iBuilder->GetInsertBlock()->back()));
     657
    650658        for (Statement * stmt : *mCurrentScope) {
    651659            if (If * innerIf = dyn_cast<If>(stmt)) {
    652660                PabloBlock * inner_blk = innerIf->getBody();
    653661                enterScope(inner_blk);
    654                 if (blockHasCarries()) {
    655                   carry_summary = iBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
     662                if (blockHasCarries()) {                   
     663                    carry_summary = iBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
    656664                }
    657665                leaveScope();
Note: See TracChangeset for help on using the changeset viewer.