@@ -122,47 +122,25 @@ static void createCleanupRegion(Fortran::lower::AbstractConverter &converter,
122122 typeError ();
123123}
124124
125- fir::ShapeShiftOp Fortran::lower::omp::getShapeShift (
126- fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box ,
127- bool cannotHaveNonDefaultLowerBounds, bool useDefaultLowerBounds ) {
125+ fir::ShapeShiftOp Fortran::lower::omp::getShapeShift (fir::FirOpBuilder &builder,
126+ mlir::Location loc ,
127+ mlir::Value box ) {
128128 fir::SequenceType sequenceType = mlir::cast<fir::SequenceType>(
129129 hlfir::getFortranElementOrSequenceType (box.getType ()));
130130 const unsigned rank = sequenceType.getDimension ();
131131 llvm::SmallVector<mlir::Value> lbAndExtents;
132132 lbAndExtents.reserve (rank * 2 );
133133
134- mlir::Value oneVal;
135- auto one = [&] {
136- if (!oneVal)
137- oneVal = builder.createIntegerConstant (loc, idxTy, 1 );
138- return oneVal;
139- };
140-
141- if ((cannotHaveNonDefaultLowerBounds || useDefaultLowerBounds) &&
142- !sequenceType.hasDynamicExtents ()) {
143- // We don't need fir::BoxDimsOp if all of the extents are statically known
144- // and we can assume default lower bounds. This helps avoids reads from the
145- // mold arg.
146- // We may also want to use default lower bounds to iterate through array
147- // elements without having to adjust each index.
148- for (int64_t extent : sequenceType.getShape ()) {
149- assert (extent != sequenceType.getUnknownExtent ());
150- lbAndExtents.push_back (one ());
151- mlir::Value extentVal = builder.createIntegerConstant (loc, idxTy, extent);
152- lbAndExtents.push_back (extentVal);
153- }
154- } else {
155- for (unsigned i = 0 ; i < rank; ++i) {
156- // TODO: ideally we want to hoist box reads out of the critical section.
157- // We could do this by having box dimensions in block arguments like
158- // OpenACC does
159- mlir::Value dim = builder.createIntegerConstant (loc, idxTy, i);
160- auto dimInfo =
161- builder.create <fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
162- lbAndExtents.push_back (useDefaultLowerBounds ? one ()
163- : dimInfo.getLowerBound ());
164- lbAndExtents.push_back (dimInfo.getExtent ());
165- }
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 ());
166144 }
167145
168146 auto shapeShiftTy = fir::ShapeShiftType::get (builder.getContext (), rank);
0 commit comments