Changeset 4728


Ignore:
Timestamp:
Aug 16, 2015, 4:31:11 PM (4 years ago)
Author:
nmedfort
Message:

Few extra changes.

Location:
icGREP/icgrep-devel/icgrep/pablo/optimizers
Files:
3 edited

Legend:

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

    r4727 r4728  
    166166
    167167        BDDMinimizationPass::optimize(function, true);
    168 
    169 //        LOG_NUMBER_OF_ADVANCES(function.getEntryBlock());
    170 
    171 //        RECORD_TIMESTAMP(start_simplify_ast);
    172 //        am.simplifyAST(function);
    173 //        RECORD_TIMESTAMP(end_simplify_ast);
    174 //        LOG("SimplifyAST:             " << (end_simplify_ast - start_simplify_ast));
    175 
    176 //        RECORD_TIMESTAMP(start_topological_sort2);
    177 //        am.topologicalSort(function.getEntryBlock());
    178 //        RECORD_TIMESTAMP(end_topological_sort2);
    179 //        LOG("TopologicalSort (2):     " << (end_topological_sort2 - start_topological_sort2));
    180 
    181168    }
    182169
     
    442429            // would be ¬(ScanThru(c,m) √ m)
    443430        case PabloAST::ClassTypeId::MatchStar:
    444             if (LLVM_UNLIKELY(isZero(input[0]) || isZero(input[1]))) {
    445                 return Zero();
    446             }
    447431        case PabloAST::ClassTypeId::Call:
    448432            bdd = NewVar();
     
    456440            throw std::runtime_error("Unexpected statement type " + stmt->getName()->to_string());
    457441    }
    458 
    459442    Ref(bdd);
    460     if (LLVM_UNLIKELY(NoSatisfyingAssignment(bdd))) {
    461         Deref(bdd);
    462         // If there is no satisfing assignment for this bdd, the statement will always produce 0.
    463         // We can safely replace this statement with 0 unless it is an Advance, Assign or Next node.
    464         // Those must be handled specially or we may end up producing a non-equivalent function.
    465         if (LLVM_UNLIKELY(isa<Advance>(stmt) || isa<Assign>(stmt) || isa<Next>(stmt))) {
    466             stmt->setOperand(0, stmt->getParent()->createZeroes());
    467             bdd = Zero();
    468         }
    469         else {
    470             stmt->replaceWith(stmt->getParent()->createZeroes());
    471             return nullptr;
    472         }
    473     }
    474443    mRecentCharacterizations.emplace_back(stmt, bdd);
    475444    return bdd;
     
    990959        const size_t n = out_degree(s, mMultiplexSetGraph);
    991960        if (n) {
    992             const size_t m = log2_plus_one(n);
    993             std::vector<Statement *> muxed(m);
     961            const size_t m = log2_plus_one(n);           
    994962            Advance * input[n];
     963            Advance * muxed[m];
    995964
    996965            unsigned i = 0;
     
    1028997                // The only way this did not return an Advance statement would be if either the mux or shift amount
    1029998                // is zero. Since these cases would have been eliminated earlier, we are safe to cast here.               
    1030                 muxed[j] = cast<Statement>(builder.createAdvance(mux, adv->getOperand(1), prefix.str()));
     999                muxed[j] = cast<Advance>(builder.createAdvance(mux, adv->getOperand(1), prefix.str()));
    10311000            }
    10321001
     
    10701039                input[i - 1]->replaceWith(demuxed, true, true);
    10711040            }
    1072 
    1073             mSimplificationQueue.push(std::move(muxed));
    10741041        }       
    10751042    }
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_automultiplexing.hpp

    r4727 r4728  
    3636    using VertexVector = std::vector<ConstraintVertex>;
    3737    using RecentCharacterizations = std::vector<std::pair<const PabloAST *, DdNode *>>;
    38     using SimplificationQueue = std::queue<std::vector<Statement *>>;
    3938public:
    4039    static bool optimize(PabloFunction & function);
     
    8281    MultiplexSetGraph           mMultiplexSetGraph;
    8382    RecentCharacterizations     mRecentCharacterizations;
    84     SimplificationQueue         mSimplificationQueue;
    8583};
    8684
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_bddminimization.cpp

    r4727 r4728  
    174174            bdd = Ite(input[0], input[1], input[2]);
    175175            break;
     176        case PabloAST::ClassTypeId::MatchStar:
     177        case PabloAST::ClassTypeId::ScanThru:
     178            if (LLVM_UNLIKELY(isZero(input[1]))) {
     179                return Zero();
     180            }
     181        case PabloAST::ClassTypeId::Advance:
     182            if (LLVM_UNLIKELY(isZero(input[0]))) {
     183                return Zero();
     184            }
    176185        case PabloAST::ClassTypeId::Call:
    177186            // TODO: we may have more than one output. Need to fix call class to allow for it.
    178         case PabloAST::ClassTypeId::Advance:
    179         case PabloAST::ClassTypeId::MatchStar:
    180         case PabloAST::ClassTypeId::ScanThru:
    181187            return NewVar(stmt);
    182188        default:
Note: See TracChangeset for help on using the changeset viewer.