https://github.com/goldsteinn approved this pull request. LGTM, although this type of re-ordering is liable to creating inf loops and this might be the only case. If this continues to be an issue we should probably drop the fold. https://github.com/llvm/llvm-project/pull/113264