jholewinski added a comment. The algorithm looks good. Thanks for working on this! Though I'm wondering if this shouldn't be moved to the CodeGen library. Other targets may be able to benefit from this, like AMDGPU. Repository: rL LLVM http://reviews.llvm.org/D11220