@@ -122,40 +122,25 @@ static void createCleanupRegion(Fortran::lower::AbstractConverter &converter,
122
122
typeError ();
123
123
}
124
124
125
- fir::ShapeShiftOp
126
- Fortran::lower::omp::getShapeShift (fir::FirOpBuilder &builder,
127
- mlir::Location loc, mlir::Value box,
128
- bool cannotHaveNonDefaultLowerBounds) {
125
+ fir::ShapeShiftOp Fortran::lower::omp::getShapeShift (fir::FirOpBuilder &builder,
126
+ mlir::Location loc,
127
+ mlir::Value box) {
129
128
fir::SequenceType sequenceType = mlir::cast<fir::SequenceType>(
130
129
hlfir::getFortranElementOrSequenceType (box.getType ()));
131
130
const unsigned rank = sequenceType.getDimension ();
132
-
133
131
llvm::SmallVector<mlir::Value> lbAndExtents;
134
132
lbAndExtents.reserve (rank * 2 );
135
- mlir::Type idxTy = builder.getIndexType ();
136
133
137
- if (cannotHaveNonDefaultLowerBounds && !sequenceType.hasDynamicExtents ()) {
138
- // We don't need fir::BoxDimsOp if all of the extents are statically known
139
- // and we can assume default lower bounds. This helps avoids reads from the
140
- // mold arg.
141
- mlir::Value one = builder.createIntegerConstant (loc, idxTy, 1 );
142
- for (int64_t extent : sequenceType.getShape ()) {
143
- assert (extent != sequenceType.getUnknownExtent ());
144
- mlir::Value extentVal = builder.createIntegerConstant (loc, idxTy, extent);
145
- lbAndExtents.push_back (one);
146
- lbAndExtents.push_back (extentVal);
147
- }
148
- } else {
149
- for (unsigned i = 0 ; i < rank; ++i) {
150
- // TODO: ideally we want to hoist box reads out of the critical section.
151
- // We could do this by having box dimensions in block arguments like
152
- // OpenACC does
153
- mlir::Value dim = builder.createIntegerConstant (loc, idxTy, i);
154
- auto dimInfo =
155
- builder.create <fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
156
- lbAndExtents.push_back (dimInfo.getLowerBound ());
157
- lbAndExtents.push_back (dimInfo.getExtent ());
158
- }
134
+ mlir::Type idxTy = builder.getIndexType ();
135
+ for (unsigned i = 0 ; i < rank; ++i) {
136
+ // TODO: ideally we want to hoist box reads out of the critical section.
137
+ // We could do this by having box dimensions in block arguments like
138
+ // OpenACC does
139
+ mlir::Value dim = builder.createIntegerConstant (loc, idxTy, i);
140
+ auto dimInfo =
141
+ builder.create <fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
142
+ lbAndExtents.push_back (dimInfo.getLowerBound ());
143
+ lbAndExtents.push_back (dimInfo.getExtent ());
159
144
}
160
145
161
146
auto shapeShiftTy = fir::ShapeShiftType::get (builder.getContext (), rank);
@@ -263,13 +248,12 @@ class PopulateInitAndCleanupRegionsHelper {
263
248
mlir::Type argType, mlir::Value scalarInitValue,
264
249
mlir::Value allocatedPrivVarArg, mlir::Value moldArg,
265
250
mlir::Block *initBlock, mlir::Region &cleanupRegion,
266
- DeclOperationKind kind, const Fortran::semantics::Symbol *sym,
267
- bool cannotHaveLowerBounds)
251
+ DeclOperationKind kind, const Fortran::semantics::Symbol *sym)
268
252
: converter{converter}, builder{converter.getFirOpBuilder ()}, loc{loc},
269
253
argType{argType}, scalarInitValue{scalarInitValue},
270
254
allocatedPrivVarArg{allocatedPrivVarArg}, moldArg{moldArg},
271
255
initBlock{initBlock}, cleanupRegion{cleanupRegion}, kind{kind},
272
- sym{sym}, cannotHaveNonDefaultLowerBounds{cannotHaveLowerBounds} {
256
+ sym{sym} {
273
257
valType = fir::unwrapRefType (argType);
274
258
}
275
259
@@ -311,10 +295,6 @@ class PopulateInitAndCleanupRegionsHelper {
311
295
// / Any length parameters which have been fetched for the type
312
296
mlir::SmallVector<mlir::Value> lenParams;
313
297
314
- // / If the source variable being privatized definitely can't have non-default
315
- // / lower bounds then we don't need to generate code to read them.
316
- bool cannotHaveNonDefaultLowerBounds;
317
-
318
298
void createYield (mlir::Value ret) {
319
299
builder.create <mlir::omp::YieldOp>(loc, ret);
320
300
}
@@ -452,8 +432,7 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedArray(
452
432
// Special case for (possibly allocatable) arrays of polymorphic types
453
433
// e.g. !fir.class<!fir.heap<!fir.array<?x!fir.type<>>>>
454
434
if (source.isPolymorphic ()) {
455
- fir::ShapeShiftOp shape =
456
- getShapeShift (builder, loc, source, cannotHaveNonDefaultLowerBounds);
435
+ fir::ShapeShiftOp shape = getShapeShift (builder, loc, source);
457
436
mlir::Type arrayType = source.getElementOrSequenceType ();
458
437
mlir::Value allocatedArray = builder.create <fir::AllocMemOp>(
459
438
loc, arrayType, /* typeparams=*/ mlir::ValueRange{}, shape.getExtents ());
@@ -492,8 +471,8 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedArray(
492
471
// Put the temporary inside of a box:
493
472
// hlfir::genVariableBox doesn't handle non-default lower bounds
494
473
mlir::Value box;
495
- fir::ShapeShiftOp shapeShift = getShapeShift (builder, loc, getLoadedMoldArg (),
496
- cannotHaveNonDefaultLowerBounds );
474
+ fir::ShapeShiftOp shapeShift =
475
+ getShapeShift (builder, loc, getLoadedMoldArg () );
497
476
mlir::Type boxType = getLoadedMoldArg ().getType ();
498
477
if (mlir::isa<fir::BaseBoxType>(temp.getType ()))
499
478
// the box created by the declare form createTempFromMold is missing
@@ -628,10 +607,10 @@ void Fortran::lower::omp::populateByRefInitAndCleanupRegions(
628
607
mlir::Type argType, mlir::Value scalarInitValue, mlir::Block *initBlock,
629
608
mlir::Value allocatedPrivVarArg, mlir::Value moldArg,
630
609
mlir::Region &cleanupRegion, DeclOperationKind kind,
631
- const Fortran::semantics::Symbol *sym, bool cannotHaveLowerBounds ) {
610
+ const Fortran::semantics::Symbol *sym) {
632
611
PopulateInitAndCleanupRegionsHelper helper (
633
612
converter, loc, argType, scalarInitValue, allocatedPrivVarArg, moldArg,
634
- initBlock, cleanupRegion, kind, sym, cannotHaveLowerBounds );
613
+ initBlock, cleanupRegion, kind, sym);
635
614
helper.populateByRefInitAndCleanupRegions ();
636
615
637
616
// Often we load moldArg to check something (e.g. length parameters, shape)
0 commit comments