Ignore:
Timestamp:
Mar 7, 2016, 3:37:30 PM (3 years ago)
Author:
nmedfort
Message:

Initial modifications to Pablo Compiler and Kernel Builder to support circular buffers for Lookahead.

File:
1 edited

Legend:

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

    r4937 r4959  
    525525
    526526/** ------------------------------------------------------------------------------------------------------------- *
     527 * @brief unused
     528 ** ------------------------------------------------------------------------------------------------------------- */
     529inline static bool unused(const Statement * const stmt) {
     530    if (LLVM_UNLIKELY(stmt->getNumUses() == 0)) {
     531        // TODO: prototypes ought to state whether they have side effects.
     532        if (LLVM_UNLIKELY(isa<Call>(stmt) && cast<Call>(stmt)->getPrototype()->getNumOfResults() == 0)) {
     533            return false;
     534        }
     535        return true;
     536    }
     537    return false;
     538}
     539
     540/** ------------------------------------------------------------------------------------------------------------- *
    527541 * @brief deadCodeElimination
    528542 ** ------------------------------------------------------------------------------------------------------------- */
     
    530544    Statement * stmt = block->front();
    531545    while (stmt) {
    532         if (isa<If>(stmt)) {
     546        if (LLVM_UNLIKELY(isa<If>(stmt))) {
    533547            deadCodeElimination(cast<If>(stmt)->getBody());
    534         } else if (isa<While>(stmt)) {
     548        } else if (LLVM_UNLIKELY(isa<While>(stmt))) {
    535549            deadCodeElimination(cast<While>(stmt)->getBody());
    536         } else if (stmt->getNumUses() == 0){
     550        } else if (LLVM_UNLIKELY(unused(stmt))){
    537551            stmt = stmt->eraseFromParent(true);
    538552            continue;
     
    562576                if (LLVM_UNLIKELY(op->getNumUses() == 1)) {
    563577                    adv->setOperand(0, op->getOperand(0));
    564                     adv->setOperand(1, block->getInteger(adv->getAdvanceAmount() + op->getAdvanceAmount()));
     578                    adv->setOperand(1, block->getInteger(adv->getAmount() + op->getAmount()));
    565579                    op->eraseFromParent(false);
    566580                }
     
    573587                if (LLVM_UNLIKELY(op->getNumUses() == 1)) {
    574588                    block->setInsertPoint(scanThru->getPrevNode());
    575                     PabloAST * expr = block->createAdvance(op->getOperand(0), op->getAdvanceAmount() - 1);
     589                    PabloAST * expr = block->createAdvance(op->getOperand(0), op->getAmount() - 1);
    576590                    scanThru->setOperand(0, expr);
    577591                    scanThru->setOperand(1, block->createOr(scanThru->getOperand(1), expr));
Note: See TracChangeset for help on using the changeset viewer.