[llvm-branch-commits] [flang] [mlir] [Flang][MLIR] Add `!$omp unroll` and `omp.unroll_heuristic` (PR #144785)
Michael Kruse via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 8 03:38:58 PDT 2025
================
@@ -3012,6 +3013,366 @@ void LoopNestOp::gatherWrappers(
}
}
+//===----------------------------------------------------------------------===//
+// OpenMP canonical loop handling
+//===----------------------------------------------------------------------===//
+
+std::tuple<NewCliOp, OpOperand *, OpOperand *>
+mlir::omp ::decodeCli(Value cli) {
+
+ // Defining a CLI for a generated loop is optional; if there is none then
+ // there is no followup-tranformation
+ if (!cli)
+ return {{}, nullptr, nullptr};
+
+ MLIRContext *ctx = cli.getContext();
+ assert(cli.getType() == CanonicalLoopInfoType::get(ctx) &&
+ "Unexpected type of cli");
+
+ NewCliOp create = cast<NewCliOp>(cli.getDefiningOp());
+ OpOperand *gen = nullptr;
+ OpOperand *cons = nullptr;
+ for (OpOperand &use : cli.getUses()) {
+ auto op = cast<LoopTransformationInterface>(use.getOwner());
+ auto applyees = op.getApplyeesODSOperandIndexAndLength();
+ auto generatees = op.getGenerateesODSOperandIndexAndLength();
+
+ unsigned opnum = use.getOperandNumber();
+ if (generatees.first <= opnum &&
+ opnum < generatees.first + generatees.second) {
+ assert(!gen && "Each CLI may have at most one consumer");
+ gen = &use;
+ } else if (applyees.first <= opnum &&
+ opnum < applyees.first + applyees.second) {
+ assert(!cons && "Each CLI may have at most one def");
+ cons = &use;
+ } else {
----------------
Meinersbur wrote:
done
https://github.com/llvm/llvm-project/pull/144785
More information about the llvm-branch-commits
mailing list