-
Notifications
You must be signed in to change notification settings - Fork 450
[Enhancement] Improve vectorization invariant check #1398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5a9d8b7
b456539
9407ae5
f782191
10bedbd
482a0ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,6 +290,24 @@ bool IndiceCanVectorize(const PrimExpr &expr, Var var, | |
| if (!analyzer->CanProveEqual(FloorMod(iter_var_size, target_size_for_iter), | ||
| 0)) | ||
| return false; | ||
|
|
||
| // Check if expr is invariant within vector boundaries | ||
| // We're trying to prove the access expression A[f(var)] depends only on | ||
| // floor(var/vecsize), not on var%vecsize | ||
| // Mathematically: | ||
| // \forall var, f(floor(var/vecsize)*vecsize + var%vecsize) == | ||
| // f(floor(var/vecsize)*vecsize + 0) | ||
| // Example: for i in T.vectorized(8): | ||
| // A[i] = B[i] * C[i//4] | ||
| // if vecsize=4, f(i)=i//4 depends only on i//4 | ||
| // Therefore A[i] = B[i] * C[i//4] can be vectorized with vecsize=4 | ||
| PrimExpr var_aligned = | ||
| floordiv(var, target_vectorized_size) * target_vectorized_size; | ||
| PrimExpr expr_aligned = Substitute(expr, {{var, var_aligned}}); | ||
| if (analyzer->CanProveEqual(expr, expr_aligned)) { | ||
| return true; | ||
| } | ||
|
Comment on lines
293
to
309
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix syntax error and function name casing. The map initialization is missing an opening brace, and Apply this diff to fix both issues: // Check if expr is invariant within vector boundaries
PrimExpr expr_aligned = Substitute(expr,
- {var, floordiv(var, target_vectorized_size) * target_vectorized_size}});
+ {{var, FloorDiv(var, target_vectorized_size) * target_vectorized_size}});
if (analyzer->CanProveEqual(expr, expr_aligned)) {
return true;
}Based on the static analysis hint reporting "Unmatched '('" at line 295. 🧰 Tools🪛 Cppcheck (2.18.0)[error] 295-295: Unmatched '('. Configuration (syntaxError) 🤖 Prompt for AI Agents |
||
|
|
||
| auto simplified_expr = analyzer->Simplify(Substitute(expr, {{var, zero}})); | ||
| // The base offset must be divisible | ||
| if (!analyzer->CanProveEqual(FloorMod(simplified_expr, target_size_for_expr), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.