ergawy wrote:
> 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.
Thanks for the comment. I had a detection for infinite loops but that wasn't
sufficient for such cases. Added detection support in
a23f20250b87fb48dcef33310a8257f00e39f33f
(https://github.com/llvm/llvm-project/pull/225757) and lowering testing in
245f71a9e62f62559208fa7c9a659de6df2a2217 (this PR).
https://github.com/llvm/llvm-project/pull/225758
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits