Skip to content

Commit c7ff45a

Browse files
committedMay 9, 2023
[flang][hlfir] Lower left-hand side vector subscripts to HLFIR
This patch lowers assignments to vector subscripted designators into the newly added hlfir.elemental_addr and hlfir.region_assign. Note that the codegen of these operation to FIR is still TODO and will still emit a TODO message when trying to compile programs end to end. Differential Revision: https://reviews.llvm.org/D149962
1 parent 54c88fc commit c7ff45a

File tree

4 files changed

+294
-1
lines changed

4 files changed

+294
-1
lines changed
 

‎flang/include/flang/Lower/ConvertExprToHLFIR.h

+17
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ namespace mlir {
2727
class Location;
2828
} // namespace mlir
2929

30+
namespace hlfir {
31+
class ElementalAddrOp;
32+
}
33+
3034
namespace Fortran::lower {
3135

3236
class AbstractConverter;
@@ -115,6 +119,19 @@ fir::MutableBoxValue
115119
convertExprToMutableBox(mlir::Location loc, Fortran::lower::AbstractConverter &,
116120
const Fortran::lower::SomeExpr &,
117121
Fortran::lower::SymMap &);
122+
/// Lower a designator containing vector subscripts into an
123+
/// hlfir::ElementalAddrOp that will allow looping on the elements to assign
124+
/// them values. This only intends to cover the cases where such designator
125+
/// appears on the left-hand side of an assignment or appears in an input IO
126+
/// statement. These are the only contexts in Fortran where a vector subscripted
127+
/// entity may be modified. Otherwise, there is no need to do anything special
128+
/// about vector subscripts, they are automatically turned into array expression
129+
/// values via an hlfir.elemental in the convertExprToXXX calls.
130+
hlfir::ElementalAddrOp convertVectorSubscriptedExprToElementalAddr(
131+
mlir::Location loc, Fortran::lower::AbstractConverter &,
132+
const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &,
133+
Fortran::lower::StatementContext &);
134+
118135
} // namespace Fortran::lower
119136

120137
#endif // FORTRAN_LOWER_CONVERTEXPRTOHLFIR_H

‎flang/lib/Lower/Bridge.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -3226,7 +3226,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
32263226
genCleanUpInRegionIfAny(loc, builder, lhsYieldOp.getCleanup(),
32273227
lhsContext);
32283228
} else {
3229-
TODO(loc, "assignment to vector subscripted entity");
3229+
hlfir::ElementalAddrOp elementalAddr =
3230+
Fortran::lower::convertVectorSubscriptedExprToElementalAddr(
3231+
loc, *this, assign.lhs, localSymbols, lhsContext);
3232+
genCleanUpInRegionIfAny(loc, builder, elementalAddr.getCleanup(),
3233+
lhsContext);
32303234
}
32313235

32323236
// Add "realloc" flag to hlfir.region_assign.

‎flang/lib/Lower/ConvertExprToHLFIR.cpp

+79
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class HlfirDesignatorBuilder {
4747
return result;
4848
}
4949

50+
hlfir::EntityWithAttributes
51+
genDesignatorExpr(const Fortran::lower::SomeExpr &designatorExpr,
52+
bool vectorSubscriptDesignatorToValue = true);
53+
5054
public:
5155
HlfirDesignatorBuilder(mlir::Location loc,
5256
Fortran::lower::AbstractConverter &converter,
@@ -112,6 +116,11 @@ class HlfirDesignatorBuilder {
112116
vectorSubscriptDesignatorToValue);
113117
}
114118

119+
/// Public entry point to lower a vector subscripted designator to
120+
/// an hlfir::ElementalAddrOp.
121+
hlfir::ElementalAddrOp convertVectorSubscriptedExprToElementalAddr(
122+
const Fortran::lower::SomeExpr &designatorExpr);
123+
115124
private:
116125
/// Struct that is filled while visiting a part-ref (in the "visit" member
117126
/// function) before the top level "gen" generates an hlfir.declare for the
@@ -844,6 +853,67 @@ class HlfirDesignatorBuilder {
844853
mlir::Location loc;
845854
};
846855

856+
hlfir::EntityWithAttributes HlfirDesignatorBuilder::genDesignatorExpr(
857+
const Fortran::lower::SomeExpr &designatorExpr,
858+
bool vectorSubscriptDesignatorToValue) {
859+
// Expr<SomeType> plumbing to unwrap Designator<T> and call
860+
// gen(Designator<T>.u).
861+
return std::visit(
862+
[&](const auto &x) -> hlfir::EntityWithAttributes {
863+
using T = std::decay_t<decltype(x)>;
864+
if constexpr (Fortran::common::HasMember<
865+
T, Fortran::lower::CategoryExpression>) {
866+
if constexpr (T::Result::category ==
867+
Fortran::common::TypeCategory::Derived) {
868+
return gen(std::get<Fortran::evaluate::Designator<
869+
Fortran::evaluate::SomeDerived>>(x.u)
870+
.u,
871+
vectorSubscriptDesignatorToValue);
872+
} else {
873+
return std::visit(
874+
[&](const auto &preciseKind) {
875+
using TK =
876+
typename std::decay_t<decltype(preciseKind)>::Result;
877+
return gen(
878+
std::get<Fortran::evaluate::Designator<TK>>(preciseKind.u)
879+
.u,
880+
vectorSubscriptDesignatorToValue);
881+
},
882+
x.u);
883+
}
884+
} else {
885+
fir::emitFatalError(loc, "unexpected typeless Designator");
886+
}
887+
},
888+
designatorExpr.u);
889+
}
890+
891+
hlfir::ElementalAddrOp
892+
HlfirDesignatorBuilder::convertVectorSubscriptedExprToElementalAddr(
893+
const Fortran::lower::SomeExpr &designatorExpr) {
894+
895+
hlfir::EntityWithAttributes elementAddrEntity = genDesignatorExpr(
896+
designatorExpr, /*vectorSubscriptDesignatorToValue=*/false);
897+
assert(getVectorSubscriptElementAddrOp().has_value() &&
898+
"expected vector subscripts");
899+
hlfir::ElementalAddrOp elementalAddrOp = *getVectorSubscriptElementAddrOp();
900+
// Now that the type parameters have been computed, add then to the
901+
// hlfir.elemental_addr.
902+
fir::FirOpBuilder &builder = getBuilder();
903+
llvm::SmallVector<mlir::Value, 1> lengths;
904+
hlfir::genLengthParameters(loc, builder, elementAddrEntity, lengths);
905+
if (!lengths.empty())
906+
elementalAddrOp.getTypeparamsMutable().assign(lengths);
907+
// Create the hlfir.yield terminator inside the hlfir.elemental_body.
908+
builder.setInsertionPointToEnd(&elementalAddrOp.getBody().front());
909+
builder.create<hlfir::YieldOp>(loc, elementAddrEntity);
910+
builder.setInsertionPointAfter(elementalAddrOp);
911+
// Reset the HlfirDesignatorBuilder state, in case it is used on a new
912+
// designator.
913+
setVectorSubscriptElementAddrOp(std::nullopt);
914+
return elementalAddrOp;
915+
}
916+
847917
//===--------------------------------------------------------------------===//
848918
// Binary Operation implementation
849919
//===--------------------------------------------------------------------===//
@@ -1613,3 +1683,12 @@ fir::MutableBoxValue Fortran::lower::convertExprToMutableBox(
16131683
assert(mutableBox && "expression could not be lowered to mutable box");
16141684
return *mutableBox;
16151685
}
1686+
1687+
hlfir::ElementalAddrOp
1688+
Fortran::lower::convertVectorSubscriptedExprToElementalAddr(
1689+
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
1690+
const Fortran::lower::SomeExpr &designatorExpr,
1691+
Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx) {
1692+
return HlfirDesignatorBuilder(loc, converter, symMap, stmtCtx)
1693+
.convertVectorSubscriptedExprToElementalAddr(designatorExpr);
1694+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
! Test lowering of vector subscripted designators in assignment
2+
! left-hand sides.
3+
! RUN: bbc -emit-fir -hlfir -o - -I nw %s 2>&1 | FileCheck %s
4+
5+
subroutine test_simple(x, vector)
6+
integer(8) :: vector(10)
7+
real :: x(:)
8+
x(vector) = 42.
9+
end subroutine
10+
! CHECK-LABEL: func.func @_QPtest_simple(
11+
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare {{.*}}Evector
12+
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare {{.*}}Ex
13+
! CHECK: hlfir.region_assign {
14+
! CHECK: %[[VAL_6:.*]] = arith.constant 4.200000e+01 : f32
15+
! CHECK: hlfir.yield %[[VAL_6]] : f32
16+
! CHECK: } to {
17+
! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
18+
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
19+
! CHECK: hlfir.elemental_addr %[[VAL_8]] : !fir.shape<1> {
20+
! CHECK: ^bb0(%[[VAL_9:.*]]: index):
21+
! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<10xi64>>, index) -> !fir.ref<i64>
22+
! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_10]] : !fir.ref<i64>
23+
! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_11]]) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
24+
! CHECK: hlfir.yield %[[VAL_12]] : !fir.ref<f32>
25+
! CHECK: }
26+
! CHECK: }
27+
28+
subroutine test_cleanup(x, vector, matrix)
29+
integer(8) :: vector(10), matrix(10, 5)
30+
real :: x(:)
31+
x(matmul(vector, matrix)) = 42.
32+
end subroutine
33+
! CHECK-LABEL: func.func @_QPtest_cleanup(
34+
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare {{.*}}Ematrix
35+
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare {{.*}}Evector
36+
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare {{.*}}Ex
37+
! CHECK: hlfir.region_assign {
38+
! CHECK: %[[VAL_11:.*]] = arith.constant 4.200000e+01 : f32
39+
! CHECK: hlfir.yield %[[VAL_11]] : f32
40+
! CHECK: } to {
41+
! CHECK: %[[VAL_12:.*]] = hlfir.matmul %[[VAL_9]]#0 %[[VAL_6]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.ref<!fir.array<10xi64>>, !fir.ref<!fir.array<10x5xi64>>) -> !hlfir.expr<5xi64>
42+
! CHECK: %[[VAL_13:.*]] = arith.constant 5 : index
43+
! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
44+
! CHECK: hlfir.elemental_addr %[[VAL_14]] : !fir.shape<1> {
45+
! CHECK: ^bb0(%[[VAL_15:.*]]: index):
46+
! CHECK: %[[VAL_16:.*]] = hlfir.apply %[[VAL_12]], %[[VAL_15]] : (!hlfir.expr<5xi64>, index) -> i64
47+
! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_10]]#0 (%[[VAL_16]]) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
48+
! CHECK: hlfir.yield %[[VAL_17]] : !fir.ref<f32>
49+
! CHECK: } cleanup {
50+
! CHECK: hlfir.destroy %[[VAL_12]] : !hlfir.expr<5xi64>
51+
! CHECK: }
52+
! CHECK: }
53+
54+
subroutine test_nested_vectors(x, vector1, vector2, vector3)
55+
integer(8) :: vector1(10), vector2(8), vector3(6)
56+
real :: x(:)
57+
x(vector1(vector2(vector3))) = 42.
58+
end subroutine
59+
! CHECK-LABEL: func.func @_QPtest_nested_vectors(
60+
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare {{.*}}Evector1
61+
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare {{.*}}Evector2
62+
! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare {{.*}}Evector3
63+
! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare {{.*}}Ex
64+
! CHECK: hlfir.region_assign {
65+
! CHECK: %[[VAL_14:.*]] = arith.constant 4.200000e+01 : f32
66+
! CHECK: hlfir.yield %[[VAL_14]] : f32
67+
! CHECK: } to {
68+
! CHECK: %[[VAL_15:.*]] = arith.constant 6 : index
69+
! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
70+
! CHECK: %[[VAL_17:.*]] = hlfir.elemental %[[VAL_16]] : (!fir.shape<1>) -> !hlfir.expr<6xi64> {
71+
! CHECK: ^bb0(%[[VAL_18:.*]]: index):
72+
! CHECK: %[[VAL_19:.*]] = hlfir.designate %[[VAL_12]]#0 (%[[VAL_18]]) : (!fir.ref<!fir.array<6xi64>>, index) -> !fir.ref<i64>
73+
! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_19]] : !fir.ref<i64>
74+
! CHECK: %[[VAL_21:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_20]]) : (!fir.ref<!fir.array<8xi64>>, i64) -> !fir.ref<i64>
75+
! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_21]] : !fir.ref<i64>
76+
! CHECK: hlfir.yield_element %[[VAL_22]] : i64
77+
! CHECK: }
78+
! CHECK: %[[VAL_23:.*]] = arith.constant 6 : index
79+
! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_23]] : (index) -> !fir.shape<1>
80+
! CHECK: %[[VAL_25:.*]] = hlfir.elemental %[[VAL_24]] : (!fir.shape<1>) -> !hlfir.expr<6xi64> {
81+
! CHECK: ^bb0(%[[VAL_26:.*]]: index):
82+
! CHECK: %[[VAL_27:.*]] = hlfir.apply %[[VAL_28:.*]], %[[VAL_26]] : (!hlfir.expr<6xi64>, index) -> i64
83+
! CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_27]]) : (!fir.ref<!fir.array<10xi64>>, i64) -> !fir.ref<i64>
84+
! CHECK: %[[VAL_30:.*]] = fir.load %[[VAL_29]] : !fir.ref<i64>
85+
! CHECK: hlfir.yield_element %[[VAL_30]] : i64
86+
! CHECK: }
87+
! CHECK: %[[VAL_31:.*]] = arith.constant 6 : index
88+
! CHECK: %[[VAL_32:.*]] = fir.shape %[[VAL_31]] : (index) -> !fir.shape<1>
89+
! CHECK: hlfir.elemental_addr %[[VAL_32]] : !fir.shape<1> {
90+
! CHECK: ^bb0(%[[VAL_33:.*]]: index):
91+
! CHECK: %[[VAL_34:.*]] = hlfir.apply %[[VAL_35:.*]], %[[VAL_33]] : (!hlfir.expr<6xi64>, index) -> i64
92+
! CHECK: %[[VAL_36:.*]] = hlfir.designate %[[VAL_13]]#0 (%[[VAL_34]]) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
93+
! CHECK: hlfir.yield %[[VAL_36]] : !fir.ref<f32>
94+
! CHECK: } cleanup {
95+
! CHECK: hlfir.destroy %[[VAL_37:.*]] : !hlfir.expr<6xi64>
96+
! CHECK: hlfir.destroy %[[VAL_38:.*]] : !hlfir.expr<6xi64>
97+
! CHECK: }
98+
! CHECK: }
99+
100+
subroutine test_substring(x, vector)
101+
integer(8) :: vector(10), ifoo, ibar
102+
external :: ifoo, ibar
103+
character(*) :: x(:)
104+
x(vector)(ifoo(): ibar()) = "hello"
105+
end subroutine
106+
! CHECK-LABEL: func.func @_QPtest_substring(
107+
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare {{.*}}Evector
108+
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare {{.*}}Ex
109+
! CHECK: hlfir.region_assign {
110+
! CHECK: %[[VAL_6:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,5>>
111+
! CHECK: %[[VAL_7:.*]] = arith.constant 5 : index
112+
! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_6]] typeparams %[[VAL_7]] {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQcl.68656C6C6F"} : (!fir.ref<!fir.char<1,5>>, index) -> (!fir.ref<!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>)
113+
! CHECK: hlfir.yield %[[VAL_8]]#0 : !fir.ref<!fir.char<1,5>>
114+
! CHECK: } to {
115+
! CHECK: %[[VAL_9:.*]] = arith.constant 10 : index
116+
! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
117+
! CHECK: %[[VAL_11:.*]] = fir.call @_QPifoo() {{.*}}: () -> i64
118+
! CHECK: %[[VAL_12:.*]] = fir.call @_QPibar() {{.*}}: () -> i64
119+
! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
120+
! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
121+
! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
122+
! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_14]], %[[VAL_13]] : index
123+
! CHECK: %[[VAL_17:.*]] = arith.addi %[[VAL_16]], %[[VAL_15]] : index
124+
! CHECK: %[[VAL_18:.*]] = arith.constant 0 : index
125+
! CHECK: %[[VAL_19:.*]] = arith.cmpi sgt, %[[VAL_17]], %[[VAL_18]] : index
126+
! CHECK: %[[VAL_20:.*]] = arith.select %[[VAL_19]], %[[VAL_17]], %[[VAL_18]] : index
127+
! CHECK: hlfir.elemental_addr %[[VAL_10]] typeparams %[[VAL_20]] : !fir.shape<1>, index {
128+
! CHECK: ^bb0(%[[VAL_21:.*]]: index):
129+
! CHECK: %[[VAL_22:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_21]]) : (!fir.ref<!fir.array<10xi64>>, index) -> !fir.ref<i64>
130+
! CHECK: %[[VAL_23:.*]] = fir.load %[[VAL_22]] : !fir.ref<i64>
131+
! CHECK: %[[VAL_24:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_23]]) substr %[[VAL_13]], %[[VAL_14]] typeparams %[[VAL_20]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>, i64, index, index, index) -> !fir.boxchar<1>
132+
! CHECK: hlfir.yield %[[VAL_24]] : !fir.boxchar<1>
133+
! CHECK: }
134+
! CHECK: }
135+
136+
subroutine test_hard_array_ref(x, vector1, vector2)
137+
integer(8) :: vector1(10), vector2(20), ifoo, ibar, ibaz
138+
external :: ifoo, ibar, ibaz
139+
real :: x(:, :, :, :, :)
140+
x(vector1, :, ifoo():ibar(), ibaz(), vector2) = 42.
141+
end subroutine
142+
! CHECK-LABEL: func.func @_QPtest_hard_array_ref(
143+
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare {{.*}}Evector1
144+
! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare {{.*}}Evector2
145+
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare {{.*}}Ex
146+
! CHECK: hlfir.region_assign {
147+
! CHECK: %[[VAL_10:.*]] = arith.constant 4.200000e+01 : f32
148+
! CHECK: hlfir.yield %[[VAL_10]] : f32
149+
! CHECK: } to {
150+
! CHECK: %[[VAL_11:.*]] = arith.constant 10 : index
151+
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
152+
! CHECK: %[[VAL_13:.*]] = arith.constant 1 : index
153+
! CHECK: %[[VAL_14:.*]]:3 = fir.box_dims %[[VAL_9]]#1, %[[VAL_13]] : (!fir.box<!fir.array<?x?x?x?x?xf32>>, index) -> (index, index, index)
154+
! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
155+
! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
156+
! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_14]]#1, %[[VAL_12]] : index
157+
! CHECK: %[[VAL_18:.*]] = arith.addi %[[VAL_17]], %[[VAL_15]] : index
158+
! CHECK: %[[VAL_19:.*]] = arith.divsi %[[VAL_18]], %[[VAL_15]] : index
159+
! CHECK: %[[VAL_20:.*]] = arith.cmpi sgt, %[[VAL_19]], %[[VAL_16]] : index
160+
! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_19]], %[[VAL_16]] : index
161+
! CHECK: %[[VAL_22:.*]] = fir.call @_QPifoo() {{.*}}: () -> i64
162+
! CHECK: %[[VAL_23:.*]] = fir.call @_QPibar() {{.*}}: () -> i64
163+
! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
164+
! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_23]] : (i64) -> index
165+
! CHECK: %[[VAL_26:.*]] = arith.constant 1 : index
166+
! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
167+
! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_25]], %[[VAL_24]] : index
168+
! CHECK: %[[VAL_29:.*]] = arith.addi %[[VAL_28]], %[[VAL_26]] : index
169+
! CHECK: %[[VAL_30:.*]] = arith.divsi %[[VAL_29]], %[[VAL_26]] : index
170+
! CHECK: %[[VAL_31:.*]] = arith.cmpi sgt, %[[VAL_30]], %[[VAL_27]] : index
171+
! CHECK: %[[VAL_32:.*]] = arith.select %[[VAL_31]], %[[VAL_30]], %[[VAL_27]] : index
172+
! CHECK: %[[VAL_33:.*]] = fir.call @_QPibaz() {{.*}}: () -> i64
173+
! CHECK: %[[VAL_34:.*]] = arith.constant 20 : index
174+
! CHECK: %[[VAL_35:.*]] = fir.shape %[[VAL_11]], %[[VAL_21]], %[[VAL_32]], %[[VAL_34]] : (index, index, index, index) -> !fir.shape<4>
175+
! CHECK: hlfir.elemental_addr %[[VAL_35]] : !fir.shape<4> {
176+
! CHECK: ^bb0(%[[VAL_36:.*]]: index, %[[VAL_37:.*]]: index, %[[VAL_38:.*]]: index, %[[VAL_39:.*]]: index):
177+
! CHECK: %[[VAL_40:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_36]]) : (!fir.ref<!fir.array<10xi64>>, index) -> !fir.ref<i64>
178+
! CHECK: %[[VAL_41:.*]] = fir.load %[[VAL_40]] : !fir.ref<i64>
179+
! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
180+
! CHECK: %[[VAL_43:.*]] = arith.subi %[[VAL_37]], %[[VAL_42]] : index
181+
! CHECK: %[[VAL_44:.*]] = arith.muli %[[VAL_43]], %[[VAL_15]] : index
182+
! CHECK: %[[VAL_45:.*]] = arith.addi %[[VAL_12]], %[[VAL_44]] : index
183+
! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
184+
! CHECK: %[[VAL_47:.*]] = arith.subi %[[VAL_38]], %[[VAL_46]] : index
185+
! CHECK: %[[VAL_48:.*]] = arith.muli %[[VAL_47]], %[[VAL_26]] : index
186+
! CHECK: %[[VAL_49:.*]] = arith.addi %[[VAL_24]], %[[VAL_48]] : index
187+
! CHECK: %[[VAL_50:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_39]]) : (!fir.ref<!fir.array<20xi64>>, index) -> !fir.ref<i64>
188+
! CHECK: %[[VAL_51:.*]] = fir.load %[[VAL_50]] : !fir.ref<i64>
189+
! CHECK: %[[VAL_52:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_41]], %[[VAL_45]], %[[VAL_49]], %[[VAL_33]], %[[VAL_51]]) : (!fir.box<!fir.array<?x?x?x?x?xf32>>, i64, index, index, i64, i64) -> !fir.ref<f32>
190+
! CHECK: hlfir.yield %[[VAL_52]] : !fir.ref<f32>
191+
! CHECK: }
192+
! CHECK: }
193+
! CHECK: return

0 commit comments

Comments
 (0)
Please sign in to comment.