Changeset 4805


Ignore:
Timestamp:
Sep 28, 2015, 3:16:23 PM (2 years ago)
Author:
nmedfort
Message:

Minor addition to Simplifier pass to test for redundant escaped values.

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

Legend:

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

    r4804 r4805  
    105105                parent = parent->getParent();
    106106            }
     107        }
     108    }
     109}
     110
     111template <class ValueList>
     112inline void removeIdenticalEscapedValues(ValueList & list) {
     113    for (auto i = list.begin(); i != list.end(); ++i) {
     114        for (auto j = i + 1; j != list.end(); ) {
     115            if (LLVM_UNLIKELY(equals(*i, *j))) {
     116                (*j)->replaceWith(*i, false, true);
     117                j = list.erase(j);
     118                continue;
     119            }
     120            ++j;
    107121        }
    108122    }
     
    161175            // Otherwise check if we any Assign reports the same value as another. If so, replace all uses of the
    162176            // second with the first. This will simplify future analysis.
    163             for (auto i = defs.begin(); i != defs.end(); ++i) {
    164                 PabloAST * expr = (*i)->getExpression();
    165                 for (auto j = i + 1; j != defs.end(); ) {
    166                     Assign * def = (*j);
    167                     if (LLVM_UNLIKELY(def->getExpression() == expr)) {
    168                         j = defs.erase(j);
    169                         def->replaceWith(*i, false, true);
    170                         continue;
    171                     }
    172                     ++j;
    173                 }
    174             }
     177            removeIdenticalEscapedValues(ifNode->getDefined());
     178
    175179        } else if (While * whileNode = dyn_cast<While>(stmt)) {
    176180
     
    186190            eliminateRedundantCode(whileNode->getBody(), &encountered);
    187191
     192            removeIdenticalEscapedValues(whileNode->getVariants());
    188193
    189194        } else if (canTriviallyFold(stmt)) { // non-Assign node
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.cpp

    r4797 r4805  
    6969            // If these weren't equivalent by address they won't be equivalent by their operands.
    7070            return false;
    71         } else { // Non-reassociatable functions (i.e., Sel, Advance, ScanThru, MatchStar)
     71        } else { // Non-reassociatable functions (i.e., Sel, Advance, ScanThru, MatchStar, Assign, Next)
    7272            const Statement * stmt1 = cast<Statement>(expr1);
    7373            const Statement * stmt2 = cast<Statement>(expr2);
  • icGREP/icgrep-devel/icgrep/pablo/ps_while.h

    r4650 r4805  
    3232        return getOperand(0);
    3333    }
     34    inline NextVars & getVariants() {
     35        return mNext;
     36    }
    3437    inline const NextVars & getVariants() const {
    3538        return mNext;
Note: See TracChangeset for help on using the changeset viewer.