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

Ehsan Amiri via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 12:51:04 PST 2025


amehsan wrote:

> DA doesn't have an equivalent of execution domains, it has to assume Src/Dst may be executed for any `i`. I don't think we need to bail out only because of the simple presence of conditionals/loop guards, it just means we cannot prove monotonicity in this case which may then cause to not be analyzable

@Meinersbur  consider a loop like this

```
for (i = 0; i < n; i++) {

    if (i <  3000) {

              for (j = .....) {
              }
              // some code with no control flow
              for (k = .....) {
              }
    }
}

```

I may have optimizations that infer nsw flags for `k` loop by looking at the ` if (i <  3000) ` condition. If you think monotonicity cannot be proven in the presennce of loop guards, then monotonicity cannot be proven in this case either. Should we check for existence of a conditino like this and then bail out and say we cannot prove monotonicity if we encounter a condition like this?


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


More information about the llvm-commits mailing list