[flang-commits] [flang] [flang] Add nsw to DO loop parameters (PR #113854)
via flang-commits
flang-commits at lists.llvm.org
Tue Oct 29 05:30:16 PDT 2024
https://github.com/jeanPerier approved this pull request.
Looks good to me (please address Tom's questions).
I verified that at least gfortran/ifort are optimizing the following program assuming that "n+1" cannot wrap:
```
subroutine foo(x, n, m)
integer :: n, m
integer :: x(m)
do i=n,n+1
x(i) = i
end do
end subroutine
```
They both optimize this into two executions of the body without branches, which also what LLVM does after your patch. So there is a precedent in leveraging the language semantics here and this won't come as a surprise for existing application.
https://github.com/llvm/llvm-project/pull/113854
More information about the flang-commits
mailing list