[llvm] [LoopFlatten] Add option to version loops instead of widening IVs (PR #166156)

Sjoerd Meijer via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 4 02:17:16 PST 2025


sjoerdmeijer wrote:

The idea for versioning makes sense. When we looked at this and thought about how to ensure correctness, there we two options: widening the IV, and versioning. We chose the widening approach, as it was the easiest and enough for our use-cases. If I recall this correctly, it has one big disadvantage: we widen first, and the final decision to flatten or not is made later. This can result in widening of the IV, while the transformation may not succeed, which isn't great. This approach may avoid that. There's one thing that surprises me though: I don't think I have seen, or I can't remember this AND instruction. I will look into things and this patch, but thought about asking this question here before I do that. 

https://github.com/llvm/llvm-project/pull/166156


More information about the llvm-commits mailing list