[flang-commits] [flang] d1aa9ba - [flang] lower select rank (#93967)
via flang-commits
flang-commits at lists.llvm.org
Mon Jun 3 08:20:10 PDT 2024
Author: jeanPerier
Date: 2024-06-03T17:20:07+02:00
New Revision: d1aa9bac3c8ecc30fcc5d4d80a1f70c729aec909
URL: https://github.com/llvm/llvm-project/commit/d1aa9bac3c8ecc30fcc5d4d80a1f70c729aec909
DIFF: https://github.com/llvm/llvm-project/commit/d1aa9bac3c8ecc30fcc5d4d80a1f70c729aec909.diff
LOG: [flang] lower select rank (#93967)
Lower select rank according to [assumed-rank lowering design
doc](https://github.com/llvm/llvm-project/blob/main/flang/docs/AssumedRank.md).
The construct is lowered using fir.box_rank and fir.select_case
operation and, for the non pointer/allocatable case, a
fir.is_assumed_size + conditional branch before the select_case to deal
with the assumed-size case.
The way the CFG logic is generated, apart from the extra conditional
branch for assumed-size, is similar to what is done for SELECT CASE
lowering, hence the sharing of the construct level visitor.
For the CFG parts. The main difference is that we need to keep track of
the selector to cook it and map it inside the cases (hence the new
members of the ConstructContext).
The only TODOs left are to deal with the RANK(*) case for polymorphic
entities and PDTs. I will do the polymorphic case in a distinct patch,
this patch has enough content.
Fortran::evaluate::IsSimplyContiguous change is needed to avoid generating
copy-in/copy-out runtime calls when passing the RANK(*) associating
entity to some implicit interface.
Added:
flang/test/Lower/HLFIR/select-rank.f90
Modified:
flang/include/flang/Lower/ConvertExprToHLFIR.h
flang/lib/Evaluate/check-expression.cpp
flang/lib/Lower/Bridge.cpp
flang/lib/Optimizer/Builder/HLFIRTools.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Lower/ConvertExprToHLFIR.h b/flang/include/flang/Lower/ConvertExprToHLFIR.h
index dc0bde191354a..c64fb01b33ed9 100644
--- a/flang/include/flang/Lower/ConvertExprToHLFIR.h
+++ b/flang/include/flang/Lower/ConvertExprToHLFIR.h
@@ -41,12 +41,11 @@ convertExprToHLFIR(mlir::Location loc, Fortran::lower::AbstractConverter &,
const Fortran::lower::SomeExpr &, Fortran::lower::SymMap &,
Fortran::lower::StatementContext &);
-inline fir::ExtendedValue
-translateToExtendedValue(mlir::Location loc, fir::FirOpBuilder &builder,
- hlfir::Entity entity,
- Fortran::lower::StatementContext &context) {
+inline fir::ExtendedValue translateToExtendedValue(
+ mlir::Location loc, fir::FirOpBuilder &builder, hlfir::Entity entity,
+ Fortran::lower::StatementContext &context, bool contiguityHint = false) {
auto [exv, exvCleanup] =
- hlfir::translateToExtendedValue(loc, builder, entity);
+ hlfir::translateToExtendedValue(loc, builder, entity, contiguityHint);
if (exvCleanup)
context.attachCleanup(*exvCleanup);
return exv;
diff --git a/flang/lib/Evaluate/check-expression.cpp b/flang/lib/Evaluate/check-expression.cpp
index 7e42db7b6ed7a..068514b514215 100644
--- a/flang/lib/Evaluate/check-expression.cpp
+++ b/flang/lib/Evaluate/check-expression.cpp
@@ -801,8 +801,14 @@ class IsContiguousHelper
// simple contiguity to allow their use in contexts like
// data targets in pointer assignments with remapping.
return true;
- } else if (ultimate.has<semantics::AssocEntityDetails>()) {
- return Base::operator()(ultimate); // use expr
+ } else if (const auto *details{
+ ultimate.detailsIf<semantics::AssocEntityDetails>()}) {
+ // RANK(*) associating entity is contiguous.
+ if (details->IsAssumedSize()) {
+ return true;
+ } else {
+ return Base::operator()(ultimate); // use expr
+ }
} else if (semantics::IsPointer(ultimate) ||
semantics::IsAssumedShape(ultimate) || IsAssumedRank(ultimate)) {
return std::nullopt;
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 63ef60710ddfe..17b46efc6a2ab 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -141,6 +141,8 @@ struct ConstructContext {
Fortran::lower::pft::Evaluation &eval; // construct eval
Fortran::lower::StatementContext &stmtCtx; // construct exit code
+ std::optional<hlfir::Entity> selector; // construct selector, if any.
+ bool pushedScope = false; // was a scoped pushed for this construct?
};
/// Helper class to generate the runtime type info global data and the
@@ -1468,6 +1470,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void popActiveConstruct() {
assert(!activeConstructStack.empty() && "invalid active construct stack");
activeConstructStack.back().eval.activeConstruct = false;
+ if (activeConstructStack.back().pushedScope)
+ localSymbols.popScope();
activeConstructStack.pop_back();
}
@@ -2181,7 +2185,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
}
- void genFIR(const Fortran::parser::CaseConstruct &) {
+ void genCaseOrRankConstruct() {
Fortran::lower::pft::Evaluation &eval = getEval();
Fortran::lower::StatementContext stmtCtx;
pushActiveConstruct(eval, stmtCtx);
@@ -2203,6 +2207,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
popActiveConstruct();
}
+ void genFIR(const Fortran::parser::CaseConstruct &) {
+ genCaseOrRankConstruct();
+ }
template <typename A>
void genNestedStatement(const Fortran::parser::Statement<A> &stmt) {
@@ -3032,13 +3039,198 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void genFIR(const Fortran::parser::SelectRankConstruct &selectRankConstruct) {
setCurrentPositionAt(selectRankConstruct);
- TODO(toLocation(), "coarray: SelectRankConstruct");
+ genCaseOrRankConstruct();
}
- void genFIR(const Fortran::parser::SelectRankStmt &) {
- TODO(toLocation(), "coarray: SelectRankStmt");
+
+ void genFIR(const Fortran::parser::SelectRankStmt &selectRankStmt) {
+ // Generate a fir.select_case with the selector rank. The RANK(*) case,
+ // if any, is handles with a conditional branch before the fir.select_case.
+ mlir::Type rankType = builder->getIntegerType(8);
+ mlir::MLIRContext *context = builder->getContext();
+ mlir::Location loc = toLocation();
+ // Build block list for fir.select_case, and identify RANK(*) block, if any.
+ // Default block must be placed last in the fir.select_case block list.
+ mlir::Block *rankStarBlock = nullptr;
+ Fortran::lower::pft::Evaluation &eval = getEval();
+ mlir::Block *defaultBlock = eval.parentConstruct->constructExit->block;
+ llvm::SmallVector<mlir::Attribute> attrList;
+ llvm::SmallVector<mlir::Value> valueList;
+ llvm::SmallVector<mlir::Block *> blockList;
+ for (Fortran::lower::pft::Evaluation *e = eval.controlSuccessor; e;
+ e = e->controlSuccessor) {
+ if (const auto *rankCaseStmt =
+ e->getIf<Fortran::parser::SelectRankCaseStmt>()) {
+ const auto &rank = std::get<Fortran::parser::SelectRankCaseStmt::Rank>(
+ rankCaseStmt->t);
+ assert(e->block && "missing SelectRankCaseStmt block");
+ std::visit(
+ Fortran::common::visitors{
+ [&](const Fortran::parser::ScalarIntConstantExpr &rankExpr) {
+ blockList.emplace_back(e->block);
+ attrList.emplace_back(fir::PointIntervalAttr::get(context));
+ std::optional<std::int64_t> rankCst =
+ Fortran::evaluate::ToInt64(
+ Fortran::semantics::GetExpr(rankExpr));
+ assert(rankCst.has_value() &&
+ "rank expr must be constant integer");
+ valueList.emplace_back(
+ builder->createIntegerConstant(loc, rankType, *rankCst));
+ },
+ [&](const Fortran::parser::Star &) {
+ rankStarBlock = e->block;
+ },
+ [&](const Fortran::parser::Default &) {
+ defaultBlock = e->block;
+ }},
+ rank.u);
+ }
+ }
+ attrList.push_back(mlir::UnitAttr::get(context));
+ blockList.push_back(defaultBlock);
+
+ // Lower selector.
+ assert(!activeConstructStack.empty() && "must be inside construct");
+ assert(!activeConstructStack.back().selector &&
+ "selector should not yet be set");
+ Fortran::lower::StatementContext &stmtCtx =
+ activeConstructStack.back().stmtCtx;
+ const Fortran::lower::SomeExpr *selectorExpr =
+ std::visit([](const auto &x) { return Fortran::semantics::GetExpr(x); },
+ std::get<Fortran::parser::Selector>(selectRankStmt.t).u);
+ assert(selectorExpr && "failed to retrieve selector expr");
+ hlfir::Entity selector = Fortran::lower::convertExprToHLFIR(
+ loc, *this, *selectorExpr, localSymbols, stmtCtx);
+ activeConstructStack.back().selector = selector;
+
+ // Deal with assumed-size first. They must fall into RANK(*) if present, or
+ // the default case (F'2023 11.1.10.2.). The selector cannot be an
+ // assumed-size if it is allocatable or pointer, so the check is skipped.
+ if (!Fortran::evaluate::IsAllocatableOrPointerObject(*selectorExpr)) {
+ mlir::Value isAssumedSize = builder->create<fir::IsAssumedSizeOp>(
+ loc, builder->getI1Type(), selector);
+ // Create new block to hold the fir.select_case for the non assumed-size
+ // cases.
+ mlir::Block *selectCaseBlock = insertBlock(blockList[0]);
+ mlir::Block *assumedSizeBlock =
+ rankStarBlock ? rankStarBlock : defaultBlock;
+ builder->create<mlir::cf::CondBranchOp>(loc, isAssumedSize,
+ assumedSizeBlock, std::nullopt,
+ selectCaseBlock, std::nullopt);
+ startBlock(selectCaseBlock);
+ }
+ // Create fir.select_case for the other rank cases.
+ mlir::Value rank = builder->create<fir::BoxRankOp>(loc, rankType, selector);
+ stmtCtx.finalizeAndReset();
+ builder->create<fir::SelectCaseOp>(loc, rank, attrList, valueList,
+ blockList);
+ }
+
+ // Get associating entity symbol inside case statement scope.
+ static const Fortran::semantics::Symbol &
+ getAssociatingEntitySymbol(const Fortran::semantics::Scope &scope) {
+ const Fortran::semantics::Symbol *assocSym = nullptr;
+ for (const auto &sym : scope.GetSymbols()) {
+ if (sym->has<Fortran::semantics::AssocEntityDetails>()) {
+ assert(!assocSym &&
+ "expect only one associating entity symbol in this scope");
+ assocSym = &*sym;
+ }
+ }
+ assert(assocSym && "should contain associating entity symbol");
+ return *assocSym;
}
- void genFIR(const Fortran::parser::SelectRankCaseStmt &) {
- TODO(toLocation(), "coarray: SelectRankCaseStmt");
+
+ void genFIR(const Fortran::parser::SelectRankCaseStmt &stmt) {
+ assert(!activeConstructStack.empty() &&
+ "must be inside select rank construct");
+ // Pop previous associating entity mapping, if any, and push scope for new
+ // mapping.
+ if (activeConstructStack.back().pushedScope)
+ localSymbols.popScope();
+ localSymbols.pushScope();
+ activeConstructStack.back().pushedScope = true;
+ const Fortran::semantics::Symbol &assocEntitySymbol =
+ getAssociatingEntitySymbol(
+ bridge.getSemanticsContext().FindScope(getEval().position));
+ const auto &details =
+ assocEntitySymbol.get<Fortran::semantics::AssocEntityDetails>();
+ assert(!activeConstructStack.empty() &&
+ activeConstructStack.back().selector.has_value() &&
+ "selector must have been created");
+ // Get lowered value for the selector.
+ hlfir::Entity selector = *activeConstructStack.back().selector;
+ assert(selector.isVariable() && "assumed-rank selector are variables");
+ // Cook selector mlir::Value according to rank case and map it to
+ // associating entity symbol.
+ Fortran::lower::StatementContext stmtCtx;
+ mlir::Location loc = toLocation();
+ if (details.IsAssumedRank()) {
+ fir::ExtendedValue selectorExv = Fortran::lower::translateToExtendedValue(
+ loc, *builder, selector, stmtCtx);
+ addSymbol(assocEntitySymbol, selectorExv);
+ } else if (details.IsAssumedSize()) {
+ // Create rank-1 assumed-size from descriptor. Assumed-size are contiguous
+ // so a new entity can be built from scratch using the base address, type
+ // parameters and dynamic type. The selector cannot be a
+ // POINTER/ALLOCATBLE as per F'2023 C1160.
+ fir::ExtendedValue newExv;
+ llvm::SmallVector assumeSizeExtents{
+ builder->createMinusOneInteger(loc, builder->getIndexType())};
+ mlir::Value baseAddr =
+ hlfir::genVariableRawAddress(loc, *builder, selector);
+ mlir::Type eleType =
+ fir::unwrapSequenceType(fir::unwrapRefType(baseAddr.getType()));
+ mlir::Type rank1Type =
+ fir::ReferenceType::get(builder->getVarLenSeqTy(eleType, 1));
+ baseAddr = builder->createConvert(loc, rank1Type, baseAddr);
+ if (selector.isCharacter()) {
+ mlir::Value len = hlfir::genCharLength(loc, *builder, selector);
+ newExv = fir::CharArrayBoxValue{baseAddr, len, assumeSizeExtents};
+ } else if (selector.isDerivedWithLengthParameters()) {
+ TODO(loc, "RANK(*) with parameterized derived type selector");
+ } else if (selector.isPolymorphic()) {
+ TODO(loc, "RANK(*) with polymorphic selector");
+ } else {
+ // Simple intrinsic or derived type.
+ newExv = fir::ArrayBoxValue{baseAddr, assumeSizeExtents};
+ }
+ addSymbol(assocEntitySymbol, newExv);
+ } else {
+ int rank = details.rank().value();
+ auto boxTy =
+ mlir::cast<fir::BaseBoxType>(fir::unwrapRefType(selector.getType()));
+ mlir::Type newBoxType = boxTy.getBoxTypeWithNewShape(rank);
+ if (fir::isa_ref_type(selector.getType()))
+ newBoxType = fir::ReferenceType::get(newBoxType);
+ // Give rank info to value via cast, and get rid of the box if not needed
+ // (simple scalars, contiguous arrays... This is done by
+ // translateVariableToExtendedValue).
+ hlfir::Entity rankedBox{
+ builder->createConvert(loc, newBoxType, selector)};
+ bool isSimplyContiguous = Fortran::evaluate::IsSimplyContiguous(
+ assocEntitySymbol, getFoldingContext());
+ fir::ExtendedValue newExv = Fortran::lower::translateToExtendedValue(
+ loc, *builder, rankedBox, stmtCtx, isSimplyContiguous);
+
+ // Non deferred length parameters of character allocatable/pointer
+ // MutableBoxValue should be properly set before binding it to a symbol in
+ // order to get correct assignment semantics.
+ if (const fir::MutableBoxValue *mutableBox =
+ newExv.getBoxOf<fir::MutableBoxValue>()) {
+ if (selector.isCharacter()) {
+ auto dynamicType =
+ Fortran::evaluate::DynamicType::From(assocEntitySymbol);
+ if (!dynamicType.value().HasDeferredTypeParameter()) {
+ llvm::SmallVector<mlir::Value> lengthParams;
+ hlfir::genLengthParameters(loc, *builder, selector, lengthParams);
+ newExv = fir::MutableBoxValue{rankedBox, lengthParams,
+ mutableBox->getMutableProperties()};
+ }
+ }
+ }
+ addSymbol(assocEntitySymbol, newExv);
+ }
+ // Statements inside rank case are lowered by SelectRankConstruct visit.
}
void genFIR(const Fortran::parser::SelectTypeConstruct &selectTypeConstruct) {
diff --git a/flang/lib/Optimizer/Builder/HLFIRTools.cpp b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
index b80fcccfddef9..31e2c4082b32c 100644
--- a/flang/lib/Optimizer/Builder/HLFIRTools.cpp
+++ b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
@@ -115,6 +115,8 @@ genLboundsAndExtentsFromBox(mlir::Location loc, fir::FirOpBuilder &builder,
static llvm::SmallVector<mlir::Value>
getNonDefaultLowerBounds(mlir::Location loc, fir::FirOpBuilder &builder,
hlfir::Entity entity) {
+ assert(!entity.isAssumedRank() &&
+ "cannot compute assumed rank bounds statically");
if (!entity.mayHaveNonDefaultLowerBounds())
return {};
if (auto varIface = entity.getIfVariableInterface()) {
@@ -889,11 +891,14 @@ static fir::ExtendedValue translateVariableToExtendedValue(
fir::MutableProperties{});
if (mlir::isa<fir::BaseBoxType>(base.getType())) {
- bool contiguous = variable.isSimplyContiguous() || contiguousHint;
+ const bool contiguous = variable.isSimplyContiguous() || contiguousHint;
+ const bool isAssumedRank = variable.isAssumedRank();
if (!contiguous || variable.isPolymorphic() ||
- variable.isDerivedWithLengthParameters() || variable.isOptional()) {
- llvm::SmallVector<mlir::Value> nonDefaultLbounds =
- getNonDefaultLowerBounds(loc, builder, variable);
+ variable.isDerivedWithLengthParameters() || variable.isOptional() ||
+ isAssumedRank) {
+ llvm::SmallVector<mlir::Value> nonDefaultLbounds;
+ if (!isAssumedRank)
+ nonDefaultLbounds = getNonDefaultLowerBounds(loc, builder, variable);
return fir::BoxValue(base, nonDefaultLbounds,
getExplicitTypeParams(variable));
}
diff --git a/flang/test/Lower/HLFIR/select-rank.f90 b/flang/test/Lower/HLFIR/select-rank.f90
new file mode 100644
index 0000000000000..84987531f1419
--- /dev/null
+++ b/flang/test/Lower/HLFIR/select-rank.f90
@@ -0,0 +1,826 @@
+! Test lowering of select rank to HLFIR
+! RUN: bbc -emit-hlfir -o - %s -allow-assumed-rank | FileCheck %s
+
+module iface_helpers
+interface
+ subroutine r0(x)
+ real :: x
+ end subroutine
+ subroutine r1(x)
+ real :: x(:)
+ end subroutine
+ subroutine r2(x)
+ real :: x(:, :)
+ end subroutine
+ subroutine r15(x)
+ real :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:)
+ end subroutine
+ subroutine rdefault(x)
+ real :: x(..)
+ end subroutine
+ subroutine rcdefault(x)
+ character(*) :: x(..)
+ end subroutine
+ subroutine rassumed_size(x)
+ real :: x(*)
+ end subroutine
+
+ subroutine ra0(x)
+ real, allocatable :: x
+ end subroutine
+ subroutine ra1(x)
+ real, allocatable :: x(:)
+ end subroutine
+ subroutine ra2(x)
+ real, allocatable :: x(:, :)
+ end subroutine
+ subroutine ra15(x)
+ real, allocatable :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:)
+ end subroutine
+ subroutine radefault(x)
+ real, allocatable :: x(..)
+ end subroutine
+
+ subroutine rup0(x)
+ class(*) :: x
+ end subroutine
+ subroutine rup1(x)
+ class(*) :: x(:)
+ end subroutine
+ subroutine rupdefault(x)
+ class(*) :: x(..)
+ end subroutine
+
+end interface
+end module
+
+subroutine test_single_case(x)
+ use iface_helpers
+ real :: x(..)
+ select rank (x)
+ rank (1)
+ call r1(x)
+ end select
+end subroutine
+
+subroutine test_simple_case(x)
+ use iface_helpers
+ real :: x(..)
+ select rank (x)
+ rank default
+ call rdefault(x)
+ rank (1)
+ call r1(x)
+ rank (15)
+ call r15(x)
+ rank (0)
+ call r0(x)
+ end select
+end subroutine
+
+subroutine test_rank_star(x)
+ use iface_helpers
+ real :: x(..)
+ select rank (x)
+ rank (2)
+ call r2(x)
+ rank default
+ call rdefault(x)
+ rank (1)
+ call r1(x)
+ rank (*)
+ ! test no copy in/out is generated here.
+ call rassumed_size(x)
+ end select
+end subroutine
+
+
+subroutine test_renaming(x)
+ use iface_helpers
+ real :: x(..)
+ select rank (new_name => x)
+ rank (1)
+ call r1(new_name)
+ call rdefault(x)
+ end select
+end subroutine
+
+subroutine test_no_case(x)
+ real :: x(..)
+ select rank (x)
+ end select
+end subroutine
+
+subroutine test_rank_star_attributes(x)
+ use iface_helpers
+ real, optional, asynchronous, target :: x(..)
+ ! The declare generated for the associating entity should have the
+ ! TARGET and ASYNCHRONOUS attribute, but not the OPTIONAL attribute.
+ ! F'2023 11.1.3.3 and 11.1.10.3.
+ select rank (x)
+ rank (2)
+ call r2(x)
+ rank default
+ call rdefault(x)
+ rank (*)
+ call rassumed_size(x)
+ end select
+end subroutine
+
+subroutine test_rank_star_contiguous(x)
+ use iface_helpers
+ real, target, contiguous :: x(..)
+ ! Test simple hlfir.declare without fir.box are generated for
+ ! ranked case and that non copy-in/out is generated when passing
+ ! associating entity to implicit interfaces.
+ select rank (x)
+ rank (2)
+ call r2_implicit(x)
+ rank default
+ ! TODO: hlfir.declare could be given the CONTIGUOUS attribute.
+ call rdefault(x)
+ rank (1)
+ call r1_implicit(x)
+ rank (*)
+ call r1_implicit(x)
+ end select
+end subroutine
+
+subroutine test_rank_star_contiguous_character(x, n)
+ use iface_helpers
+ integer(8) :: n
+ character(n), contiguous :: x(..)
+ select rank (x)
+ ! test fir.box is properly converted to fir.boxchar in the hlfir.declare
+ ! for the associating entity.
+ rank (0)
+ call rc0_implicit(x)
+ rank default
+ call rcdefault(x)
+ rank (1)
+ call rc1_implicit(x)
+ rank (*)
+ call rc1_implicit(x)
+ end select
+end subroutine
+
+subroutine test_simple_alloc(x)
+ use iface_helpers
+ real, allocatable :: x(..)
+ ! test no is_assumed_size if generated and that associating entity
+ ! hlfir.declare has allocatable attrbute.
+ select rank (x)
+ rank (2)
+ call ra2(x)
+ rank (0)
+ call ra0(x)
+ rank default
+ call radefault(x)
+ rank (1)
+ call ra1(x)
+ end select
+end subroutine
+
+subroutine test_character_alloc(x)
+ character(:), allocatable :: x(..)
+ ! test hlfir.declare for associating entities do not not have
+ ! explicit type parameters.
+ select rank (x)
+ rank default
+ rank (1)
+ end select
+end subroutine
+
+subroutine test_explicit_character_ptr(x, n)
+ use iface_helpers
+ integer(8) :: n
+ character(n), allocatable :: x(..)
+ ! test hlfir.declare for associating entities have
+ ! explicit type parameters.
+ select rank (x)
+ rank default
+ rank (0)
+ end select
+end subroutine
+
+subroutine test_assumed_character_ptr(x)
+ use iface_helpers
+ character(*), allocatable :: x(..)
+ ! test hlfir.declare for associating entities have
+ ! explicit type parameters.
+ select rank (x)
+ rank default
+ rank (0)
+ end select
+end subroutine
+
+subroutine test_polymorphic(x)
+ use iface_helpers
+ class(*) :: x(..)
+ select rank (x)
+ rank (1)
+ call rup1(x)
+ rank default
+ call rupdefault(x)
+ rank (0)
+ call rup0(x)
+ end select
+end subroutine
+
+subroutine test_nested_select_rank(x1, x2)
+ use iface_helpers
+ real :: x1(..), x2(..)
+ select rank(x1)
+ rank(0)
+ select rank(x2)
+ rank(0)
+ call r0(x1)
+ call r0(x2)
+ rank(1)
+ call r0(x1)
+ call r1(x2)
+ rank default
+ call r0(x1)
+ call rdefault(x2)
+ end select
+ rank(1)
+ select rank(x2)
+ rank(0)
+ call r1(x1)
+ call r0(x2)
+ rank(1)
+ call r1(x1)
+ call r1(x2)
+ rank default
+ call r1(x1)
+ call rdefault(x2)
+ end select
+ rank default
+ select rank(x2)
+ rank(0)
+ call rdefault(x1)
+ call r0(x2)
+ rank(1)
+ call rdefault(x1)
+ call r1(x2)
+ rank default
+ call rdefault(x1)
+ call rdefault(x2)
+ end select
+ end select
+end subroutine
+
+subroutine test_branching(x)
+! Note branching into a select rank, or between cases, is illegal
+! and caught by semantics.
+ use iface_helpers
+ real :: x(..)
+ logical, external :: leave_now
+ logical, external :: jump
+ select rank (x)
+ rank default
+ if (jump()) goto 1
+ call one()
+1 call rdefault(x)
+ rank (1)
+ if (leave_now()) goto 3
+ call r1(x)
+ rank (2)
+ end select
+3 call the_end()
+end subroutine
+
+! CHECK-LABEL: func.func @_QPtest_single_case(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_single_caseEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_4:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_4]], ^bb3, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_5:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_5]] : i8 [#fir.point, %[[VAL_3]], ^bb2, unit, ^bb3]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] {uniq_name = "_QFtest_single_caseEx"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr1(%[[VAL_7]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb3
+! CHECK: ^bb3:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_simple_case(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_simple_caseEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_4:.*]] = arith.constant 15 : i8
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_6:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_6]], ^bb1, ^bb2
+! CHECK: ^bb1:
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {uniq_name = "_QFtest_simple_caseEx"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: fir.call @_QPrdefault(%[[VAL_7]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb2:
+! CHECK: %[[VAL_8:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_8]] : i8 [#fir.point, %[[VAL_3]], ^bb3, #fir.point, %[[VAL_4]], ^bb4, #fir.point, %[[VAL_5]], ^bb5, unit, ^bb1]
+! CHECK: ^bb3:
+! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_9]] {uniq_name = "_QFtest_simple_caseEx"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr1(%[[VAL_10]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb4:
+! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?x?x?x?x?x?x?x?x?x?x?x?x?x?x?xf32>>
+! CHECK: %[[VAL_12:.*]]:2 = hlfir.declare %[[VAL_11]] {uniq_name = "_QFtest_simple_caseEx"} : (!fir.box<!fir.array<?x?x?x?x?x?x?x?x?x?x?x?x?x?x?xf32>>) -> (!fir.box<!fir.array<?x?x?x?x?x?x?x?x?x?x?x?x?x?x?xf32>>, !fir.box<!fir.array<?x?x?x?x?x?x?x?x?x?x?x?x?x?x?xf32>>)
+! CHECK: fir.call @_QPr15(%[[VAL_12]]#0) fastmath<contract> : (!fir.box<!fir.array<?x?x?x?x?x?x?x?x?x?x?x?x?x?x?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb5:
+! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<f32>
+! CHECK: %[[VAL_14:.*]] = fir.box_addr %[[VAL_13]] : (!fir.box<f32>) -> !fir.ref<f32>
+! CHECK: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_14]] {uniq_name = "_QFtest_simple_caseEx"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+! CHECK: fir.call @_QPr0(%[[VAL_15]]#1) fastmath<contract> : (!fir.ref<f32>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb6:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_rank_star(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_rank_starEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 2 : i8
+! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_5:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_5]], ^bb5, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_6:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_6]] : i8 [#fir.point, %[[VAL_3]], ^bb2, #fir.point, %[[VAL_4]], ^bb4, unit, ^bb3]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?x?xf32>>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_7]] {uniq_name = "_QFtest_rank_starEx"} : (!fir.box<!fir.array<?x?xf32>>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.box<!fir.array<?x?xf32>>)
+! CHECK: fir.call @_QPr2(%[[VAL_8]]#0) fastmath<contract> : (!fir.box<!fir.array<?x?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb3:
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {uniq_name = "_QFtest_rank_starEx"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: fir.call @_QPrdefault(%[[VAL_9]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb4:
+! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFtest_rank_starEx"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr1(%[[VAL_11]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb5:
+! CHECK: %[[VAL_12:.*]] = arith.constant -1 : index
+! CHECK: %[[VAL_13:.*]] = fir.box_addr %[[VAL_2]]#1 : (!fir.box<!fir.array<*:f32>>) -> !fir.ref<!fir.array<*:f32>>
+! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.array<*:f32>>) -> !fir.ref<!fir.array<?xf32>>
+! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_12]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_14]](%[[VAL_15]]) {uniq_name = "_QFtest_rank_starEx"} : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.ref<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPrassumed_size(%[[VAL_16]]#1) fastmath<contract> : (!fir.ref<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb6:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_renaming(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_renamingEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_4:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_4]], ^bb3, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_5:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_5]] : i8 [#fir.point, %[[VAL_3]], ^bb2, unit, ^bb3]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] {uniq_name = "_QFtest_renamingEnew_name"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr1(%[[VAL_7]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: fir.call @_QPrdefault(%[[VAL_2]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb3
+! CHECK: ^bb3:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_no_case(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_no_caseEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_3]], ^bb2, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_4:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_4]] : i8 [unit, ^bb2]
+! CHECK: ^bb2:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_rank_star_attributes(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x", fir.optional, fir.target}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<asynchronous, optional, target>, uniq_name = "_QFtest_rank_star_attributesEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 2 : i8
+! CHECK: %[[VAL_4:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_4]], ^bb4, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_5:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_5]] : i8 [#fir.point, %[[VAL_3]], ^bb2, unit, ^bb3]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?x?xf32>>
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] {fortran_attrs = #fir.var_attrs<asynchronous, target>, uniq_name = "_QFtest_rank_star_attributesEx"} : (!fir.box<!fir.array<?x?xf32>>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.box<!fir.array<?x?xf32>>)
+! CHECK: fir.call @_QPr2(%[[VAL_7]]#0) fastmath<contract> : (!fir.box<!fir.array<?x?xf32>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb3:
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {fortran_attrs = #fir.var_attrs<asynchronous, target>, uniq_name = "_QFtest_rank_star_attributesEx"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: fir.call @_QPrdefault(%[[VAL_8]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb4:
+! CHECK: %[[VAL_9:.*]] = arith.constant -1 : index
+! CHECK: %[[VAL_10:.*]] = fir.box_addr %[[VAL_2]]#1 : (!fir.box<!fir.array<*:f32>>) -> !fir.ref<!fir.array<*:f32>>
+! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref<!fir.array<*:f32>>) -> !fir.ref<!fir.array<?xf32>>
+! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_9]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_11]](%[[VAL_12]]) {fortran_attrs = #fir.var_attrs<asynchronous, target>, uniq_name = "_QFtest_rank_star_attributesEx"} : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.ref<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPrassumed_size(%[[VAL_13]]#1) fastmath<contract> : (!fir.ref<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb5:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_rank_star_contiguous(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x", fir.contiguous, fir.target}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<contiguous, target>, uniq_name = "_QFtest_rank_star_contiguousEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 2 : i8
+! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_5:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_5]], ^bb5, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_6:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_6]] : i8 [#fir.point, %[[VAL_3]], ^bb2, #fir.point, %[[VAL_4]], ^bb4, unit, ^bb3]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?x?xf32>>
+! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_7]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.ref<!fir.array<?x?xf32>>
+! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_7]], %[[VAL_9]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
+! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
+! CHECK: %[[VAL_12:.*]]:3 = fir.box_dims %[[VAL_7]], %[[VAL_11]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
+! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
+! CHECK: %[[VAL_14:.*]]:2 = hlfir.declare %[[VAL_8]](%[[VAL_13]]) {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtest_rank_star_contiguousEx"} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.array<?x?xf32>>)
+! CHECK: fir.call @_QPr2_implicit(%[[VAL_14]]#1) fastmath<contract> : (!fir.ref<!fir.array<?x?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb3:
+! CHECK: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtest_rank_star_contiguousEx"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: fir.call @_QPrdefault(%[[VAL_15]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb4:
+! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_17:.*]] = fir.box_addr %[[VAL_16]] : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<!fir.array<?xf32>>
+! CHECK: %[[VAL_18:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_19:.*]]:3 = fir.box_dims %[[VAL_16]], %[[VAL_18]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
+! CHECK: %[[VAL_20:.*]] = fir.shape %[[VAL_19]]#1 : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_21:.*]]:2 = hlfir.declare %[[VAL_17]](%[[VAL_20]]) {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtest_rank_star_contiguousEx"} : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.ref<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr1_implicit(%[[VAL_21]]#1) fastmath<contract> : (!fir.ref<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb5:
+! CHECK: %[[VAL_22:.*]] = arith.constant -1 : index
+! CHECK: %[[VAL_23:.*]] = fir.box_addr %[[VAL_2]]#1 : (!fir.box<!fir.array<*:f32>>) -> !fir.ref<!fir.array<*:f32>>
+! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (!fir.ref<!fir.array<*:f32>>) -> !fir.ref<!fir.array<?xf32>>
+! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_22]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_24]](%[[VAL_25]]) {fortran_attrs = #fir.var_attrs<target>, uniq_name = "_QFtest_rank_star_contiguousEx"} : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.ref<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr1_implicit(%[[VAL_26]]#1) fastmath<contract> : (!fir.ref<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb6:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_rank_star_contiguous_character(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:!fir.char<1,?>>> {fir.bindc_name = "x", fir.contiguous},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i64> {fir.bindc_name = "n"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_rank_star_contiguous_characterEn"} : (!fir.ref<i64>, !fir.dscope) -> (!fir.ref<i64>, !fir.ref<i64>)
+! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i64>
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
+! CHECK: %[[VAL_6:.*]] = arith.cmpi sgt, %[[VAL_4]], %[[VAL_5]] : i64
+! CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_6]], %[[VAL_4]], %[[VAL_5]] : i64
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_7]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<contiguous>, uniq_name = "_QFtest_rank_star_contiguous_characterEx"} : (!fir.box<!fir.array<*:!fir.char<1,?>>>, i64, !fir.dscope) -> (!fir.box<!fir.array<*:!fir.char<1,?>>>, !fir.box<!fir.array<*:!fir.char<1,?>>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_11:.*]] = fir.is_assumed_size %[[VAL_8]]#0 : (!fir.box<!fir.array<*:!fir.char<1,?>>>) -> i1
+! CHECK: cf.cond_br %[[VAL_11]], ^bb5, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_12:.*]] = fir.box_rank %[[VAL_8]]#0 : (!fir.box<!fir.array<*:!fir.char<1,?>>>) -> i8
+! CHECK: fir.select_case %[[VAL_12]] : i8 [#fir.point, %[[VAL_9]], ^bb2, #fir.point, %[[VAL_10]], ^bb4, unit, ^bb3]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_8]]#0 : (!fir.box<!fir.array<*:!fir.char<1,?>>>) -> !fir.box<!fir.char<1,?>>
+! CHECK: %[[VAL_14:.*]] = fir.box_addr %[[VAL_13]] : (!fir.box<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,?>>
+! CHECK: %[[VAL_15:.*]] = fir.box_elesize %[[VAL_13]] : (!fir.box<!fir.char<1,?>>) -> index
+! CHECK: %[[VAL_16:.*]]:2 = hlfir.declare %[[VAL_14]] typeparams %[[VAL_15]] {uniq_name = "_QFtest_rank_star_contiguous_characterEx"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
+! CHECK: fir.call @_QPrc0_implicit(%[[VAL_16]]#0) fastmath<contract> : (!fir.boxchar<1>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb3:
+! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_8]]#1 typeparams %[[VAL_7]] {uniq_name = "_QFtest_rank_star_contiguous_characterEx"} : (!fir.box<!fir.array<*:!fir.char<1,?>>>, i64) -> (!fir.box<!fir.array<*:!fir.char<1,?>>>, !fir.box<!fir.array<*:!fir.char<1,?>>>)
+! CHECK: fir.call @_QPrcdefault(%[[VAL_17]]#0) fastmath<contract> : (!fir.box<!fir.array<*:!fir.char<1,?>>>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb4:
+! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_8]]#0 : (!fir.box<!fir.array<*:!fir.char<1,?>>>) -> !fir.box<!fir.array<?x!fir.char<1,?>>>
+! CHECK: %[[VAL_19:.*]] = fir.box_addr %[[VAL_18]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
+! CHECK: %[[VAL_20:.*]] = arith.constant 0 : index
+! CHECK: %[[VAL_21:.*]]:3 = fir.box_dims %[[VAL_18]], %[[VAL_20]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>, index) -> (index, index, index)
+! CHECK: %[[VAL_22:.*]] = fir.box_elesize %[[VAL_18]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
+! CHECK: %[[VAL_23:.*]] = fir.shape %[[VAL_21]]#1 : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_24:.*]]:2 = hlfir.declare %[[VAL_19]](%[[VAL_23]]) typeparams %[[VAL_22]] {uniq_name = "_QFtest_rank_star_contiguous_characterEx"} : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> (!fir.box<!fir.array<?x!fir.char<1,?>>>, !fir.ref<!fir.array<?x!fir.char<1,?>>>)
+! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_24]]#1 : (!fir.ref<!fir.array<?x!fir.char<1,?>>>) -> !fir.ref<!fir.char<1,?>>
+! CHECK: %[[VAL_26:.*]] = fir.emboxchar %[[VAL_25]], %[[VAL_22]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
+! CHECK: fir.call @_QPrc1_implicit(%[[VAL_26]]) fastmath<contract> : (!fir.boxchar<1>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb5:
+! CHECK: %[[VAL_27:.*]] = arith.constant -1 : index
+! CHECK: %[[VAL_28:.*]] = fir.box_addr %[[VAL_8]]#1 : (!fir.box<!fir.array<*:!fir.char<1,?>>>) -> !fir.ref<!fir.array<*:!fir.char<1,?>>>
+! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.array<*:!fir.char<1,?>>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
+! CHECK: %[[VAL_30:.*]] = fir.shape %[[VAL_27]] : (index) -> !fir.shape<1>
+! CHECK: %[[VAL_31:.*]]:2 = hlfir.declare %[[VAL_29]](%[[VAL_30]]) typeparams %[[VAL_7]] {uniq_name = "_QFtest_rank_star_contiguous_characterEx"} : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, i64) -> (!fir.box<!fir.array<?x!fir.char<1,?>>>, !fir.ref<!fir.array<?x!fir.char<1,?>>>)
+! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_31]]#1 : (!fir.ref<!fir.array<?x!fir.char<1,?>>>) -> !fir.ref<!fir.char<1,?>>
+! CHECK: %[[VAL_33:.*]] = fir.emboxchar %[[VAL_32]], %[[VAL_7]] : (!fir.ref<!fir.char<1,?>>, i64) -> !fir.boxchar<1>
+! CHECK: fir.call @_QPrc1_implicit(%[[VAL_33]]) fastmath<contract> : (!fir.boxchar<1>) -> ()
+! CHECK: cf.br ^bb6
+! CHECK: ^bb6:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_simple_alloc(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_simple_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 2 : i8
+! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i8
+! CHECK-NOT: fir.is_assumed_size
+! CHECK: %[[VAL_6:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> i8
+! CHECK: fir.select_case %[[VAL_6]] : i8 [#fir.point, %[[VAL_3]], ^bb1, #fir.point, %[[VAL_4]], ^bb2, #fir.point, %[[VAL_5]], ^bb4, unit, ^bb3]
+! CHECK: ^bb1:
+! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_7]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_simple_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>)
+! CHECK: fir.call @_QPra2(%[[VAL_8]]#0) fastmath<contract> : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb2:
+! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> !fir.ref<!fir.box<!fir.heap<f32>>>
+! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_9]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_simple_allocEx"} : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> (!fir.ref<!fir.box<!fir.heap<f32>>>, !fir.ref<!fir.box<!fir.heap<f32>>>)
+! CHECK: fir.call @_QPra0(%[[VAL_10]]#0) fastmath<contract> : (!fir.ref<!fir.box<!fir.heap<f32>>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb3:
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_simple_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>)
+! CHECK: fir.call @_QPradefault(%[[VAL_11]]#0) fastmath<contract> : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb4:
+! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:f32>>>>) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
+! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_simple_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>)
+! CHECK: fir.call @_QPra1(%[[VAL_13]]#0) fastmath<contract> : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb5:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_character_alloc(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_character_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_4:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>) -> i8
+! CHECK: fir.select_case %[[VAL_4]] : i8 [#fir.point, %[[VAL_3]], ^bb2, unit, ^bb1]
+! CHECK: ^bb1:
+! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_character_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>)
+! CHECK: cf.br ^bb3
+! CHECK: ^bb2:
+! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
+! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>
+! CHECK: %[[VAL_8:.*]] = fir.box_elesize %[[VAL_7]] : (!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>) -> index
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_6]] typeparams %[[VAL_8]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_character_allocEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>, index) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>)
+! CHECK: cf.br ^bb3
+! CHECK: ^bb3:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_explicit_character_ptr(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>> {fir.bindc_name = "x"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i64> {fir.bindc_name = "n"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_explicit_character_ptrEn"} : (!fir.ref<i64>, !fir.dscope) -> (!fir.ref<i64>, !fir.ref<i64>)
+! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i64>
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
+! CHECK: %[[VAL_6:.*]] = arith.cmpi sgt, %[[VAL_4]], %[[VAL_5]] : i64
+! CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_6]], %[[VAL_4]], %[[VAL_5]] : i64
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_7]] dummy_scope %[[VAL_2]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_explicit_character_ptrEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, i64, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>)
+! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_10:.*]] = fir.box_rank %[[VAL_8]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>) -> i8
+! CHECK: fir.select_case %[[VAL_10]] : i8 [#fir.point, %[[VAL_9]], ^bb2, unit, ^bb1]
+! CHECK: ^bb1:
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_8]]#1 typeparams %[[VAL_7]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_explicit_character_ptrEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, i64) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>)
+! CHECK: cf.br ^bb3
+! CHECK: ^bb2:
+! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_8]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>) -> !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
+! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] typeparams %[[VAL_7]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_explicit_character_ptrEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, i64) -> (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
+! CHECK: cf.br ^bb3
+! CHECK: ^bb3:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_assumed_character_ptr(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>
+! CHECK: %[[VAL_3:.*]] = fir.box_elesize %[[VAL_2]] : (!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>) -> index
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0]] typeparams %[[VAL_3]] dummy_scope %[[VAL_1]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_assumed_character_ptrEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, index, !fir.dscope) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>)
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_6:.*]] = fir.box_rank %[[VAL_4]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>) -> i8
+! CHECK: fir.select_case %[[VAL_6]] : i8 [#fir.point, %[[VAL_5]], ^bb2, unit, ^bb1]
+! CHECK: ^bb1:
+! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_4]]#1 typeparams %[[VAL_3]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_assumed_character_ptrEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, index) -> (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>)
+! CHECK: cf.br ^bb3
+! CHECK: ^bb2:
+! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.box<!fir.heap<!fir.array<*:!fir.char<1,?>>>>>) -> !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] typeparams %[[VAL_3]] {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtest_assumed_character_ptrEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, index) -> (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>, !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>)
+! CHECK: cf.br ^bb3
+! CHECK: ^bb3:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_polymorphic(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.class<!fir.array<*:none>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_polymorphicEx"} : (!fir.class<!fir.array<*:none>>, !fir.dscope) -> (!fir.class<!fir.array<*:none>>, !fir.class<!fir.array<*:none>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_4:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_5:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.class<!fir.array<*:none>>) -> i1
+! CHECK: cf.cond_br %[[VAL_5]], ^bb3, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_6:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.class<!fir.array<*:none>>) -> i8
+! CHECK: fir.select_case %[[VAL_6]] : i8 [#fir.point, %[[VAL_3]], ^bb2, #fir.point, %[[VAL_4]], ^bb4, unit, ^bb3]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.class<!fir.array<*:none>>) -> !fir.class<!fir.array<?xnone>>
+! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_7]] {uniq_name = "_QFtest_polymorphicEx"} : (!fir.class<!fir.array<?xnone>>) -> (!fir.class<!fir.array<?xnone>>, !fir.class<!fir.array<?xnone>>)
+! CHECK: fir.call @_QPrup1(%[[VAL_8]]#0) fastmath<contract> : (!fir.class<!fir.array<?xnone>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb3:
+! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {uniq_name = "_QFtest_polymorphicEx"} : (!fir.class<!fir.array<*:none>>) -> (!fir.class<!fir.array<*:none>>, !fir.class<!fir.array<*:none>>)
+! CHECK: fir.call @_QPrupdefault(%[[VAL_9]]#0) fastmath<contract> : (!fir.class<!fir.array<*:none>>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb4:
+! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.class<!fir.array<*:none>>) -> !fir.class<none>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFtest_polymorphicEx"} : (!fir.class<none>) -> (!fir.class<none>, !fir.class<none>)
+! CHECK: fir.call @_QPrup0(%[[VAL_11]]#0) fastmath<contract> : (!fir.class<none>) -> ()
+! CHECK: cf.br ^bb5
+! CHECK: ^bb5:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_nested_select_rank(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x1"},
+! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x2"}) {
+! CHECK: %[[VAL_2:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_nested_select_rankEx1"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_1]] dummy_scope %[[VAL_2]] {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_7:.*]] = fir.is_assumed_size %[[VAL_3]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_7]], ^bb14, ^bb1
+! CHECK: ^bb1:
+! CHECK: %[[VAL_8:.*]] = fir.box_rank %[[VAL_3]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_8]] : i8 [#fir.point, %[[VAL_5]], ^bb2, #fir.point, %[[VAL_6]], ^bb8, unit, ^bb14]
+! CHECK: ^bb2:
+! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<f32>
+! CHECK: %[[VAL_10:.*]] = fir.box_addr %[[VAL_9]] : (!fir.box<f32>) -> !fir.ref<f32>
+! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFtest_nested_select_rankEx1"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+! CHECK: %[[VAL_12:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_13:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_14:.*]] = fir.is_assumed_size %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_14]], ^bb6, ^bb3
+! CHECK: ^bb3:
+! CHECK: %[[VAL_15:.*]] = fir.box_rank %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_15]] : i8 [#fir.point, %[[VAL_12]], ^bb4, #fir.point, %[[VAL_13]], ^bb5, unit, ^bb6]
+! CHECK: ^bb4:
+! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<f32>
+! CHECK: %[[VAL_17:.*]] = fir.box_addr %[[VAL_16]] : (!fir.box<f32>) -> !fir.ref<f32>
+! CHECK: %[[VAL_18:.*]]:2 = hlfir.declare %[[VAL_17]] {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+! CHECK: fir.call @_QPr0(%[[VAL_11]]#1) fastmath<contract> : (!fir.ref<f32>) -> ()
+! CHECK: fir.call @_QPr0(%[[VAL_18]]#1) fastmath<contract> : (!fir.ref<f32>) -> ()
+! CHECK: cf.br ^bb7
+! CHECK: ^bb5:
+! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_20:.*]]:2 = hlfir.declare %[[VAL_19]] {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr0(%[[VAL_11]]#1) fastmath<contract> : (!fir.ref<f32>) -> ()
+! CHECK: fir.call @_QPr1(%[[VAL_20]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb7
+! CHECK: ^bb6:
+! CHECK: %[[VAL_21:.*]]:2 = hlfir.declare %[[VAL_4]]#1 {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: fir.call @_QPr0(%[[VAL_11]]#1) fastmath<contract> : (!fir.ref<f32>) -> ()
+! CHECK: fir.call @_QPrdefault(%[[VAL_21]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb7
+! CHECK: ^bb7:
+! CHECK: cf.br ^bb20
+! CHECK: ^bb8:
+! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_23:.*]]:2 = hlfir.declare %[[VAL_22]] {uniq_name = "_QFtest_nested_select_rankEx1"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: %[[VAL_24:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_25:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_26:.*]] = fir.is_assumed_size %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_26]], ^bb12, ^bb9
+! CHECK: ^bb9:
+! CHECK: %[[VAL_27:.*]] = fir.box_rank %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_27]] : i8 [#fir.point, %[[VAL_24]], ^bb10, #fir.point, %[[VAL_25]], ^bb11, unit, ^bb12]
+! CHECK: ^bb10:
+! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<f32>
+! CHECK: %[[VAL_29:.*]] = fir.box_addr %[[VAL_28]] : (!fir.box<f32>) -> !fir.ref<f32>
+! CHECK: %[[VAL_30:.*]]:2 = hlfir.declare %[[VAL_29]] {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+! CHECK: fir.call @_QPr1(%[[VAL_23]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: fir.call @_QPr0(%[[VAL_30]]#1) fastmath<contract> : (!fir.ref<f32>) -> ()
+! CHECK: cf.br ^bb13
+! CHECK: ^bb11:
+! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_32:.*]]:2 = hlfir.declare %[[VAL_31]] {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPr1(%[[VAL_23]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: fir.call @_QPr1(%[[VAL_32]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb13
+! CHECK: ^bb12:
+! CHECK: %[[VAL_33:.*]]:2 = hlfir.declare %[[VAL_4]]#1 {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: fir.call @_QPr1(%[[VAL_23]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: fir.call @_QPrdefault(%[[VAL_33]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb13
+! CHECK: ^bb13:
+! CHECK: cf.br ^bb20
+! CHECK: ^bb14:
+! CHECK: %[[VAL_34:.*]]:2 = hlfir.declare %[[VAL_3]]#1 {uniq_name = "_QFtest_nested_select_rankEx1"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_35:.*]] = arith.constant 0 : i8
+! CHECK: %[[VAL_36:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_37:.*]] = fir.is_assumed_size %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_37]], ^bb18, ^bb15
+! CHECK: ^bb15:
+! CHECK: %[[VAL_38:.*]] = fir.box_rank %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_38]] : i8 [#fir.point, %[[VAL_35]], ^bb16, #fir.point, %[[VAL_36]], ^bb17, unit, ^bb18]
+! CHECK: ^bb16:
+! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<f32>
+! CHECK: %[[VAL_40:.*]] = fir.box_addr %[[VAL_39]] : (!fir.box<f32>) -> !fir.ref<f32>
+! CHECK: %[[VAL_41:.*]]:2 = hlfir.declare %[[VAL_40]] {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+! CHECK: fir.call @_QPrdefault(%[[VAL_34]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: fir.call @_QPr0(%[[VAL_41]]#1) fastmath<contract> : (!fir.ref<f32>) -> ()
+! CHECK: cf.br ^bb19
+! CHECK: ^bb17:
+! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_43:.*]]:2 = hlfir.declare %[[VAL_42]] {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: fir.call @_QPrdefault(%[[VAL_34]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: fir.call @_QPr1(%[[VAL_43]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb19
+! CHECK: ^bb18:
+! CHECK: %[[VAL_44:.*]]:2 = hlfir.declare %[[VAL_4]]#1 {uniq_name = "_QFtest_nested_select_rankEx2"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: fir.call @_QPrdefault(%[[VAL_34]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: fir.call @_QPrdefault(%[[VAL_44]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb19
+! CHECK: ^bb19:
+! CHECK: cf.br ^bb20
+! CHECK: ^bb20:
+! CHECK: return
+! CHECK: }
+
+! CHECK-LABEL: func.func @_QPtest_branching(
+! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<*:f32>> {fir.bindc_name = "x"}) {
+! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
+! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]] {uniq_name = "_QFtest_branchingEx"} : (!fir.box<!fir.array<*:f32>>, !fir.dscope) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i8
+! CHECK: %[[VAL_4:.*]] = arith.constant 2 : i8
+! CHECK: %[[VAL_5:.*]] = fir.is_assumed_size %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i1
+! CHECK: cf.cond_br %[[VAL_5]], ^bb1, ^bb2
+! CHECK: ^bb1:
+! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_2]]#1 {uniq_name = "_QFtest_branchingEx"} : (!fir.box<!fir.array<*:f32>>) -> (!fir.box<!fir.array<*:f32>>, !fir.box<!fir.array<*:f32>>)
+! CHECK: %[[VAL_7:.*]] = fir.call @_QPjump() fastmath<contract> : () -> !fir.logical<4>
+! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.logical<4>) -> i1
+! CHECK: %[[VAL_9:.*]] = arith.constant true
+! CHECK: %[[VAL_10:.*]] = arith.xori %[[VAL_8]], %[[VAL_9]] : i1
+! CHECK: fir.if %[[VAL_10]] {
+! CHECK: fir.call @_QPone() fastmath<contract> : () -> ()
+! CHECK: } else {
+! CHECK: }
+! CHECK: fir.call @_QPrdefault(%[[VAL_6]]#0) fastmath<contract> : (!fir.box<!fir.array<*:f32>>) -> ()
+! CHECK: cf.br ^bb7
+! CHECK: ^bb2:
+! CHECK: %[[VAL_11:.*]] = fir.box_rank %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> i8
+! CHECK: fir.select_case %[[VAL_11]] : i8 [#fir.point, %[[VAL_3]], ^bb3, #fir.point, %[[VAL_4]], ^bb6, unit, ^bb1]
+! CHECK: ^bb3:
+! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?xf32>>
+! CHECK: %[[VAL_13:.*]]:2 = hlfir.declare %[[VAL_12]] {uniq_name = "_QFtest_branchingEx"} : (!fir.box<!fir.array<?xf32>>) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! CHECK: %[[VAL_14:.*]] = fir.call @_QPleave_now() fastmath<contract> : () -> !fir.logical<4>
+! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.logical<4>) -> i1
+! CHECK: cf.cond_br %[[VAL_15]], ^bb4, ^bb5
+! CHECK: ^bb4:
+! CHECK: cf.br ^bb8
+! CHECK: ^bb5:
+! CHECK: fir.call @_QPr1(%[[VAL_13]]#0) fastmath<contract> : (!fir.box<!fir.array<?xf32>>) -> ()
+! CHECK: cf.br ^bb7
+! CHECK: ^bb6:
+! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<?x?xf32>>
+! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_16]] {uniq_name = "_QFtest_branchingEx"} : (!fir.box<!fir.array<?x?xf32>>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.box<!fir.array<?x?xf32>>)
+! CHECK: cf.br ^bb7
+! CHECK: ^bb7:
+! CHECK: cf.br ^bb8
+! CHECK: ^bb8:
+! CHECK: fir.call @_QPthe_end() fastmath<contract> : () -> ()
+! CHECK: return
+! CHECK: }
More information about the flang-commits
mailing list