Skip to content

Commit 10c3a6a

Browse files
committed
Updated comments in selectBoundaryValue.
1 parent de41f64 commit 10c3a6a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,18 +1534,24 @@ class ArrayShiftConversion : public mlir::OpRewritePattern<Op> {
15341534
mlir::Location loc, fir::FirOpBuilder &builder, hlfir::EOShiftOp op,
15351535
mlir::Value precomputedScalarBoundary, mlir::Value boundaryIsScalarPred,
15361536
mlir::ValueRange oneBasedIndices) {
1537+
// Boundary is statically absent: a default value has been precomputed.
15371538
if (!op.getBoundary())
15381539
return precomputedScalarBoundary;
15391540

1541+
// Boundary is statically present and is a scalar: boundary does not depend
1542+
// upon the indices and so it has been precomputed.
15401543
hlfir::Entity boundary{op.getBoundary()};
15411544
if (boundary.isScalar())
15421545
return precomputedScalarBoundary;
15431546

1544-
if (!precomputedScalarBoundary) {
1545-
// The array boundary must be present, so we just need to load
1546-
// the scalar boundary value.
1547+
// Boundary is statically present and is an array: if the scalar
1548+
// boundary has not been precomputed, this means that the data type
1549+
// of the shifted values does not provide a way to compute
1550+
// the default boundary value, so the array boundary must be dynamically
1551+
// present, and we can load the boundary values from it.
1552+
bool mustBePresent = !precomputedScalarBoundary;
1553+
if (mustBePresent)
15471554
return loadEoshiftVal(loc, builder, boundary, oneBasedIndices);
1548-
}
15491555

15501556
// The array boundary may be dynamically absent.
15511557
// In this case, precomputedScalarBoundary is a pre-computed scalar

0 commit comments

Comments
 (0)