[llvm] [DA] Rewrite Banerjee MIV test with SCEV-based interval arithmetic (PR #207662)

Ruoyu Qiu via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 03:57:22 PDT 2026


cabbaken wrote:

> The current approach seems completely reasonable to me. We can check the sizes of integers invovled and also calculate what integer size we need to avoid overflow and then we can perform the computation in the wider size. Developing a new mechanism like dynamic-size integer is unnecessary.
>
> For step (1) it makes more sense to stick to integers and postpone worrying about symbolic cases to future.

Thanks for your agreement.
I've implemented SCEV expressions version for symbolic support, and it seems to work well for now. It still follows the same fixed-width approach, every operand is extended to WideType before any Banerjee multiplication or accumulation.

>  That is, whenever we change the logic, we may also need to reconsider its value; otherwise, we may miss the possibility of overflow someday. I don't think such a program is robust enough.

Thanks, I understand the maintainability concern. I agree that __this proof is coupled to the arithmetic__ performed by the implementation.
Since the Banerjee computation here has a small and well-defined operation set, I think the explicit width invariant is a reasonable first implementation. We can make the dependency clearer by keeping all relevant arithmetic in dedicated helpers and documenting that any new arithmetic operation must preserve the width proof. Would that be acceptable for this patch?

> I feel this implementation is a bit flaky. I think it would be better to introduce a mechanism such as dynamic-sized integer (or SCEV). For example, the addition of x with type ty0 and y with type ty1 is an integer with type max(ty0, ty1) + 1.

Introducing dynamically widened arithmetic while retaining symbolic SCEV expressions would require an additional abstraction that extends operands separately for every operation. How about considering dynamically widened symbolic arithmetic separately?

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


More information about the llvm-commits mailing list