[llvm] [DA] Add tests for nsw doesn't hold on entier iteration (PR #162281)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 05:52:44 PST 2025


kasuga-fj wrote:

> If I understand correctly, [ L 1 , U 1 ] is a subset of [ 0 , BTC 1 ] . Are the new bounds derived from the conditions leading required to reach a BasicBlock, i.e. acyclic control-flow-sensitive?
> 
> If so, this seems to be `isMonotonicAt(BB)` with an additional step: `isMonotonicInDomain(getEffectiveDomain(BB))`.

That matches my intent. One thing I don’t quite understand, and which makes things more complex, is the existence of delinearization. For example, in the following case:

```c
int A[][10];
for (i = 0; i < INT64_MAX; i++)
  for (j = 0; j < 10; j++)
    A[i][j] = 0;
```

The original offset will be lowered to `%i*10 + %j`, which overflows. However, this would be delinearized to `%A[%i][%j]`, and in this case each subscript `%i` and `%j` is monotonic. I'm really not sure if it's sound that `isMonotonic(BB, i)` returns true. Conservatively, maybe we should also pass the original offset to `isMonotonicAt`?

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


More information about the llvm-commits mailing list