Ignore:
Timestamp:
Jan 15, 2018, 3:42:27 PM (18 months ago)
Author:
nmedfort
Message:

Bug fix for UntilN

File:
1 edited

Legend:

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

    r5831 r5832  
    499499            Value * EOFbit = b->getScalarField("EOFbit");
    500500            Value * EOFmask = b->getScalarField("EOFmask");
    501             Value * const to_count = b->simd_and(b->simd_or(b->simd_not(EOFmask), EOFbit), compileExpression(b, c->getExpr()));
    502             const unsigned counterSize = b->getSizeTy()->getBitWidth();
     501            Value * const to_count = b->simd_and(b->simd_or(b->simd_not(EOFmask), EOFbit), compileExpression(b, c->getExpr()));           
    503502            const auto f = mAccumulator.find(c);
    504503            if (LLVM_UNLIKELY(f == mAccumulator.end())) {
    505504                report_fatal_error("Unknown accumulator: " + c->getName().str());
    506505            }
    507             Value * ptr = b->getScalarFieldPtr(f->second);
     506            Value * const ptr = b->getScalarFieldPtr(f->second);
    508507            const auto alignment = getPointerElementAlignment(ptr);
    509             Value * countSoFar = b->CreateAlignedLoad(ptr, alignment, c->getName() + "_accumulator");
    510             auto fields = (b->getBitBlockWidth() / counterSize);
    511             Value * fieldCounts = b->simd_popcount(counterSize, to_count);
     508            Value * const countSoFar = b->CreateAlignedLoad(ptr, alignment, c->getName() + "_accumulator");
     509            const auto fieldWidth = b->getSizeTy()->getBitWidth();
     510            auto fields = (b->getBitBlockWidth() / fieldWidth);
     511            Value * fieldCounts = b->simd_popcount(fieldWidth, to_count);
    512512            while (fields > 1) {
    513                 fields = fields/2;
    514                 fieldCounts = b->CreateAdd(fieldCounts, b->mvmd_srli(counterSize, fieldCounts, fields));
    515             }
    516             value = b->CreateAdd(b->mvmd_extract(counterSize, fieldCounts, 0), countSoFar, "countSoFar");
     513                fields /= 2;
     514                fieldCounts = b->CreateAdd(fieldCounts, b->mvmd_srli(fieldWidth, fieldCounts, fields));
     515            }
     516            value = b->CreateAdd(b->mvmd_extract(fieldWidth, fieldCounts, 0), countSoFar, "countSoFar");
    517517            b->CreateAlignedStore(value, ptr, alignment);
    518518        } else if (const Lookahead * l = dyn_cast<Lookahead>(stmt)) {
Note: See TracChangeset for help on using the changeset viewer.