[llvm] [LV] Use ElementCount::isKnownLT to factor code (NFC) (PR #130596)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 10 10:56:30 PDT 2025


https://github.com/artagnon updated https://github.com/llvm/llvm-project/pull/130596

>From 6bea870202cd622fcf0018de68ec642f34ab757e Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 10 Mar 2025 12:14:22 +0000
Subject: [PATCH 1/2] [LV] Use ElementCount::isKnownLT to factor code (NFC)

---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index b987863127994..a061df0428169 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -144,16 +144,10 @@
 #include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
 #include "llvm/Transforms/Utils/SizeOpts.h"
 #include "llvm/Transforms/Vectorize/LoopVectorizationLegality.h"
-#include <algorithm>
 #include <cassert>
 #include <cstdint>
-#include <functional>
-#include <iterator>
 #include <limits>
-#include <memory>
 #include <string>
-#include <tuple>
-#include <utility>
 
 using namespace llvm;
 
@@ -4396,10 +4390,7 @@ void LoopVectorizationPlanner::emitInvalidCostRemarks(
   sort(InvalidCosts, [&Numbering](RecipeVFPair &A, RecipeVFPair &B) {
     if (Numbering[A.first] != Numbering[B.first])
       return Numbering[A.first] < Numbering[B.first];
-    const auto &LHS = A.second;
-    const auto &RHS = B.second;
-    return std::make_tuple(LHS.isScalable(), LHS.getKnownMinValue()) <
-           std::make_tuple(RHS.isScalable(), RHS.getKnownMinValue());
+    return ElementCount::isKnownLT(A.second, B.second);
   });
 
   // For a list of ordered recipe-VF pairs:

>From f04f978a590b0ae93418eb7bbda48a830b0ee39a Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 10 Mar 2025 17:55:51 +0000
Subject: [PATCH 2/2] [LV] Revert header cleanup

---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index a061df0428169..f5be9249aa82f 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -144,10 +144,16 @@
 #include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
 #include "llvm/Transforms/Utils/SizeOpts.h"
 #include "llvm/Transforms/Vectorize/LoopVectorizationLegality.h"
+#include <algorithm>
 #include <cassert>
 #include <cstdint>
+#include <functional>
+#include <iterator>
 #include <limits>
+#include <memory>
 #include <string>
+#include <tuple>
+#include <utility>
 
 using namespace llvm;
 



More information about the llvm-commits mailing list