Ignore:
Timestamp:
Nov 12, 2015, 4:26:25 PM (4 years ago)
Author:
nmedfort
Message:

Work on bug fixes for multiplexing pass.

File:
1 edited

Legend:

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

    r4866 r4868  
    216216}
    217217
    218 
    219218/** ------------------------------------------------------------------------------------------------------------- *
    220219 * @brief eliminateRedundantCode
    221220 *
    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.
     221 * Note: Do not recursively delete statements in this function. The ExpressionTable could use deleted statements
     222 * as replacements. Let the DCE remove the unnecessary statements with the finalized Def-Use information.
    224223 ** ------------------------------------------------------------------------------------------------------------- */
    225224void Simplifier::eliminateRedundantCode(PabloBlock & block, ExpressionTable * predecessor) {
     
    233232            // the Assign's expression directly.
    234233            if (isSuperfluous(assign)) {
    235                 stmt = assign->replaceWith(assign->getExpression(), true);
     234                stmt = assign->replaceWith(assign->getExpression());
    236235                continue;
    237236            }
     
    247246            }
    248247
    249             bool evaluate = true;
     248            // Test whether all of the defined variables are necessary
    250249            If::DefinedVars & defs = ifNode->getDefined();
    251             while (evaluate) {
    252                 evaluate = false;
    253                 // Process the If body
    254                 eliminateRedundantCode(cast<If>(stmt)->getBody(), &encountered);
    255                 // Now test whether all of the defined variables are necessary
    256                 for (auto itr = defs.begin(); itr != defs.end(); ) {
    257                     Assign * def = *itr;
    258                     if (LLVM_UNLIKELY(demoteDefinedVar(ifNode, def))) {
    259                         itr = defs.erase(itr);
    260                         def->replaceWith(def->getExpression());
    261                         evaluate = true;
    262                         continue;
    263                     }
    264                     ++itr;
    265                 }
    266             }
     250            for (auto def = defs.begin(); def != defs.end(); ) {
     251                if (LLVM_UNLIKELY(demoteDefinedVar(ifNode, *def))) {
     252                    (*def)->replaceWith((*def)->getExpression());
     253                    def = ifNode->removeDefined(*def);
     254                    continue;
     255                }
     256                ++def;
     257            }
     258
     259            // Process the If body
     260            eliminateRedundantCode(cast<If>(stmt)->getBody(), &encountered);
    267261
    268262            // If we ended up removing all of the defined variables, delete the If node.
Note: See TracChangeset for help on using the changeset viewer.