[llvm-branch-commits] [flang] [flang] Lower loops whose branching is confined to their body structurally (PR #225758)
Tom Eccles via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Sep 24 03:18:24 PDT 2026
https://github.com/tblah commented:
Codex found that DCE can remove side-effect free non-terminating loop bodies, leaving just the finite fir.do_loop.
```
subroutine self_loop(n)
integer :: n, i
do i = 1, n
10 goto 10
end do
call never_executed()
end subroutine
```
`flang -fc1 -emit-hlfir ...` produces
```
...
fir.do_loop ... {
fir.store ...
}
...
fir.call ...
return
```
I think the problem is the recursive memory effects on the scf.execute_region turning up nothing. If this instead used a fully unstructured lowering, the unstructured branches would all be terminators, which are never removed by DCE.
https://github.com/llvm/llvm-project/pull/225758
More information about the llvm-branch-commits
mailing list