[Mlir-commits] [llvm] [mlir] [MLIR][OpenMP] Add Taskloop Collapse Support (PR #175924)
Jack Styles
llvmlistbot at llvm.org
Thu Jan 15 03:45:58 PST 2026
================
@@ -2797,6 +2789,22 @@ convertOmpTaskloopOp(Operation &opInst, llvm::IRBuilderBase &builder,
return loopInfo;
};
+ llvm::Value *ubVal = builder.getInt32(1);
+ Operation::operand_range lowerBounds = loopOp.getLoopLowerBounds();
+ Operation::operand_range upperBounds = loopOp.getLoopUpperBounds();
+ if (loopOp.getCollapseNumLoops() > 1) {
+ for (uint64_t i = 0; i < loopOp.getCollapseNumLoops(); i++) {
+ ubVal = builder.CreateMul(
+ ubVal,
+ builder.CreateSub(
+ moduleTranslation.lookupValue(upperBounds[i]),
+ builder.CreateSub(moduleTranslation.lookupValue(lowerBounds[i]),
+ builder.getInt32(1))));
+ }
+ } else {
+ ubVal = moduleTranslation.lookupValue(upperBounds[0]);
----------------
Stylie777 wrote:
Ah apologies, think I misunderstood your question. The adjustment is to make sure the trip count is including the first iteration of the loop. Without the adjustment, the trip count ends up being 1 short and I was finding that the number of loop iterations was not right
https://github.com/llvm/llvm-project/pull/175924
More information about the Mlir-commits
mailing list