Skip to content
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

[bug] AffineApplyNormalizer assert Error #421

Open
sBobHuang opened this issue Jul 12, 2024 · 2 comments
Open

[bug] AffineApplyNormalizer assert Error #421

sBobHuang opened this issue Jul 12, 2024 · 2 comments

Comments

@sBobHuang
Copy link

When running my code using cgeist with the --raise-scf-to-affine option, I encountered the following error:

cgeist: ../lib/polygeist/Passes/AffineCFG.cpp:534: AffineApplyNormalizer::AffineApplyNormalizer(mlir::AffineMap, llvm::ArrayRefmlir::Value, mlir::PatternRewriter&, mlir::DominanceInfo&): Assertion `isValidSymbolInt(t, false)' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

Use the following minimal code example (saved as test.c) that reproduces the error,run the code using cgeist test.c --raise-scf-to-affine --function=* -S --memref-fullrank -o test.mlir

void nested_loop_using_variable_as_step(int vali[20][30]) {
  int stepx = vali[0][0];
  for (int x = 0; x < 20; x++) {
    for (int y = 1; y < 30; y += stepx) {
      vali[x][y] = 1;
    }
  }
}
@sBobHuang
Copy link
Author

Upon analyzing the process flow, the error appears to involve the operation "arith.divui," which is created at lib/polygeist/Passes/RaiseToAffine.cpp:114. This operation subsequently encounters a problem during evaluation at lib/polygeist/Passes/AffineCFG.cpp:319.

@sBobHuang
Copy link
Author

I think lib/polygeist/Passes/AffineCFG.cpp:215 fix involves a lambda function attempting to promote the current value to a top level to satisfy the condition “It is defined at the top level of 'region' or is its argument.” If promotion is not possible, the function returns nullptr. In this example, the condition for fix at lib/polygeist/Passes/AffineCFG.cpp:326 is not satisfied, but after applying fix, promotion is possible. Therefore, I modified the condition at line lib/polygeist/Passes/AffineCFG.cpp:335 to include DivUIOp, which resolved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant