Ignore:
Timestamp:
Nov 10, 2015, 2:13:54 PM (4 years ago)
Author:
nmedfort
Message:

Bug fix for Linda.

File:
1 edited

Legend:

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

    r4860 r4866  
    216216}
    217217
     218
    218219/** ------------------------------------------------------------------------------------------------------------- *
    219220 * @brief eliminateRedundantCode
     221 *
     222 * Note: Do not recursively erase statements in this function. The ExpressionTable could use deleted statements
     223 * as replacements. Let the DCE remove the unnecessary statements with the final Use-Def information.
    220224 ** ------------------------------------------------------------------------------------------------------------- */
    221225void Simplifier::eliminateRedundantCode(PabloBlock & block, ExpressionTable * predecessor) {
    222226    ExpressionTable encountered(predecessor);
    223227    Statement * stmt = block.front();
     228
    224229    while (stmt) {
     230
    225231        if (Assign * assign = dyn_cast<Assign>(stmt)) {
    226232            // If we have an Assign whose users do not contain an If or Next node, we can replace its users with
    227233            // the Assign's expression directly.
    228234            if (isSuperfluous(assign)) {
    229                 if (assign->getNumUses() == 0) {
    230                     stmt = assign->eraseFromParent(true);
    231                 } else {
    232                     stmt = assign->replaceWith(assign->getExpression(), true, true);
    233                 }
     235                stmt = assign->replaceWith(assign->getExpression(), true);
    234236                continue;
    235237            }
     
    241243            // Check to see if the Cond is Zero and delete the loop.
    242244            if (LLVM_UNLIKELY(isa<Zeroes>(ifNode->getCondition()))) {
    243                 stmt = stmt->eraseFromParent(true);
     245                stmt = stmt->eraseFromParent();
    244246                continue;
    245247            }
     
    256258                    if (LLVM_UNLIKELY(demoteDefinedVar(ifNode, def))) {
    257259                        itr = defs.erase(itr);
    258                         def->replaceWith(def->getExpression(), false, true);
     260                        def->replaceWith(def->getExpression());
    259261                        evaluate = true;
    260262                        continue;
     
    266268            // If we ended up removing all of the defined variables, delete the If node.
    267269            if (LLVM_UNLIKELY(defs.empty())) {
    268                 stmt = stmt->eraseFromParent(true);
     270                stmt = stmt->eraseFromParent();
    269271                continue;
    270272            }
     
    287289                    nested = next;
    288290                }
    289                 stmt = ifNode->eraseFromParent(true);
     291                stmt = ifNode->eraseFromParent();
    290292                continue;
    291293            }
     
    297299            }
    298300            if (LLVM_UNLIKELY(isa<Zeroes>(initial))) {
    299                 stmt = stmt->eraseFromParent(true);
     301                stmt = stmt->eraseFromParent();
    300302                continue;
    301303            }
     
    303305            removeIdenticalEscapedValues(whileNode->getVariants());
    304306        } else if (PabloAST * expr = canTriviallyFold(stmt, block)) {
    305             stmt = stmt->replaceWith(expr, true, true);
     307            stmt = stmt->replaceWith(expr, true);
    306308            continue;
    307309        } else {
     
    312314            const auto f = encountered.findOrAdd(stmt);
    313315            if (!f.second) {
    314                 stmt = stmt->replaceWith(f.first, true, true);
     316                stmt = stmt->replaceWith(f.first, true);
    315317                continue;
    316318            }
Note: See TracChangeset for help on using the changeset viewer.