-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[mlir] Inconsistent results for arith.ceildivsi #115293
Labels
Comments
On further investigation, the issue is that From where I'm standing:
I suspect that, since it looks like this is defined behavior, I need to go add some cases to integer range analysis |
krzysz00
added a commit
to krzysz00/llvm-project
that referenced
this issue
Nov 14, 2024
Fixes llvm#115293 While the definition of ceildivsi is integer division, rounding up, most implementations will use `-(-a / b)` for dividing `a ceildiv b` with `a` negative and `b` positive. Mathematically, and for most integers, these two definitions are equivalent. However, with `a == INT_MIN`, the initial negation is a noop, which means that, while divinding and rounding up would give a negative result, `-((- INT_MIN) / b)` is `-(INT_MIN / b)`, which is positive. This commit adds a special case to ceilDivSI inference to handle this case and bring it in line with the operational instead of the mathematical semantics of ceiling division.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the following MLIR program:
test.mlir:
When I ran
/data/tmp/v1107/llvm-project/build/bin/mlir-opt --int-range-optimizations --arith-expand --convert-arith-to-llvm --convert-vector-to-llvm --convert-func-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1107/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1107/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1107/llvm-project/build/lib/libmlir_c_runner_utils.so
on the program, I got the result of:However, when I ran
/data/tmp/v1107/llvm-project/build/bin/mlir-opt --arith-expand --convert-arith-to-llvm --convert-vector-to-llvm --convert-func-to-llvm --reconcile-unrealized-casts test.mlir | /data/tmp/v1107/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1107/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1107/llvm-project/build/lib/libmlir_c_runner_utils.so
on the program, I got the result of:The above two results seem to be inconsistent. I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused these results.
My git version is 1469d82.
The text was updated successfully, but these errors were encountered: