[llvm] [LoopInterchange] Ignore the cost-model, force interchange if legal (PR #148858)
Sjoerd Meijer via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 15 11:49:31 PDT 2025
sjoerdmeijer wrote:
> What do you think about adding something like `force` [here](https://github.com/llvm/llvm-project/blob/c2e41be50f2cc3d1e99c30b1996b8873b05c4b0e/llvm/lib/Transforms/Scalar/LoopInterchange.cpp#L96-L109) instead? I personally think it could be useful in some cases, e.g., we can specify `-loop-interchange-profitabilities=cache,force`. The behavior is slightly different from `-loop-interchange-profitabilities=cache`. The former will interchange the loops if it is _not unprofitable_ for the cache, while the latter will perform the interchange if it is profitable for the cache. The result will differ in cases where it is unclear whether interchanging is profitable or unprofitable for the cache.
Yeah, I don't mind adding it there, that makes sense. I am a little bit undecided, but I am thinking that the combination `cache,force` is not a very intuitive option to read, it is not very clear what that means. My question is if we can come up with something that is clearer.
But I see what you would like to achieve, so let me summarise the kind of 3 states that we could have:
- I would like an option to ignore the cost-model entirely, i.e. to force interchange.
- Your suggestion is to prefer interchange if the cost-model is undecided. That makes sense.
- and what we already have, to have it entirely driven by the cost-model (what we currently have, nothing changes for this case).
The first one could be achieved by `-loop-interchange-profitabilities=force`, so I will add that one first, to help my test coverage.
I might do this in a follow up with another patch to address the issue when the cost-model is undecided. I am not totally in love with this, but I think I will add options:
- `-loop-interchange-profitabilities=cache-force`
- `-loop-interchange-profitabilities=vectorize-force`
- `-loop-interchange-profitabilities=instorder-force`
to prefer interchange when the profitability is not clear. I think a separate option `cache-force` is a bit clearer than a comma separate list and giving a special meaning to the previous option.
https://github.com/llvm/llvm-project/pull/148858
More information about the llvm-commits
mailing list