Ignore:
Timestamp:
Mar 24, 2017, 4:01:22 PM (2 years ago)
Author:
nmedfort
Message:

Bug fix for long advance

File:
1 edited

Legend:

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

    r5357 r5371  
    433433    int total = repeat_count * length;
    434434    PabloAST * consecutive_i = repeated;
    435     while (i * 2 < total) {
     435    while ((i * 2) < total) {
    436436        PabloAST * v = consecutive_i;
    437437        PabloAST * v2 =  pb.createAdvance(v, i);
     
    439439        consecutive_i = pb.createAnd(v, v2, "at" + std::to_string(i) + "of" + std::to_string(total));
    440440    }
    441     if (i < total) {
     441    if (LLVM_LIKELY(i < total)) {
    442442        PabloAST * v = consecutive_i;
    443443        consecutive_i = pb.createAnd(v, pb.createAdvance(v, total - i), "at" + std::to_string(total));
     
    453453    }
    454454    PabloAST * reachable_i = pb.createOr(repeated, pb.createAdvance(repeated, 1), "within1");
    455     while (i * 2 < total_lgth) {
     455    while ((i * 2) < total_lgth) {
    456456        PabloAST * v = reachable_i;
    457457        PabloAST * v2 =  pb.createAdvance(v, i);
     
    459459        reachable_i = pb.createOr(v, v2, "within" + std::to_string(i));
    460460    }
    461     if (i < total_lgth) {
     461    if (LLVM_LIKELY(i < total_lgth)) {
    462462        PabloAST * v = reachable_i;
    463463        reachable_i = pb.createOr(v, pb.createAdvance(v, total_lgth - i), "within" + std::to_string(total_lgth));
     
    467467
    468468MarkerType RE_Compiler::processLowerBound(RE * repeated, int lb, MarkerType marker, PabloBuilder & pb) {
    469     if (lb == 0) return marker;
    470     if (!mGraphemeBoundaryRule && isByteLength(repeated) && !AlgorithmOptionIsSet(DisableLog2BoundedRepetition)) {
     469    if (lb == 0) {
     470        return marker;
     471    } else if (!mGraphemeBoundaryRule && isByteLength(repeated) && !AlgorithmOptionIsSet(DisableLog2BoundedRepetition)) {
    471472        PabloAST * cc = markerVar(compile(repeated, pb));
    472473        PabloAST * cc_lb = consecutive_matches(cc, 1, lb, pb);
     
    479480        marker = AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb);
    480481    }
    481     if (lb == 1) return marker;
     482    if (lb == 1) {
     483        return marker;
     484    }
    482485    Var * m = pb.createVar("m", pb.createZeroes());
    483486    PabloBuilder nested = PabloBuilder::Create(pb);
     
    489492   
    490493MarkerType RE_Compiler::processBoundedRep(RE * repeated, int ub, MarkerType marker, PabloBuilder & pb) {
    491     if (ub == 0) return marker;
    492     if (!mGraphemeBoundaryRule && isByteLength(repeated) && ub > 1 && !AlgorithmOptionIsSet(DisableLog2BoundedRepetition)) {
     494    if (ub == 0) {
     495        return marker;
     496    } else if (!mGraphemeBoundaryRule && isByteLength(repeated) && ub > 1 && !AlgorithmOptionIsSet(DisableLog2BoundedRepetition)) {
    493497        // log2 upper bound for fixed length (=1) class
    494498        // Create a mask of positions reachable within ub from current marker.
     
    508512        marker = AdvanceMarker(marker, MarkerPosition::FinalPostPositionUnit, pb);
    509513    }
    510     if (ub == 1) return marker;
     514    if (ub == 1) {
     515        return marker;
     516    }
    511517    Var * m1a = pb.createVar("m", pb.createZeroes());
    512518    PabloBuilder nested = PabloBuilder::Create(pb);
Note: See TracChangeset for help on using the changeset viewer.