[llvm] 128e2e4 - [SandboxVec][VecUtils][NFC] Move functions to VecUtils.cpp and add a VecUtils::dump()
Vasileios Porpodas via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 17 11:56:28 PST 2025
Author: Vasileios Porpodas
Date: 2025-01-17T11:56:07-08:00
New Revision: 128e2e446e90c3b1827cfc7d4d19e3c0976beff3
URL: https://github.com/llvm/llvm-project/commit/128e2e446e90c3b1827cfc7d4d19e3c0976beff3
DIFF: https://github.com/llvm/llvm-project/commit/128e2e446e90c3b1827cfc7d4d19e3c0976beff3.diff
LOG: [SandboxVec][VecUtils][NFC] Move functions to VecUtils.cpp and add a VecUtils::dump()
Added:
llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
Modified:
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h
llvm/lib/Transforms/Vectorize/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h
index 28fa33656dd5f4..6cbbb396ea823f 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h
@@ -134,15 +134,13 @@ class VecUtils {
return ScalarTy;
}
/// \Returns the first integer power of 2 that is <= Num.
- static unsigned getFloorPowerOf2(unsigned Num) {
- if (Num == 0)
- return Num;
- unsigned Mask = Num;
- Mask >>= 1;
- for (unsigned ShiftBy = 1; ShiftBy < sizeof(Num) * 8; ShiftBy <<= 1)
- Mask |= Mask >> ShiftBy;
- return Num & ~Mask;
- }
+ static unsigned getFloorPowerOf2(unsigned Num);
+
+#ifndef NDEBUG
+ /// Helper dump function for debugging.
+ LLVM_DUMP_METHOD static void dump(ArrayRef<Value *> Bndl);
+ LLVM_DUMP_METHOD static void dump(ArrayRef<Instruction *> Bndl);
+#endif // NDEBUG
};
} // namespace llvm::sandboxir
diff --git a/llvm/lib/Transforms/Vectorize/CMakeLists.txt b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
index 6a025652f92f8e..e5fabd318b82cc 100644
--- a/llvm/lib/Transforms/Vectorize/CMakeLists.txt
+++ b/llvm/lib/Transforms/Vectorize/CMakeLists.txt
@@ -13,6 +13,7 @@ add_llvm_component_library(LLVMVectorize
SandboxVectorizer/SandboxVectorizerPassBuilder.cpp
SandboxVectorizer/Scheduler.cpp
SandboxVectorizer/SeedCollector.cpp
+ SandboxVectorizer/VecUtils.cpp
SLPVectorizer.cpp
Vectorize.cpp
VectorCombine.cpp
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
new file mode 100644
index 00000000000000..6f9ef07e467d23
--- /dev/null
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/VecUtils.cpp
@@ -0,0 +1,32 @@
+//===- VecUtils.cpp -------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h"
+
+namespace llvm::sandboxir {
+
+unsigned VecUtils::getFloorPowerOf2(unsigned Num) {
+ if (Num == 0)
+ return Num;
+ unsigned Mask = Num;
+ Mask >>= 1;
+ for (unsigned ShiftBy = 1; ShiftBy < sizeof(Num) * 8; ShiftBy <<= 1)
+ Mask |= Mask >> ShiftBy;
+ return Num & ~Mask;
+}
+
+#ifndef NDEBUG
+template <typename T> static void dumpImpl(ArrayRef<T *> Bndl) {
+ for (auto [Idx, V] : enumerate(Bndl))
+ dbgs() << Idx << "." << *V << "\n";
+}
+void VecUtils::dump(ArrayRef<Value *> Bndl) { dumpImpl(Bndl); }
+void VecUtils::dump(ArrayRef<Instruction *> Bndl) { dumpImpl(Bndl); }
+#endif // NDEBUG
+
+} // namespace llvm::sandboxir
More information about the llvm-commits
mailing list