[llvm] [LoopInterchange] Prevent from undoing its own transformation (PR #127473)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 07:50:30 PST 2025
================
@@ -1184,11 +1218,27 @@ std::optional<bool> LoopInterchangeProfitability::isProfitableForVectorization(
return std::optional<bool>(!DepMatrix.empty());
}
-bool LoopInterchangeProfitability::isProfitable(
- const Loop *InnerLoop, const Loop *OuterLoop, unsigned InnerLoopId,
- unsigned OuterLoopId, CharMatrix &DepMatrix,
- const DenseMap<const Loop *, unsigned> &CostMap,
- std::unique_ptr<CacheCost> &CC) {
+// The bubble-sort fashion algorithm is adopted to sort the loop nest, so the
+// comparison function should ideally induce a strict weak ordering required by
+// some standard C++ libraries. In particular, isProfitable should hold the
+// following properties.
+//
+// Asymmetry: If isProfitable(a, b) is true then isProfitable(b, a) is false.
----------------
Meinersbur wrote:
How do you want to express the "transivity" part? That is, that after a series of swaps you get back to the original order, without directly undoing a previous swap?
There is no need to use math for this, unless you want to get into formal proofs.
https://github.com/llvm/llvm-project/pull/127473
More information about the llvm-commits
mailing list