https://github.com/lenary approved this pull request. LGTM. We did something a bit different on AArch64 for this kind of thing, which looked neater but doesn't translate over very well. This will do. https://github.com/llvm/llvm-project/pull/223894