[Mlir-commits] [mlir] [mlir][arith] fix wrong floordivsi fold (#83079) (PR #83248)

Jakub Kuderski llvmlistbot at llvm.org
Sun Mar 3 10:07:36 PST 2024


kuhar wrote:

> @kuhar There are indeed many overflow states that need to be checked here, but I haven't come up with a good method yet. Can you give me a specific suggestion? Thank you.

Without knowing the exact details of the floordivsi algorithm, the way I'd think about it is that we only need to detect if the *final* overflow happened or not. And of course fold correctly when there is no overflow. If there are intermediate overflows, I'd think that they can fold into one of the two buckets: (a) those that indicate that the floordivsi overflows for these arguments, and (b) implementation bugs.

It might be helpful to extract this fold code to a unit test (say one of the APInt test files) and go from there. Pick a few inputs that are known to overflow and trace the values and intermediate overflows. Maybe write a separate check to decide if overflow happens for the given input instead of relying on some intermediate checks.

https://github.com/llvm/llvm-project/pull/83248


More information about the Mlir-commits mailing list