[llvm] [SandboxVec][Scheduler] Boilerplate and initial implementation. (PR #112449)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 16:34:48 PDT 2024
================
@@ -0,0 +1,160 @@
+//===- Scheduler.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/Scheduler.h"
+
+namespace llvm::sandboxir {
+
+DGNode *SchedBundle::getTop() const {
+ DGNode *TopN = Nodes.front();
+ for (auto *N : drop_begin(Nodes)) {
+ if (N->getInstruction()->comesBefore(TopN->getInstruction()))
+ TopN = N;
+ }
+ return TopN;
+}
+
+DGNode *SchedBundle::getBot() const {
+ DGNode *BotN = Nodes.front();
+ for (auto *N : drop_begin(Nodes)) {
+ if (BotN->getInstruction()->comesBefore(N->getInstruction()))
+ BotN = N;
+ }
+ return BotN;
+}
----------------
vporpo wrote:
Yes, these are quite expensive, so caching Top/Bottom, or even a priority queue might be an option. The only issue is that if the instructions move to some other location, then we would have to recalculate top/bottom. I think the safest option is to use this version for now, but I will add a TODO to explore whether we could cache top/bottom.
https://github.com/llvm/llvm-project/pull/112449
More information about the llvm-commits
mailing list