Skip to content

Commit 1fb0707

Browse files
committed
[flang][hlfir] Simplify hlfir::convertToValue
Use hlfir::loadTrivialScalars to dereference pointer, allocatables, and load numerical and logical scalars. This has a small fallout on tests: - load is done on the HLFIR entity (#0 of hlfir.declare) and not the FIR one (#1). This makes no difference at the FIR level (#1 and #0 only differs to account for assumed and explicit shape lower bounds). - loadTrivialScalars get rids of allocatable fir.box for monomoprhic scalars (it is not needed). This exposed a bug in lowering of MERGE with a polymorphic and a monomorphic argument: when the monomorphic is not a fir.box, the polymorphic fir.class should not be reboxed but its address should be read. Reviewed By: tblah Differential Revision: https://reviews.llvm.org/D153252
1 parent efbb4aa commit 1fb0707

8 files changed

+38
-74
lines changed

flang/lib/Optimizer/Builder/HLFIRTools.cpp

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -912,52 +912,11 @@ hlfir::translateToExtendedValue(mlir::Location loc, fir::FirOpBuilder &builder,
912912
std::pair<fir::ExtendedValue, std::optional<hlfir::CleanupFunction>>
913913
hlfir::convertToValue(mlir::Location loc, fir::FirOpBuilder &builder,
914914
const hlfir::Entity &entity) {
915-
auto [exv, cleanup] = translateToExtendedValue(loc, builder, entity);
916915
// Load scalar references to integer, logical, real, or complex value
917916
// to an mlir value, dereference allocatable and pointers, and get rid
918917
// of fir.box that are not needed or create a copy into contiguous memory.
919-
exv = exv.match(
920-
[&](const fir::UnboxedValue &box) -> fir::ExtendedValue {
921-
if (mlir::Type elementType = fir::dyn_cast_ptrEleTy(box.getType()))
922-
if (fir::isa_trivial(elementType))
923-
return builder.create<fir::LoadOp>(loc, box);
924-
return box;
925-
},
926-
[&](const fir::CharBoxValue &box) -> fir::ExtendedValue { return box; },
927-
[&](const fir::ArrayBoxValue &box) -> fir::ExtendedValue { return box; },
928-
[&](const fir::CharArrayBoxValue &box) -> fir::ExtendedValue {
929-
return box;
930-
},
931-
[&](const fir::MutableBoxValue &box) -> fir::ExtendedValue {
932-
if (box.rank() != 0)
933-
TODO(loc, "lower array descriptor designator to HLFIR value");
934-
if (entity.isProcedure())
935-
TODO(loc, "lower proc descriptor designator to HLFIR value");
936-
937-
hlfir::Entity derefedEntity =
938-
hlfir::derefPointersAndAllocatables(loc, builder, entity);
939-
mlir::Type eleTy = derefedEntity.getFortranElementType();
940-
941-
// Trivial values are unboxed.
942-
if (derefedEntity.isScalar() && fir::isa_trivial(eleTy))
943-
return builder.create<fir::LoadOp>(loc, derefedEntity);
944-
945-
if (mlir::isa<fir::CharacterType>(eleTy)) {
946-
if (mlir::isa<fir::BoxCharType>(derefedEntity.getFirBase().getType()))
947-
return genUnboxChar(loc, builder, derefedEntity.getFirBase());
948-
// Extract length from the original entity.
949-
mlir::Value len = genCharacterVariableLength(loc, builder, entity);
950-
return fir::CharBoxValue{derefedEntity, len};
951-
}
952-
953-
// Keep derived type value boxed.
954-
return fir::factory::genMutableBoxRead(builder, loc, box);
955-
},
956-
[&](const auto &) -> fir::ExtendedValue {
957-
// Can we end up here?
958-
TODO(loc, "lower descriptor designator to HLFIR value");
959-
});
960-
return {exv, cleanup};
918+
auto derefedAndLoadedEntity = loadTrivialScalar(loc, builder, entity);
919+
return translateToExtendedValue(loc, builder, derefedAndLoadedEntity);
961920
}
962921

963922
static fir::ExtendedValue placeTrivialInMemory(mlir::Location loc,

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,20 +3638,21 @@ IntrinsicLibrary::genMerge(mlir::Type,
36383638
// used.
36393639
mlir::Value tsourceCast = tsource;
36403640
mlir::Value fsourceCast = fsource;
3641+
auto convertToStaticType = [&](mlir::Value polymorphic,
3642+
mlir::Value other) -> mlir::Value {
3643+
mlir::Type otherType = other.getType();
3644+
if (otherType.isa<fir::BaseBoxType>())
3645+
return builder.create<fir::ReboxOp>(loc, otherType, polymorphic,
3646+
/*shape*/ mlir::Value{},
3647+
/*slice=*/mlir::Value{});
3648+
return builder.create<fir::BoxAddrOp>(loc, otherType, polymorphic);
3649+
};
36413650
if (fir::isPolymorphicType(tsource.getType()) &&
36423651
!fir::isPolymorphicType(fsource.getType())) {
3643-
tsourceCast = builder.create<fir::ReboxOp>(loc, fsource.getType(), tsource,
3644-
/*shape*/ mlir::Value{},
3645-
/*slice=*/mlir::Value{});
3646-
3647-
// builder.createConvert(loc, fsource.getType(), tsource);
3652+
tsourceCast = convertToStaticType(tsource, fsource);
36483653
} else if (!fir::isPolymorphicType(tsource.getType()) &&
36493654
fir::isPolymorphicType(fsource.getType())) {
3650-
fsourceCast = builder.create<fir::ReboxOp>(loc, tsource.getType(), fsource,
3651-
/*shape*/ mlir::Value{},
3652-
/*slice=*/mlir::Value{});
3653-
3654-
// fsourceCast = builder.createConvert(loc, tsource.getType(), fsource);
3655+
fsourceCast = convertToStaticType(fsource, tsource);
36553656
} else {
36563657
// FSOURCE and TSOURCE are not polymorphic.
36573658
// FSOURCE has the same type as TSOURCE, but they may not have the same MLIR

flang/test/Lower/HLFIR/calls-character-singleton-result.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ subroutine scalar_char(c, i)
1414
! CHECK: %[[VAL_4:.*]] = fir.convert %{{.*}}#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1>>
1515
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] typeparams %{{.*}} {{.*}}Ec
1616
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %{{.*}} {{.*}}Ei
17-
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_6]]#1 : !fir.ref<i64>
17+
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_6]]#0 : !fir.ref<i64>
1818
! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> i8
1919
! CHECK: %[[VAL_9:.*]] = fir.undefined !fir.char<1>
2020
! CHECK: %[[VAL_10:.*]] = fir.insert_value %[[VAL_9]], %[[VAL_8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>

flang/test/Lower/HLFIR/calls-f77.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ subroutine return_char(n)
157157
! CHECK-LABEL: func.func @_QPreturn_char(
158158
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare {{.*}}n
159159
! CHECK: %[[VAL_2:.*]] = arith.constant -1 : i32
160-
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_1]]#1 : !fir.ref<i64>
160+
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_1]]#0 : !fir.ref<i64>
161161
! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
162162
! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
163163
! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_9]] : index

flang/test/Lower/HLFIR/convert-mbox-to-value.f90

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ end subroutine test_char_allocatable
5454
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = "_QFtest_char_allocatableEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
5555
! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.char<1,11>>>>
5656
! CHECK: %[[VAL_6:.*]] = fir.box_addr %[[VAL_5]] : (!fir.box<!fir.heap<!fir.char<1,11>>>) -> !fir.heap<!fir.char<1,11>>
57+
! CHECK: %[[VAL_1B:.*]] = arith.constant 11 : index
5758
! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
5859
! CHECK: %[[VAL_8:.*]] = arith.constant -1 : index
5960
! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
6061
! CHECK: %[[VAL_10:.*]] = arith.constant true
6162
! CHECK: %[[VAL_11:.*]] = arith.constant 32 : i8
62-
! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_1]], %[[VAL_7]] : index
63+
! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_1B]], %[[VAL_7]] : index
6364
! CHECK: %[[VAL_13:.*]]:2 = fir.iterate_while (%[[VAL_14:.*]] = %[[VAL_12]] to %[[VAL_9]] step %[[VAL_8]]) and (%[[VAL_15:.*]] = %[[VAL_10]]) iter_args(%[[VAL_16:.*]] = %[[VAL_12]]) -> (index) {
6465
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_6]] : (!fir.heap<!fir.char<1,11>>) -> !fir.ref<!fir.array<11x!fir.char<1>>>
6566
! CHECK: %[[VAL_18:.*]] = fir.coordinate_of %[[VAL_17]], %[[VAL_14]] : (!fir.ref<!fir.array<11x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
@@ -88,12 +89,13 @@ end subroutine test_char_pointer
8889
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_3]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFtest_char_pointerEp"} : (!fir.ref<!fir.box<!fir.ptr<!fir.char<1,11>>>>, index) -> (!fir.ref<!fir.box<!fir.ptr<!fir.char<1,11>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.char<1,11>>>>)
8990
! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.char<1,11>>>>
9091
! CHECK: %[[VAL_6:.*]] = fir.box_addr %[[VAL_5]] : (!fir.box<!fir.ptr<!fir.char<1,11>>>) -> !fir.ptr<!fir.char<1,11>>
92+
! CHECK: %[[VAL_3B:.*]] = arith.constant 11 : index
9193
! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
9294
! CHECK: %[[VAL_8:.*]] = arith.constant -1 : index
9395
! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
9496
! CHECK: %[[VAL_10:.*]] = arith.constant true
9597
! CHECK: %[[VAL_11:.*]] = arith.constant 32 : i8
96-
! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_3]], %[[VAL_7]] : index
98+
! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_3B]], %[[VAL_7]] : index
9799
! CHECK: %[[VAL_13:.*]]:2 = fir.iterate_while (%[[VAL_14:.*]] = %[[VAL_12]] to %[[VAL_9]] step %[[VAL_8]]) and (%[[VAL_15:.*]] = %[[VAL_10]]) iter_args(%[[VAL_16:.*]] = %[[VAL_12]]) -> (index) {
98100
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_6]] : (!fir.ptr<!fir.char<1,11>>) -> !fir.ref<!fir.array<11x!fir.char<1>>>
99101
! CHECK: %[[VAL_18:.*]] = fir.coordinate_of %[[VAL_17]], %[[VAL_14]] : (!fir.ref<!fir.array<11x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
@@ -205,14 +207,15 @@ end subroutine test_derived_allocatable
205207
! CHECK: %[[VAL_12:.*]] = fir.embox %[[VAL_11]] : (!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>) -> !fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>
206208
! CHECK: fir.store %[[VAL_12]] to %[[VAL_10]] : !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>
207209
! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_10]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_derived_allocatableEr"} : (!fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>) -> (!fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>, !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>)
208-
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_4]]#1 : !fir.ref<!fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>
209-
! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_8]]#1 : !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>
210-
! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_9]]#1 : !fir.ref<!fir.logical<4>>
210+
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>
211+
! CHECK: %[[VAL_14B:.*]] = fir.box_addr %[[VAL_14]] : (!fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>) -> !fir.heap<!fir.type<_QFtest_derived_allocatableTt>>
212+
! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_8]]#0 : !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>
213+
! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<!fir.logical<4>>
211214
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (!fir.logical<4>) -> i1
212-
! CHECK: %[[VAL_18:.*]] = fir.rebox %[[VAL_15]] : (!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>) -> !fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>
213-
! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_17]], %[[VAL_14]], %[[VAL_18]] : !fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>
214-
! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>) -> (!fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>, !fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>)
215-
! CHECK: %[[VAL_21:.*]] = hlfir.as_expr %[[VAL_20]]#0 : (!fir.box<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>) -> !hlfir.expr<!fir.type<_QFtest_derived_allocatableTt>>
215+
! CHECK: %[[VAL_18:.*]] = fir.box_addr %[[VAL_15]] : (!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>) -> !fir.heap<!fir.type<_QFtest_derived_allocatableTt>>
216+
! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_17]], %[[VAL_14B]], %[[VAL_18]] : !fir.heap<!fir.type<_QFtest_derived_allocatableTt>>
217+
! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>) -> (!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>, !fir.heap<!fir.type<_QFtest_derived_allocatableTt>>)
218+
! CHECK: %[[VAL_21:.*]] = hlfir.as_expr %[[VAL_20]]#0 : (!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>) -> !hlfir.expr<!fir.type<_QFtest_derived_allocatableTt>>
216219
! CHECK: hlfir.assign %[[VAL_21]] to %[[VAL_13]]#0 realloc : !hlfir.expr<!fir.type<_QFtest_derived_allocatableTt>>, !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_allocatableTt>>>>
217220
! CHECK: hlfir.destroy %[[VAL_21]] : !hlfir.expr<!fir.type<_QFtest_derived_allocatableTt>>
218221
! CHECK: return
@@ -244,14 +247,15 @@ end subroutine test_derived_pointer
244247
! CHECK: %[[VAL_12:.*]] = fir.embox %[[VAL_11]] : (!fir.heap<!fir.type<_QFtest_derived_pointerTt>>) -> !fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>
245248
! CHECK: fir.store %[[VAL_12]] to %[[VAL_10]] : !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>>
246249
! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_10]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_derived_pointerEr"} : (!fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>>) -> (!fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>>, !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>>)
247-
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_4]]#1 : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>>
248-
! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_8]]#1 : !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>>
249-
! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_9]]#1 : !fir.ref<!fir.logical<4>>
250+
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>>
251+
! CHECK: %[[VAL_14B:.*]] = fir.box_addr %[[VAL_14]] : (!fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>) -> !fir.ptr<!fir.type<_QFtest_derived_pointerTt>>
252+
! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_8]]#0 : !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>>
253+
! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_9]]#0 : !fir.ref<!fir.logical<4>>
250254
! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (!fir.logical<4>) -> i1
251-
! CHECK: %[[VAL_18:.*]] = fir.rebox %[[VAL_15]] : (!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>) -> !fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>
252-
! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_17]], %[[VAL_14]], %[[VAL_18]] : !fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>
253-
! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>) -> (!fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>, !fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>)
254-
! CHECK: %[[VAL_21:.*]] = hlfir.as_expr %[[VAL_20]]#0 : (!fir.box<!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>>) -> !hlfir.expr<!fir.type<_QFtest_derived_pointerTt>>
255+
! CHECK: %[[VAL_18:.*]] = fir.box_addr %[[VAL_15]] : (!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>) -> !fir.ptr<!fir.type<_QFtest_derived_pointerTt>>
256+
! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_17]], %[[VAL_14B]], %[[VAL_18]] : !fir.ptr<!fir.type<_QFtest_derived_pointerTt>>
257+
! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]] {uniq_name = ".tmp.intrinsic_result"} : (!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>) -> (!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>, !fir.ptr<!fir.type<_QFtest_derived_pointerTt>>)
258+
! CHECK: %[[VAL_21:.*]] = hlfir.as_expr %[[VAL_20]]#0 : (!fir.ptr<!fir.type<_QFtest_derived_pointerTt>>) -> !hlfir.expr<!fir.type<_QFtest_derived_pointerTt>>
255259
! CHECK: hlfir.assign %[[VAL_21]] to %[[VAL_13]]#0 realloc : !hlfir.expr<!fir.type<_QFtest_derived_pointerTt>>, !fir.ref<!fir.class<!fir.heap<!fir.type<_QFtest_derived_pointerTt>>>>
256260
! CHECK: hlfir.destroy %[[VAL_21]] : !hlfir.expr<!fir.type<_QFtest_derived_pointerTt>>
257261
! CHECK: return

flang/test/Lower/HLFIR/expr-as-inquired.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ subroutine test_lbound(x, n)
3333
! CHECK: %[[VAL_7:.*]] = arith.constant 3 : i64
3434
! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
3535
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %{{.*}}(%{{.*}}) {{.*}}Ex
36-
! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_4]]#1 : !fir.ref<i32>
36+
! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<i32>
3737
! CHECK: %[[VAL_12:.*]] = fir.shift %[[VAL_6]], %[[VAL_8]] : (index, index) -> !fir.shift<2>
3838
! CHECK: %[[VAL_13:.*]] = fir.rebox %[[VAL_10]]#1(%[[VAL_12]]) : (!fir.box<!fir.array<?x?xf32>>, !fir.shift<2>) -> !fir.box<!fir.array<?x?xf32>>
3939
! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_13]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.box<none>

flang/test/Lower/HLFIR/expr-value.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ subroutine foo()
1313
subroutine foo_designator(n)
1414
!CHECK: %[[n:.*]]:2 = hlfir.declare %[[arg0]] {uniq_name = "_QFfoo_designatorEn"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
1515
print *, n
16-
! CHECK: %[[nval:.*]] = fir.load %[[n]]#1 : !fir.ref<i32>
16+
! CHECK: %[[nval:.*]] = fir.load %[[n]]#0 : !fir.ref<i32>
1717
! CHECK: fir.call @_FortranAioOutputInteger32(%{{.*}}, %[[nval]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
1818
end subroutine

flang/test/Lower/HLFIR/forall.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ subroutine test_forall_step(step)
5252
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare {{.*}}Estep
5353
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare {{.*}}Ex
5454
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare {{.*}}Ey
55-
! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_4]]#1 : !fir.ref<i32>
55+
! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<i32>
5656
! CHECK: hlfir.forall lb {
5757
! CHECK: hlfir.yield %[[VAL_2]] : i32
5858
! CHECK: } ub {

0 commit comments

Comments
 (0)