Ignore:
Timestamp:
Sep 21, 2017, 3:10:34 PM (21 months ago)
Author:
nmedfort
Message:

Minor clean up. Bug fix for object cache when the same cached kernel is used twice in a single run. Improvement to RE Minimizer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_star_normal.cpp

    r5493 r5646  
    5656
    5757RE * RE_Star_Normal::helper(RE * re) {
    58 
    5958    if (Alt * alt = dyn_cast<Alt>(re)) {
    6059        std::vector<RE *> list;
     
    6564        re = makeAlt(list.begin(), list.end());
    6665    } else if (Seq * seq = dyn_cast<Seq>(re)) {
    67         RE * re_first = *(seq->begin());
    68         std::vector<RE *> list;
    69         list.reserve(seq->size());
    70         for (auto i = seq->begin() + 1; i != seq->end(); i++) {
    71             list.push_back(*i);
    72         }
    73         RE * re_follow = makeSeq(list.begin(), list.end());
    74         if (!isNullable(re_first) && !isNullable(re_follow)) {
     66        RE * const re_first = *(seq->begin());
     67        RE * const re_follow = makeSeq(seq->begin() + 1, seq->end());
     68        const auto isFirstNullable = isNullable(re_first);
     69        const auto isFollowNullable = isNullable(re_follow);
     70        if (LLVM_LIKELY(!isFirstNullable && !isFollowNullable)) {
    7571            re = makeSeq({star_normal(re_first), star_normal(re_follow)});
    76         } else if (!isNullable(re_first) && isNullable(re_follow)) {
     72        } else if (!isFirstNullable && isFollowNullable) {
    7773            re = makeSeq({helper(re_first), star_normal(re_follow)});
    78         } else if (isNullable(re_first) && !isNullable(re_follow)) {
     74        } else if (isFirstNullable && !isFollowNullable) {
    7975            re = makeSeq({star_normal(re_first), helper(re_follow)});
    8076        } else {
     
    8480        re = makeAssertion(helper(a->getAsserted()), a->getKind(), a->getSense());
    8581    } else if (Rep * rep = dyn_cast<Rep>(re)) {
     82        RE * const expr = helper(rep->getRE());
    8683        if (rep->getLB() == 0 && rep->getUB() == Rep::UNBOUNDED_REP) {
    87             re = helper(rep->getRE());
     84            re = expr;
    8885        } else {
    89             RE * expr = helper(rep->getRE());
    9086            re = makeRep(expr, rep->getLB(), rep->getUB());
    9187        }
Note: See TracChangeset for help on using the changeset viewer.