Skip to content

Commit

Permalink
Fix reduce_expr_modulo of vector in Solve.cpp (halide#8089)
Browse files Browse the repository at this point in the history
* Fix reduce_expr_modulo of vector in Solve.cpp

* Fix test
  • Loading branch information
abadams committed Feb 14, 2024
1 parent f2d750f commit b582561
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Solve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class SolveExpression : public IRMutator {
if (a_uses_var && !b_uses_var) {
const int64_t *ib = as_const_int(b);
auto is_multiple_of_b = [&](const Expr &e) {
if (ib) {
if (ib && op->type.is_scalar()) {
int64_t r = 0;
return reduce_expr_modulo(e, *ib, &r) && r == 0;
} else {
Expand Down Expand Up @@ -1478,6 +1478,9 @@ void solve_test() {
check_solve(min(x + y, x - z), x + min(y, 0 - z));
check_solve(max(x + y, x - z), x + max(y, 0 - z));

check_solve((5 * Broadcast::make(x, 4) + y) / 5,
Broadcast::make(x, 4) + (Broadcast::make(y, 4) / 5));

debug(0) << "Solve test passed\n";
}

Expand Down

0 comments on commit b582561

Please sign in to comment.