Ignore:
Timestamp:
Dec 15, 2017, 12:44:01 PM (21 months ago)
Author:
nmedfort
Message:

Initial check-in of LookAhead? support; modified LineBreakKernel? to compute CR+LF using LookAhead?(1) + misc. fixes.

File:
1 edited

Legend:

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

    r5706 r5782  
    483483                }
    484484            }
    485         } else if (LLVM_UNLIKELY(isa<ScanThru>(stmt))) {
    486             ScanThru * scanThru = cast<ScanThru>(stmt);
    487             if (LLVM_UNLIKELY(isa<Advance>(scanThru->getScanFrom()))) {
    488                 // Replace a ScanThru(Advance(x,n),y) with an ScanThru(Advance(x, n - 1), Advance(x, n - 1) | y), where Advance(x, 0) = x
    489                 Advance * adv = cast<Advance>(scanThru->getScanFrom());
    490                 if (LLVM_UNLIKELY(adv->getNumUses() == 1)) {
    491                     PabloAST * stream = adv->getExpression();
     485        } else if (LLVM_UNLIKELY(isa<ScanThru>(stmt))) {           
     486            ScanThru * const outer = cast<ScanThru>(stmt);
     487            if (LLVM_UNLIKELY(isa<Advance>(outer->getScanFrom()))) {
     488                // Replace ScanThru(Advance(x,n),y) with ScanThru(Advance(x, n - 1), Advance(x, n - 1) | y), where Advance(x, 0) = x               
     489                Advance * const inner = cast<Advance>(outer->getScanFrom());
     490                if (LLVM_UNLIKELY(inner->getNumUses() == 1)) {
     491                    PabloAST * stream = inner->getExpression();
    492492                    block->setInsertPoint(stmt);
    493                     if (LLVM_UNLIKELY(adv->getAmount() != 1)) {
    494                         stream = block->createAdvance(stream, block->getInteger(adv->getAmount() - 1));
    495                     }
    496                     stmt = scanThru->replaceWith(block->createAdvanceThenScanThru(stream, scanThru->getScanThru()));
    497                     adv->eraseFromParent(false);
     493                    if (LLVM_UNLIKELY(inner->getAmount() != 1)) {
     494                        stream = block->createAdvance(stream, block->getInteger(inner->getAmount() - 1));
     495                    }
     496                    stmt = outer->replaceWith(block->createAdvanceThenScanThru(stream, outer->getScanThru()));
     497                    inner->eraseFromParent(false);
    498498                    continue;
    499499                }
    500             } else if (LLVM_UNLIKELY(isa<And>(scanThru->getScanFrom()))) {
     500            } else if (LLVM_UNLIKELY(isa<ScanThru>(outer->getScanFrom()))) {
     501                // Replace ScanThru(ScanThru(x, y), z) with ScanThru(x, y | z)
     502                ScanThru * const inner = cast<ScanThru>(outer->getScanFrom());
     503                block->setInsertPoint(stmt);
     504                ScanThru * const scanThru = block->createScanThru(inner->getScanFrom(), block->createOr(inner->getScanThru(), outer->getScanThru()));
     505                stmt->replaceWith(scanThru);
     506                stmt = scanThru;
     507                continue;
     508            } else if (LLVM_UNLIKELY(isa<And>(outer->getScanFrom()))) {
    501509                // Suppose B is an arbitrary bitstream and A = Advance(B, 1). ScanThru(B ∧ ¬A, B) will leave a marker on the position
    502510                // following the end of any run of 1-bits in B. But this is equivalent to computing A ∧ ¬B since A will have exactly
Note: See TracChangeset for help on using the changeset viewer.