Skip to content

Commit fa3e602

Browse files
authored
Merge pull request #1023 from flang-compiler/jpr-fix-issue-1019
Handle vector subscripts that are descriptors - Fix #1019
2 parents feec79c + 344abfa commit fa3e602

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

flang/lib/Lower/ConvertExpr.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
#include "flang/Lower/Todo.h"
3333
#include "flang/Optimizer/Builder/Character.h"
3434
#include "flang/Optimizer/Builder/Complex.h"
35+
#include "flang/Optimizer/Builder/Runtime/Character.h"
36+
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
3537
#include "flang/Optimizer/Dialect/FIRAttr.h"
3638
#include "flang/Optimizer/Dialect/FIRDialect.h"
3739
#include "flang/Optimizer/Dialect/FIROpsSupport.h"
38-
#include "flang/Optimizer/Builder/Runtime/Character.h"
39-
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
4040
#include "flang/Optimizer/Support/FatalError.h"
4141
#include "flang/Optimizer/Transforms/Factory.h"
4242
#include "flang/Semantics/expression.h"
@@ -4327,24 +4327,14 @@ class ArrayExprLowering {
43274327
newIters.setIndexValue(dim, val);
43284328
return newIters;
43294329
};
4330-
auto useInexactRange = [&]() {
4331-
// Get the range of the array in this dimension, [1:n:1].
4332-
trips.push_back(one);
4333-
trips.push_back(getExtent(arrExt, sub.index()));
4334-
trips.push_back(one);
4335-
};
4336-
if (const auto *sym = extractSubscriptSymbol(arrExpr)) {
4337-
auto symVal = symMap.lookupSymbol(*sym);
4338-
symVal.match(
4339-
[&](const fir::ArrayBoxValue &v) {
4340-
trips.push_back(getLBound(v, 0, one));
4341-
trips.push_back(getUBound(v, 0, one));
4342-
trips.push_back(one);
4343-
},
4344-
[&](auto) { useInexactRange(); });
4345-
} else {
4346-
useInexactRange();
4347-
}
4330+
// Create a slice with the vector size so that the shape
4331+
// of array reference is correctly computed in later phase,
4332+
// even though this is not a triplet.
4333+
auto vectorSubscriptShape = getShape(arrLoad);
4334+
assert(vectorSubscriptShape.size() == 1);
4335+
trips.push_back(one);
4336+
trips.push_back(vectorSubscriptShape[0]);
4337+
trips.push_back(one);
43484338
} else {
43494339
// A regular scalar index, which does not yield an array
43504340
// section. Use a degenerate slice operation `(e:undef:undef)`

0 commit comments

Comments
 (0)