diff --git a/src/Simplify_Stmts.cpp b/src/Simplify_Stmts.cpp index 3645ebbf4369..3b004211a953 100644 --- a/src/Simplify_Stmts.cpp +++ b/src/Simplify_Stmts.cpp @@ -240,7 +240,12 @@ Stmt Simplify::visit(const For *op) { loop_var_info); // If we're in the loop, the extent must be greater than 0. - ScopedFact fact = scoped_truth(extent_positive); + ScopedFact fact_extent_positive = scoped_truth(extent_positive); + + // The loop variable will never exceed the loop bound. + Expr loop_var = Variable::make(Int(32), op->name); + ScopedFact loop_var_less_than_extent = scoped_truth(loop_var < new_extent); + new_body = mutate(op->body); }