[Mlir-commits] [mlir] [MLIR][SCF] fix loop pipelining pass use of uninitialized value (PR #146991)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jul 3 19:43:59 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-scf
@llvm/pr-subscribers-mlir
Author: Hu Yufan (Hyffer)
<details>
<summary>Changes</summary>
fix issue https://github.com/llvm/llvm-project/issues/146990
---
Full diff: https://github.com/llvm/llvm-project/pull/146991.diff
1 Files Affected:
- (modified) mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp (+14-13)
``````````diff
diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
index 4aacbe739ca5d..018ac729de8f9 100644
--- a/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp
@@ -106,6 +106,20 @@ bool LoopPipelinerInternal::initializeLoopInfo(
lb = forOp.getLowerBound();
step = forOp.getStep();
+ std::vector<std::pair<Operation *, unsigned>> schedule;
+ options.getScheduleFn(forOp, schedule);
+ if (schedule.empty()) {
+ LDBG("--empty schedule -> BAIL");
+ return false;
+ }
+
+ opOrder.reserve(schedule.size());
+ for (auto &opSchedule : schedule) {
+ maxStage = std::max(maxStage, opSchedule.second);
+ stages[opSchedule.first] = opSchedule.second;
+ opOrder.push_back(opSchedule.first);
+ }
+
dynamicLoop = true;
auto upperBoundCst = getConstantIntValue(ub);
auto lowerBoundCst = getConstantIntValue(lb);
@@ -137,19 +151,6 @@ bool LoopPipelinerInternal::initializeLoopInfo(
LDBG("--no epilogue or predicate set -> BAIL");
return false;
}
- std::vector<std::pair<Operation *, unsigned>> schedule;
- options.getScheduleFn(forOp, schedule);
- if (schedule.empty()) {
- LDBG("--empty schedule -> BAIL");
- return false;
- }
-
- opOrder.reserve(schedule.size());
- for (auto &opSchedule : schedule) {
- maxStage = std::max(maxStage, opSchedule.second);
- stages[opSchedule.first] = opSchedule.second;
- opOrder.push_back(opSchedule.first);
- }
// All operations need to have a stage.
for (Operation &op : forOp.getBody()->without_terminator()) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/146991
More information about the Mlir-commits
mailing list