Skip to content

Commit a51722f

Browse files
authored
Revert "[flang][lowering] Fix lowering of nested WHERE statements" (#1081)
This reverts commit b80bc91.
1 parent b80bc91 commit a51722f

File tree

3 files changed

+22
-203
lines changed

3 files changed

+22
-203
lines changed

flang/lib/Lower/ConvertExpr.cpp

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3821,36 +3821,34 @@ class ArrayExprLowering {
38213821

38223822
// Handle the negated conditions. See 10.2.3.2p4 as to why this control
38233823
// structure is produced.
3824-
auto masks = implicitSpace->getMasks();
3825-
for (auto maskExprs : masks) {
3826-
const auto size = maskExprs.size() - 1;
3827-
for (std::remove_const_t<decltype(size)> i = 0; i < size; ++i)
3828-
if (maskExprs[i]) {
3829-
auto ifOp = builder.create<fir::IfOp>(
3830-
loc, mlir::TypeRange{innerArg.getType()},
3831-
fir::getBase(genCond(
3832-
implicitSpace->getBindingWithShape(maskExprs[i]), iters)),
3833-
/*withElseRegion=*/true);
3834-
builder.create<fir::ResultOp>(loc, ifOp.getResult(0));
3835-
builder.setInsertionPointToStart(&ifOp.thenRegion().front());
3836-
builder.create<fir::ResultOp>(loc, innerArg);
3837-
builder.setInsertionPointToStart(&ifOp.elseRegion().front());
3838-
}
3839-
3840-
// The last condition is either non-negated or unconditionally negated.
3841-
if (maskExprs[size]) {
3824+
auto maskExprs = implicitSpace->getExprs();
3825+
const auto size = maskExprs.size() - 1;
3826+
for (std::remove_const_t<decltype(size)> i = 0; i < size; ++i)
3827+
if (maskExprs[i]) {
38423828
auto ifOp = builder.create<fir::IfOp>(
38433829
loc, mlir::TypeRange{innerArg.getType()},
38443830
fir::getBase(genCond(
3845-
implicitSpace->getBindingWithShape(maskExprs[size]), iters)),
3831+
implicitSpace->getBindingWithShape(maskExprs[i]), iters)),
38463832
/*withElseRegion=*/true);
38473833
builder.create<fir::ResultOp>(loc, ifOp.getResult(0));
3848-
builder.setInsertionPointToStart(&ifOp.elseRegion().front());
3849-
builder.create<fir::ResultOp>(loc, innerArg);
38503834
builder.setInsertionPointToStart(&ifOp.thenRegion().front());
3851-
} else {
3852-
// do nothing
3835+
builder.create<fir::ResultOp>(loc, innerArg);
3836+
builder.setInsertionPointToStart(&ifOp.elseRegion().front());
38533837
}
3838+
3839+
// The last condition is either non-negated or unconditionally negated.
3840+
if (maskExprs[size]) {
3841+
auto ifOp = builder.create<fir::IfOp>(
3842+
loc, mlir::TypeRange{innerArg.getType()},
3843+
fir::getBase(genCond(
3844+
implicitSpace->getBindingWithShape(maskExprs[size]), iters)),
3845+
/*withElseRegion=*/true);
3846+
builder.create<fir::ResultOp>(loc, ifOp.getResult(0));
3847+
builder.setInsertionPointToStart(&ifOp.elseRegion().front());
3848+
builder.create<fir::ResultOp>(loc, innerArg);
3849+
builder.setInsertionPointToStart(&ifOp.thenRegion().front());
3850+
} else {
3851+
// do nothing
38543852
}
38553853
}
38563854

flang/lib/Lower/IterationSpace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class ImplicitIterSpace
150150
return maskVarMap.lookup(exp).second;
151151
}
152152

153+
private:
153154
// Stack of WHERE constructs, each building a list of mask expressions.
154155
llvm::SmallVector<llvm::SmallVector<FrontEndMaskExpr>> &getMasks() {
155156
return stack;
@@ -159,7 +160,6 @@ class ImplicitIterSpace
159160
return stack;
160161
}
161162

162-
private:
163163
llvm::DenseMap<FrontEndExpr, std::pair<mlir::Value, mlir::Value>> maskVarMap;
164164
};
165165

flang/test/Lower/nested-where.f90

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)