[Mlir-commits] [flang] [mlir] [mlir][flang][OpenMP] Select iterators per locator and allow multi-block regions (PR #227454)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 8 18:51:14 PDT 2026
================
@@ -256,23 +256,23 @@ static IteratorRange lowerIteratorRange(
mlir::Value ubVal =
fir::getBase(converter.genExprValue(toEvExpr(ubExpr), stmtCtx));
- auto toIndex = [](fir::FirOpBuilder &builder, mlir::Location loc,
- mlir::Value v) -> mlir::Value {
- if (v.getType().isIndex())
- return v;
- return fir::ConvertOp::create(builder, loc, builder.getIndexType(), v);
- };
-
- r.lb = toIndex(builder, loc, lbVal);
- r.ub = toIndex(builder, loc, ubVal);
-
- if (stExpr) {
- mlir::Value stVal =
- fir::getBase(converter.genExprValue(toEvExpr(*stExpr), stmtCtx));
- r.step = toIndex(builder, loc, stVal);
- } else {
- r.step = mlir::arith::ConstantIndexOp::create(builder, loc, 1);
- }
+ // Begin and end take the iterator's type, but the step keeps its own. Count
+ // in the wider of the two so that neither is narrowed.
+ mlir::Type ivTy = converter.genType(*r.ivSym);
+ mlir::Value stVal =
+ stExpr ? fir::getBase(converter.genExprValue(toEvExpr(*stExpr), stmtCtx))
+ : builder.createIntegerConstant(loc, ivTy, 1);
+ mlir::Type rangeTy = ivTy;
+ if (auto stTy = mlir::dyn_cast<mlir::IntegerType>(stVal.getType()))
+ if (stTy.isSignless() &&
+ stTy.getWidth() > mlir::cast<mlir::IntegerType>(ivTy).getWidth())
+ rangeTy = stTy;
+
+ r.lb = builder.createConvert(loc, rangeTy,
+ builder.createConvert(loc, ivTy, lbVal));
+ r.ub = builder.createConvert(loc, rangeTy,
+ builder.createConvert(loc, ivTy, ubVal));
----------------
MattPD wrote:
Confirmed: The reported range now produces zero entries for `n=256`.
https://github.com/llvm/llvm-project/pull/227454
More information about the Mlir-commits
mailing list