From 6fa904b9711ddb8358c6b81cd199138fc593b969 Mon Sep 17 00:00:00 2001 From: Martijn Courteaux Date: Thu, 20 Jun 2024 13:23:55 +0200 Subject: [PATCH] scoped_truth for the loop variable being always less than the loop extent. --- src/Simplify_Stmts.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); }