Skip to content

Commit

Permalink
fix the off-by-one error in the lowering of eval
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Oct 31, 2023
1 parent bc47670 commit 0df8dd9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Conversion/PolyToStandard/PolyToStandard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ struct ConvertEval : public OpConversionPattern<EvalOp> {
auto lowerBound =
b.create<arith::ConstantOp>(b.getIndexType(), b.getIndexAttr(1));
auto numTermsOp = b.create<arith::ConstantOp>(b.getIndexType(),
b.getIndexAttr(numTerms));
auto upperBound = b.create<arith::ConstantOp>(b.getIndexType(),
b.getIndexAttr(numTerms + 1));
auto step = lowerBound;

Expand All @@ -163,7 +165,7 @@ struct ConvertEval : public OpConversionPattern<EvalOp> {
auto accum =
b.create<arith::ConstantOp>(b.getI32Type(), b.getI32IntegerAttr(0));
auto loop = b.create<scf::ForOp>(
lowerBound, numTermsOp, step, accum.getResult(),
lowerBound, upperBound, step, accum.getResult(),
[&](OpBuilder &builder, Location loc, Value loopIndex,
ValueRange loopState) {
ImplicitLocOpBuilder b(op.getLoc(), builder);
Expand Down

0 comments on commit 0df8dd9

Please sign in to comment.