@@ -4077,11 +4077,16 @@ class ArrayExprLowering {
4077
4077
return header;
4078
4078
}
4079
4079
4080
+ // / Lower mask expressions with implied iteration spaces from the variants of
4081
+ // / WHERE syntax. Since it is legal for mask expressions to have side-effects
4082
+ // / and modify values that will be used for the lhs, rhs, or both of
4083
+ // / subsequent assignments, the mask must be evaluated before the assignment
4084
+ // / is processed.
4080
4085
// / Mask expressions are array expressions too.
4081
4086
void genMasks () {
4082
- auto loc = getLoc ();
4083
4087
// Lower the mask expressions, if any.
4084
4088
if (implicitSpaceHasMasks ()) {
4089
+ auto loc = getLoc ();
4085
4090
// Mask expressions are array expressions too.
4086
4091
for (const auto *e : implicitSpace->getExprs ())
4087
4092
if (e && !implicitSpace->isLowered (e)) {
@@ -4140,7 +4145,6 @@ class ArrayExprLowering {
4140
4145
auto ldExt = builder.create <fir::LoadOp>(loc, coor);
4141
4146
extents.push_back (builder.createConvert (loc, idxTy, ldExt));
4142
4147
}
4143
- destShape = extents;
4144
4148
// Construct shape of buffer.
4145
4149
auto shapeOp = builder.genShape (loc, extents);
4146
4150
@@ -4221,11 +4225,6 @@ class ArrayExprLowering {
4221
4225
std::pair<IterationSpace, mlir::OpBuilder::InsertPoint>
4222
4226
genIterSpace (mlir::Type resultType) {
4223
4227
auto loc = getLoc ();
4224
-
4225
- // Generate any mask expressions, as necessary. This is the compute step
4226
- // that creates the effective masks. See 10.2.3.2 in particular.
4227
- genMasks ();
4228
-
4229
4228
auto shape = genIterationShape ();
4230
4229
if (!destination) {
4231
4230
// Allocate storage for the result if it is not already provided.
@@ -6378,7 +6377,11 @@ class ArrayExprLowering {
6378
6377
: converter{converter}, builder{converter.getFirOpBuilder ()},
6379
6378
stmtCtx{stmtCtx}, symMap{symMap},
6380
6379
explicitSpace (expSpace->isActive () ? expSpace : nullptr),
6381
- implicitSpace(impSpace->empty () ? nullptr : impSpace), semant{sem} {}
6380
+ implicitSpace(impSpace->empty () ? nullptr : impSpace), semant{sem} {
6381
+ // Generate any mask expressions, as necessary. This is the compute step
6382
+ // that creates the effective masks. See 10.2.3.2 in particular.
6383
+ genMasks ();
6384
+ }
6382
6385
6383
6386
mlir::Location getLoc () { return converter.getCurrentLocation (); }
6384
6387
0 commit comments