[flang-commits] [flang] 7b4aa95 - [flang][hlfir] Set/propagate 'unordered' attribute for elementals.
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Thu Jun 29 11:16:47 PDT 2023
Author: Slava Zakharin
Date: 2023-06-29T11:16:38-07:00
New Revision: 7b4aa95d7c5e313ffb8028f627fe0480d66ef650
URL: https://github.com/llvm/llvm-project/commit/7b4aa95d7c5e313ffb8028f627fe0480d66ef650
DIFF: https://github.com/llvm/llvm-project/commit/7b4aa95d7c5e313ffb8028f627fe0480d66ef650.diff
LOG: [flang][hlfir] Set/propagate 'unordered' attribute for elementals.
This patch adds 'unordered' attribute handling the HLFIR elementals'
builders and fixes the attribute handling in lowering and transformations.
Depends on D154031, D154032
Reviewed By: jeanPerier, tblah
Differential Revision: https://reviews.llvm.org/D154035
Added:
Modified:
flang/include/flang/Optimizer/Builder/HLFIRTools.h
flang/include/flang/Optimizer/HLFIR/HLFIROps.td
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/ConvertArrayConstructor.cpp
flang/lib/Lower/ConvertCall.cpp
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Optimizer/Builder/HLFIRTools.cpp
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
flang/test/HLFIR/simplify-hlfir-intrinsics.fir
flang/test/Lower/HLFIR/allocatables-and-pointers.f90
flang/test/Lower/HLFIR/array-ctor-as-elemental-nested.f90
flang/test/Lower/HLFIR/array-ctor-as-elemental.f90
flang/test/Lower/HLFIR/array-ctor-index.f90
flang/test/Lower/HLFIR/count.f90
flang/test/Lower/HLFIR/elemental-array-ops.f90
flang/test/Lower/HLFIR/elemental-intrinsics.f90
flang/test/Lower/HLFIR/elemental-user-procedure-ref-polymorphic.f90
flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90
flang/test/Lower/HLFIR/implicit-type-conversion.f90
flang/test/Lower/HLFIR/matmul.f90
flang/test/Lower/HLFIR/structure-constructor.f90
flang/test/Lower/HLFIR/user-defined-assignment.f90
flang/test/Lower/HLFIR/vector-subscript-as-value.f90
flang/test/Lower/HLFIR/vector-subscript-lhs.f90
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Builder/HLFIRTools.h b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
index ddea8e5d909981..88819cdec2e77c 100644
--- a/flang/include/flang/Optimizer/Builder/HLFIRTools.h
+++ b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
@@ -375,6 +375,7 @@ hlfir::ElementalOp genElementalOp(mlir::Location loc,
mlir::Type elementType, mlir::Value shape,
mlir::ValueRange typeParams,
const ElementalKernelGenerator &genKernel,
+ bool isUnordered = false,
mlir::Type exprType = mlir::Type{});
/// Structure to describe a loop nest.
diff --git a/flang/include/flang/Optimizer/HLFIR/HLFIROps.td b/flang/include/flang/Optimizer/HLFIR/HLFIROps.td
index 1bb0e3f9c58599..a5bb323c361a2d 100644
--- a/flang/include/flang/Optimizer/HLFIR/HLFIROps.td
+++ b/flang/include/flang/Optimizer/HLFIR/HLFIROps.td
@@ -786,7 +786,9 @@ def hlfir_ElementalOp : hlfir_Op<"elemental", [RecursiveMemoryEffects, hlfir_Ele
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<(ins "mlir::Type":$result_type, "mlir::Value":$shape,
- CArg<"mlir::ValueRange", "{}">:$typeparams)>];
+ CArg<"mlir::ValueRange", "{}">:$typeparams,
+ CArg<"bool", "false">:$isUnordered)>
+ ];
}
@@ -1216,7 +1218,7 @@ def hlfir_ElementalAddrOp : hlfir_Op<"elemental_addr", [Terminator, HasParent<"R
MaxSizedRegion<1>:$cleanup);
let builders = [
- OpBuilder<(ins "mlir::Value":$shape)>
+ OpBuilder<(ins "mlir::Value":$shape, CArg<"bool", "false">:$isUnordered)>
];
let assemblyFormat = [{
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 1bf538a0a1c8e6..211d49659699e1 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -3165,7 +3165,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
return hlfir::EntityWithAttributes{builder.createConvert(loc, toTy, val)};
};
mlir::Value convertedRhs = hlfir::genElementalOp(
- loc, builder, toTy, shape, /*typeParams=*/{}, genKernel);
+ loc, builder, toTy, shape, /*typeParams=*/{}, genKernel,
+ /*isUnordered=*/true);
fir::FirOpBuilder *bldr = &builder;
stmtCtx.attachCleanup([loc, bldr, convertedRhs]() {
bldr->create<hlfir::DestroyOp>(loc, convertedRhs);
diff --git a/flang/lib/Lower/ConvertArrayConstructor.cpp b/flang/lib/Lower/ConvertArrayConstructor.cpp
index ed78a712b68b35..b0282019901832 100644
--- a/flang/lib/Lower/ConvertArrayConstructor.cpp
+++ b/flang/lib/Lower/ConvertArrayConstructor.cpp
@@ -215,7 +215,8 @@ class AsElementalStrategy : public StrategyBase {
mlir::Value one =
builder.createIntegerConstant(loc, builder.getIndexType(), 1);
elementalOp =
- builder.create<hlfir::ElementalOp>(loc, exprType, shape, lengthParams);
+ builder.create<hlfir::ElementalOp>(loc, exprType, shape, lengthParams,
+ /*isUnordered=*/true);
builder.setInsertionPointToStart(elementalOp.getBody());
// implied-do-index = lower+((i-1)*stride)
mlir::Value
diff = builder.create<mlir::arith::SubIOp>(
@@ -686,9 +687,10 @@ static ArrayCtorLoweringStrategy selectArrayCtorLoweringStrategy(
loc, builder, stmtCtx, symMap, declaredType,
extent ? std::optional<mlir::Value>(extent) : std::nullopt, lengths,
needToEvaluateOneExprToGetLengthParameters);
- // Note: array constructors containing impure ac-value expr are currently not
- // rewritten to hlfir.elemental because impure expressions should be evaluated
- // in order, and hlfir.elemental currently misses a way to indicate that.
+ // Note: the generated hlfir.elemental is always unordered, thus,
+ // AsElementalStrategy can only be used for array constructors without
+ // impure ac-value expressions. If/when this changes, make sure
+ // the 'unordered' attribute is set accordingly for the hlfir.elemental.
if (analysis.isSingleImpliedDoWithOneScalarPureExpr())
return AsElementalStrategy(loc, builder, stmtCtx, symMap, declaredType,
extent, lengths);
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 9bfe93f5132e69..46fc480bb1b5f5 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -1612,8 +1612,6 @@ class ElementalCallBuilder {
return std::nullopt;
}
// Function case: generate call inside hlfir.elemental
- if (mustBeOrdered)
- TODO(loc, "ordered elemental calls in HLFIR");
mlir::Type elementType =
hlfir::getFortranElementType(*callContext.resultType);
// Get result length parameters.
@@ -1645,8 +1643,9 @@ class ElementalCallBuilder {
// use.
return res;
};
- mlir::Value elemental = hlfir::genElementalOp(loc, builder, elementType,
- shape, typeParams, genKernel);
+ mlir::Value elemental =
+ hlfir::genElementalOp(loc, builder, elementType, shape, typeParams,
+ genKernel, !mustBeOrdered);
fir::FirOpBuilder *bldr = &builder;
callContext.stmtCtx.attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, elemental); });
diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp
index 7df4a6224bb241..eb48df41104b79 100644
--- a/flang/lib/Lower/ConvertExprToHLFIR.cpp
+++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp
@@ -783,7 +783,9 @@ class HlfirDesignatorBuilder {
// of the whole designator (not the ones of the vector subscripted part).
// These are not yet known and will be added when finalizing the designator
// lowering.
- auto elementalAddrOp = builder.create<hlfir::ElementalAddrOp>(loc, shape);
+ auto elementalAddrOp =
+ builder.create<hlfir::ElementalAddrOp>(loc, shape,
+ /*isUnordered=*/true);
setVectorSubscriptElementAddrOp(elementalAddrOp);
builder.setInsertionPointToEnd(&elementalAddrOp.getBody().front());
mlir::Region::BlockArgListType indices = elementalAddrOp.getIndices();
@@ -1512,7 +1514,8 @@ class HlfirBuilder {
return unaryOp.gen(l, b, op.derived(), leftVal);
};
mlir::Value elemental = hlfir::genElementalOp(loc, builder, elementType,
- shape, typeParams, genKernel);
+ shape, typeParams, genKernel,
+ /*isUnordered=*/true);
fir::FirOpBuilder *bldr = &builder;
getStmtCtx().attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, elemental); });
@@ -1557,7 +1560,8 @@ class HlfirBuilder {
return binaryOp.gen(l, b, op.derived(), leftVal, rightVal);
};
mlir::Value elemental = hlfir::genElementalOp(loc, builder, elementType,
- shape, typeParams, genKernel);
+ shape, typeParams, genKernel,
+ /*isUnordered=*/true);
fir::FirOpBuilder *bldr = &builder;
getStmtCtx().attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, elemental); });
diff --git a/flang/lib/Optimizer/Builder/HLFIRTools.cpp b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
index a905f83edf2f0a..40138db20aa80f 100644
--- a/flang/lib/Optimizer/Builder/HLFIRTools.cpp
+++ b/flang/lib/Optimizer/Builder/HLFIRTools.cpp
@@ -732,14 +732,16 @@ static hlfir::ExprType getArrayExprType(mlir::Type elementType,
isPolymorphic);
}
-hlfir::ElementalOp hlfir::genElementalOp(
- mlir::Location loc, fir::FirOpBuilder &builder, mlir::Type elementType,
- mlir::Value shape, mlir::ValueRange typeParams,
- const ElementalKernelGenerator &genKernel, mlir::Type exprType) {
+hlfir::ElementalOp
+hlfir::genElementalOp(mlir::Location loc, fir::FirOpBuilder &builder,
+ mlir::Type elementType, mlir::Value shape,
+ mlir::ValueRange typeParams,
+ const ElementalKernelGenerator &genKernel,
+ bool isUnordered, mlir::Type exprType) {
if (!exprType)
exprType = getArrayExprType(elementType, shape, false);
- auto elementalOp =
- builder.create<hlfir::ElementalOp>(loc, exprType, shape, typeParams);
+ auto elementalOp = builder.create<hlfir::ElementalOp>(
+ loc, exprType, shape, typeParams, isUnordered);
auto insertPt = builder.saveInsertionPoint();
builder.setInsertionPointToStart(elementalOp.getBody());
mlir::Value elementResult = genKernel(loc, builder, elementalOp.getIndices());
@@ -1013,5 +1015,5 @@ hlfir::cloneToElementalOp(mlir::Location loc, fir::FirOpBuilder &builder,
mlir::Type elementType = scalarAddress.getFortranElementType();
return hlfir::genElementalOp(loc, builder, elementType,
elementalAddrOp.getShape(), typeParams,
- genKernel);
+ genKernel, !elementalAddrOp.isOrdered());
}
diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
index 04687b54bff7ba..c861d428c773ba 100644
--- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
+++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
@@ -1029,10 +1029,13 @@ void hlfir::AsExprOp::build(mlir::OpBuilder &builder,
void hlfir::ElementalOp::build(mlir::OpBuilder &builder,
mlir::OperationState &odsState,
mlir::Type resultType, mlir::Value shape,
- mlir::ValueRange typeparams) {
+ mlir::ValueRange typeparams, bool isUnordered) {
odsState.addOperands(shape);
odsState.addOperands(typeparams);
odsState.addTypes(resultType);
+ if (isUnordered)
+ odsState.addAttribute(getUnorderedAttrName(odsState.name),
+ isUnordered ? builder.getUnitAttr() : nullptr);
mlir::Region *bodyRegion = odsState.addRegion();
bodyRegion->push_back(new mlir::Block{});
if (auto exprType = resultType.dyn_cast<hlfir::ExprType>()) {
@@ -1264,8 +1267,11 @@ static void printYieldOpCleanup(mlir::OpAsmPrinter &p, YieldOp yieldOp,
void hlfir::ElementalAddrOp::build(mlir::OpBuilder &builder,
mlir::OperationState &odsState,
- mlir::Value shape) {
+ mlir::Value shape, bool isUnordered) {
odsState.addOperands(shape);
+ if (isUnordered)
+ odsState.addAttribute(getUnorderedAttrName(odsState.name),
+ isUnordered ? builder.getUnitAttr() : nullptr);
mlir::Region *bodyRegion = odsState.addRegion();
bodyRegion->push_back(new mlir::Block{});
if (auto shapeType = shape.getType().dyn_cast<fir::ShapeType>()) {
diff --git a/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp b/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
index f1c8d689606004..141c41d1a63ce1 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
+++ b/flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp
@@ -60,7 +60,7 @@ class TransposeAsElementalConversion
};
hlfir::ElementalOp elementalOp = hlfir::genElementalOp(
loc, builder, elementType, resultShape, typeParams, genKernel,
- transpose.getResult().getType());
+ /*isUnordered=*/true, transpose.getResult().getType());
// it wouldn't be safe to replace block arguments with a
diff erent
// hlfir.expr type. Types can
diff er due to
diff ering amounts of shape
diff --git a/flang/test/HLFIR/simplify-hlfir-intrinsics.fir b/flang/test/HLFIR/simplify-hlfir-intrinsics.fir
index eac89a64239211..aeea8bfc973266 100644
--- a/flang/test/HLFIR/simplify-hlfir-intrinsics.fir
+++ b/flang/test/HLFIR/simplify-hlfir-intrinsics.fir
@@ -10,7 +10,7 @@ func.func @transpose0(%arg0: !fir.box<!fir.array<1x2xi32>>) {
// CHECK: %[[C1:.*]] = arith.constant 1 : index
// CHECK: %[[C2:.*]] = arith.constant 2 : index
// CHECK: %[[SHAPE:.*]] = fir.shape %[[C2]], %[[C1]] : (index, index) -> !fir.shape<2>
-// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[SHAPE]] : (!fir.shape<2>) -> !hlfir.expr<2x1xi32> {
+// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[SHAPE]] unordered : (!fir.shape<2>) -> !hlfir.expr<2x1xi32> {
// CHECK: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index):
// CHECK: %[[C0:.*]] = arith.constant 0 : index
// CHECK: %[[DIMS0:.*]]:3 = fir.box_dims %[[ARG0]], %[[C0]] : (!fir.box<!fir.array<1x2xi32>>, index) -> (index, index, index)
@@ -38,7 +38,7 @@ func.func @transpose1(%arg0: !hlfir.expr<1x2xi32>) {
// CHECK: %[[C1:.*]] = arith.constant 1 : index
// CHECK: %[[C2:.*]] = arith.constant 2 : index
// CHECK: %[[SHAPE:.*]] = fir.shape %[[C2]], %[[C1]] : (index, index) -> !fir.shape<2>
-// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[SHAPE]] : (!fir.shape<2>) -> !hlfir.expr<2x1xi32> {
+// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[SHAPE]] unordered : (!fir.shape<2>) -> !hlfir.expr<2x1xi32> {
// CHECK: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index):
// CHECK: %[[ELEMENT:.*]] = hlfir.apply %[[ARG0]], %[[J]], %[[I]] : (!hlfir.expr<1x2xi32>, index, index) -> i32
// CHECK: hlfir.yield_element %[[ELEMENT]] : i32
@@ -57,7 +57,7 @@ func.func @transpose2(%arg0: !fir.box<!fir.array<?x2xi32>>) {
// CHECK: %[[DIMS0:.*]]:3 = fir.box_dims %[[ARG0]], %[[C0]] : (!fir.box<!fir.array<?x2xi32>>, index) -> (index, index, index)
// CHECK: %[[C2:.*]] = arith.constant 2 : index
// CHECK: %[[SHAPE:.*]] = fir.shape %[[C2]], %[[DIMS0]]#1 : (index, index) -> !fir.shape<2>
-// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[SHAPE]] : (!fir.shape<2>) -> !hlfir.expr<2x?xi32> {
+// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[SHAPE]] unordered : (!fir.shape<2>) -> !hlfir.expr<2x?xi32> {
// CHECK: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index):
// CHECK: %[[C0_1:.*]] = arith.constant 0 : index
// CHECK: %[[DIMS0:.*]]:3 = fir.box_dims %[[ARG0]], %[[C0_1]] : (!fir.box<!fir.array<?x2xi32>>, index) -> (index, index, index)
@@ -86,7 +86,7 @@ func.func @transpose3(%arg0: !hlfir.expr<?x2xi32>) {
// CHECK: %[[EXTENT0:.*]] = hlfir.get_extent %[[IN_SHAPE]] {dim = 0 : index} : (!fir.shape<2>) -> index
// CHECK: %[[C2:.*]] = arith.constant 2 : index
// CHECK: %[[OUT_SHAPE:.*]] = fir.shape %[[C2]], %[[EXTENT0]] : (index, index) -> !fir.shape<2>
-// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[OUT_SHAPE]] : (!fir.shape<2>) -> !hlfir.expr<2x?xi32> {
+// CHECK: %[[EXPR:.*]] = hlfir.elemental %[[OUT_SHAPE]] unordered : (!fir.shape<2>) -> !hlfir.expr<2x?xi32> {
// CHECK: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index):
// CHECK: %[[ELEMENT:.*]] = hlfir.apply %[[ARG0]], %[[J]], %[[I]] : (!hlfir.expr<?x2xi32>, index, index) -> i32
// CHECK: hlfir.yield_element %[[ELEMENT]] : i32
@@ -113,7 +113,7 @@ func.func @transpose4(%arg0: !hlfir.expr<2x2xf32>, %arg1: !fir.ref<!fir.box<!fir
// CHECK-SAME: %[[ARG0:.*]]: !hlfir.expr<2x2xf32>
// CHECK-SAME: %[[ARG1:.*]]:
// CHECK: %[[SHAPE0:.*]] = fir.shape
-// CHECK: %[[TRANSPOSE:.*]] = hlfir.elemental %[[SHAPE0]] : (!fir.shape<2>) -> !hlfir.expr<2x2xf32> {
+// CHECK: %[[TRANSPOSE:.*]] = hlfir.elemental %[[SHAPE0]] unordered : (!fir.shape<2>) -> !hlfir.expr<2x2xf32> {
// CHECK: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index):
// CHECK: %[[ELE:.*]] = hlfir.apply %[[ARG0]], %[[J]], %[[I]] : (!hlfir.expr<2x2xf32>, index, index) -> f32
// CHECK: hlfir.yield_element %[[ELE]] : f32
diff --git a/flang/test/Lower/HLFIR/allocatables-and-pointers.f90 b/flang/test/Lower/HLFIR/allocatables-and-pointers.f90
index 9c54d5cd6bacec..ad6b2cf932e36b 100644
--- a/flang/test/Lower/HLFIR/allocatables-and-pointers.f90
+++ b/flang/test/Lower/HLFIR/allocatables-and-pointers.f90
@@ -138,7 +138,7 @@ subroutine elemental_expr(x)
! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_6]] : (!fir.box<!fir.ptr<!fir.array<?x?xi32>>>, index) -> (index, index, index)
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_5]]#1, %[[VAL_7]]#1 : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_8]] : (!fir.shape<2>) -> !hlfir.expr<?x?xi32> {
+! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<2>) -> !hlfir.expr<?x?xi32> {
! CHECK: ^bb0(%[[VAL_10:.*]]: index, %[[VAL_11:.*]]: index):
! CHECK: %[[VAL_12:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_13:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_12]] : (!fir.box<!fir.ptr<!fir.array<?x?xi32>>>, index) -> (index, index, index)
diff --git a/flang/test/Lower/HLFIR/array-ctor-as-elemental-nested.f90 b/flang/test/Lower/HLFIR/array-ctor-as-elemental-nested.f90
index 4b4192b1df9309..5ebbe600bef154 100644
--- a/flang/test/Lower/HLFIR/array-ctor-as-elemental-nested.f90
+++ b/flang/test/Lower/HLFIR/array-ctor-as-elemental-nested.f90
@@ -19,11 +19,11 @@
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtestEpi"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
! CHECK: %[[VAL_12:.*]] = arith.constant 2 : index
! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_12]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_14:.*]] = hlfir.elemental %[[VAL_13]] : (!fir.shape<1>) -> !hlfir.expr<2xf32> {
+! CHECK: %[[VAL_14:.*]] = hlfir.elemental %[[VAL_13]] unordered : (!fir.shape<1>) -> !hlfir.expr<2xf32> {
! CHECK: ^bb0(%[[VAL_15:.*]]: index):
! CHECK: %[[VAL_16:.*]] = arith.constant 2 : index
! CHECK: %[[VAL_17:.*]] = fir.shape %[[VAL_16]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_18:.*]] = hlfir.elemental %[[VAL_17]] : (!fir.shape<1>) -> !hlfir.expr<2xf32> {
+! CHECK: %[[VAL_18:.*]] = hlfir.elemental %[[VAL_17]] unordered : (!fir.shape<1>) -> !hlfir.expr<2xf32> {
! CHECK: ^bb0(%[[VAL_19:.*]]: index):
! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_11]]#0 : !fir.ref<f32>
! CHECK: hlfir.yield_element %[[VAL_20]] : f32
diff --git a/flang/test/Lower/HLFIR/array-ctor-as-elemental.f90 b/flang/test/Lower/HLFIR/array-ctor-as-elemental.f90
index 77c7ef1a96b4d7..35b60a40147812 100644
--- a/flang/test/Lower/HLFIR/array-ctor-as-elemental.f90
+++ b/flang/test/Lower/HLFIR/array-ctor-as-elemental.f90
@@ -15,7 +15,7 @@ subroutine test_as_simple_elemental(n)
! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i64
! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_3]] : (!fir.shape<1>) -> !hlfir.expr<4xi32> {
+! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_3]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi32> {
! CHECK: ^bb0(%[[VAL_10:.*]]: index):
! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_10]], %[[VAL_8]] : index
! CHECK: %[[VAL_12:.*]] = arith.muli %[[VAL_11]], %[[VAL_7]] : index
@@ -63,7 +63,7 @@ subroutine test_as_strided_elemental(lb, ub, stride)
! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_4]]#0 : !fir.ref<i64>
! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
! CHECK: %[[VAL_24:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_25:.*]] = hlfir.elemental %[[VAL_19]] : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
+! CHECK: %[[VAL_25:.*]] = hlfir.elemental %[[VAL_19]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
! CHECK: ^bb0(%[[VAL_26:.*]]: index):
! CHECK: %[[VAL_27:.*]] = arith.subi %[[VAL_26]], %[[VAL_24]] : index
! CHECK: %[[VAL_28:.*]] = arith.muli %[[VAL_27]], %[[VAL_23]] : index
@@ -99,7 +99,7 @@ integer pure function foo(i)
! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i64
! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_3]] : (!fir.shape<1>) -> !hlfir.expr<4xi32> {
+! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_3]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi32> {
! CHECK: ^bb0(%[[VAL_10:.*]]: index):
! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_10]], %[[VAL_8]] : index
! CHECK: %[[VAL_12:.*]] = arith.muli %[[VAL_11]], %[[VAL_7]] : index
diff --git a/flang/test/Lower/HLFIR/array-ctor-index.f90 b/flang/test/Lower/HLFIR/array-ctor-index.f90
index 611fd07b329591..83eb2cd3a40808 100644
--- a/flang/test/Lower/HLFIR/array-ctor-index.f90
+++ b/flang/test/Lower/HLFIR/array-ctor-index.f90
@@ -20,7 +20,7 @@ end function test1
! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_14:.*]]: index):
! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_14]], %[[VAL_12]] : index
! CHECK: %[[VAL_16:.*]] = arith.muli %[[VAL_15]], %[[VAL_11]] : index
@@ -31,13 +31,13 @@ end function test1
! CHECK: %[[VAL_21:.*]] = arith.muli %[[VAL_18]], %[[VAL_20]] : i64
! CHECK: hlfir.yield_element %[[VAL_21]] : i64
! CHECK: }
-! CHECK: %[[VAL_22:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_22:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_23:.*]]: index):
! CHECK: %[[VAL_24:.*]] = hlfir.apply %[[VAL_25:.*]], %[[VAL_23]] : (!hlfir.expr<4xi64>, index) -> i64
! CHECK: %[[VAL_26:.*]] = hlfir.no_reassoc %[[VAL_24]] : i64
! CHECK: hlfir.yield_element %[[VAL_26]] : i64
! CHECK: }
-! CHECK: %[[VAL_27:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi8> {
+! CHECK: %[[VAL_27:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi8> {
! CHECK: ^bb0(%[[VAL_28:.*]]: index):
! CHECK: %[[VAL_29:.*]] = hlfir.apply %[[VAL_30:.*]], %[[VAL_28]] : (!hlfir.expr<4xi64>, index) -> i64
! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_29]] : (i64) -> i8
@@ -70,7 +70,7 @@ end function test2
! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_14:.*]]: index):
! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_14]], %[[VAL_12]] : index
! CHECK: %[[VAL_16:.*]] = arith.muli %[[VAL_15]], %[[VAL_11]] : index
@@ -81,13 +81,13 @@ end function test2
! CHECK: %[[VAL_21:.*]] = arith.muli %[[VAL_18]], %[[VAL_20]] : i64
! CHECK: hlfir.yield_element %[[VAL_21]] : i64
! CHECK: }
-! CHECK: %[[VAL_22:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_22:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_23:.*]]: index):
! CHECK: %[[VAL_24:.*]] = hlfir.apply %[[VAL_25:.*]], %[[VAL_23]] : (!hlfir.expr<4xi64>, index) -> i64
! CHECK: %[[VAL_26:.*]] = hlfir.no_reassoc %[[VAL_24]] : i64
! CHECK: hlfir.yield_element %[[VAL_26]] : i64
! CHECK: }
-! CHECK: %[[VAL_27:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi16> {
+! CHECK: %[[VAL_27:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi16> {
! CHECK: ^bb0(%[[VAL_28:.*]]: index):
! CHECK: %[[VAL_29:.*]] = hlfir.apply %[[VAL_30:.*]], %[[VAL_28]] : (!hlfir.expr<4xi64>, index) -> i64
! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_29]] : (i64) -> i16
@@ -120,7 +120,7 @@ end function test3
! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_14:.*]]: index):
! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_14]], %[[VAL_12]] : index
! CHECK: %[[VAL_16:.*]] = arith.muli %[[VAL_15]], %[[VAL_11]] : index
@@ -131,13 +131,13 @@ end function test3
! CHECK: %[[VAL_21:.*]] = arith.muli %[[VAL_18]], %[[VAL_20]] : i64
! CHECK: hlfir.yield_element %[[VAL_21]] : i64
! CHECK: }
-! CHECK: %[[VAL_22:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_22:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_23:.*]]: index):
! CHECK: %[[VAL_24:.*]] = hlfir.apply %[[VAL_25:.*]], %[[VAL_23]] : (!hlfir.expr<4xi64>, index) -> i64
! CHECK: %[[VAL_26:.*]] = hlfir.no_reassoc %[[VAL_24]] : i64
! CHECK: hlfir.yield_element %[[VAL_26]] : i64
! CHECK: }
-! CHECK: %[[VAL_27:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi32> {
+! CHECK: %[[VAL_27:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi32> {
! CHECK: ^bb0(%[[VAL_28:.*]]: index):
! CHECK: %[[VAL_29:.*]] = hlfir.apply %[[VAL_30:.*]], %[[VAL_28]] : (!hlfir.expr<4xi64>, index) -> i64
! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_29]] : (i64) -> i32
@@ -170,7 +170,7 @@ end function test4
! CHECK: %[[VAL_10:.*]] = arith.constant 1 : i64
! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
-! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_14:.*]]: index):
! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_14]], %[[VAL_12]] : index
! CHECK: %[[VAL_16:.*]] = arith.muli %[[VAL_15]], %[[VAL_11]] : index
@@ -180,7 +180,7 @@ end function test4
! CHECK: %[[VAL_20:.*]] = arith.muli %[[VAL_18]], %[[VAL_19]] : i64
! CHECK: hlfir.yield_element %[[VAL_20]] : i64
! CHECK: }
-! CHECK: %[[VAL_21:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
+! CHECK: %[[VAL_21:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<4xi64> {
! CHECK: ^bb0(%[[VAL_22:.*]]: index):
! CHECK: %[[VAL_23:.*]] = hlfir.apply %[[VAL_24:.*]], %[[VAL_22]] : (!hlfir.expr<4xi64>, index) -> i64
! CHECK: %[[VAL_25:.*]] = hlfir.no_reassoc %[[VAL_23]] : i64
diff --git a/flang/test/Lower/HLFIR/count.f90 b/flang/test/Lower/HLFIR/count.f90
index 25c74841514e97..4ce196450cfed2 100644
--- a/flang/test/Lower/HLFIR/count.f90
+++ b/flang/test/Lower/HLFIR/count.f90
@@ -74,7 +74,7 @@ subroutine count4(a, s, d)
! CHECK-DAG: %[[DIM:.*]] = fir.load %[[DIM_REF]]#0 : !fir.ref<i32>
! CHECK-DAG: %[[EXPR:.*]] = hlfir.count %[[MASK]]#0 dim %[[DIM]] kind %[[C8]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i32, i32) -> !hlfir.expr<?xi64>
! CHECK-DAG: %[[RES_SHAPE:.*]] = hlfir.shape_of %[[EXPR]]
-! CHECK-DAG: %[[RES:.*]] = hlfir.elemental %[[RES_SHAPE]] : (!fir.shape<1>) -> !hlfir.expr<?xi32>
+! CHECK-DAG: %[[RES:.*]] = hlfir.elemental %[[RES_SHAPE]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32>
! CHECK-DAG: hlfir.assign %[[RES]] to %[[OUT]]#0
! CHECK-NEXT: hlfir.destroy %[[RES]] : !hlfir.expr<?xi32>
! CHECK-NEXT: hlfir.destroy %[[EXPR]] : !hlfir.expr<?xi64>
diff --git a/flang/test/Lower/HLFIR/elemental-array-ops.f90 b/flang/test/Lower/HLFIR/elemental-array-ops.f90
index ff97a671e0fea2..c2f0e24c5f6bf0 100644
--- a/flang/test/Lower/HLFIR/elemental-array-ops.f90
+++ b/flang/test/Lower/HLFIR/elemental-array-ops.f90
@@ -8,7 +8,7 @@ subroutine binary(x, y)
! CHECK-LABEL: func.func @_QPbinary(
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_3:[^)]*]]) {{.*}}x
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_6:[^)]*]]) {{.*}}y
-! CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_3]] : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
+! CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_3]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
! CHECK: ^bb0(%[[VAL_9:.*]]: index):
! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32>
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32>
@@ -28,7 +28,7 @@ subroutine binary_with_scalar_and_array(x, y)
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_3:[^)]*]]) {{.*}}x
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %{{.*}} {{.*}}y
! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_5]]#0 : !fir.ref<i32>
-! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_3]] : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
+! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_3]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
! CHECK: ^bb0(%[[VAL_8:.*]]: index):
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_8]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32>
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32>
@@ -46,7 +46,7 @@ subroutine char_binary(x, y)
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_5:.*]]) typeparams %[[VAL_2:.*]]#1 {{.*}}x
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_10:.*]]) typeparams %[[VAL_7:.*]]#1 {{.*}}y
! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_2]]#1, %[[VAL_7]]#1 : index
-! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_12]] : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
+! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_12]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
! CHECK: ^bb0(%[[VAL_14:.*]]: index):
! CHECK: %[[VAL_15:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_14]]) typeparams %[[VAL_2]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
! CHECK: %[[VAL_16:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[VAL_14]]) typeparams %[[VAL_7]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
@@ -63,7 +63,7 @@ subroutine unary(x, n)
end subroutine
! CHECK-LABEL: func.func @_QPunary(
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_9:[^)]*]]) {{.*}}x
-! CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_9]] : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
+! CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_9]] unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
! CHECK: ^bb0(%[[VAL_12:.*]]: index):
! CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_10]]#0 (%[[VAL_12]]) : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !fir.ref<!fir.logical<4>>
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_13]] : !fir.ref<!fir.logical<4>>
@@ -82,7 +82,7 @@ subroutine char_unary(x)
end subroutine
! CHECK-LABEL: func.func @_QPchar_unary(
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_5:.*]]) typeparams %[[VAL_2:[^ ]*]] {{.*}}x
-! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_2]] : (!fir.shape<1>, index) -> !hlfir.expr<20x!fir.char<1,?>> {
+! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_2]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<20x!fir.char<1,?>> {
! CHECK: ^bb0(%[[VAL_8:.*]]: index):
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_8]]) typeparams %[[VAL_2]] : (!fir.ref<!fir.array<20x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>>
! CHECK: %[[VAL_10:.*]] = hlfir.as_expr %[[VAL_9]] : (!fir.ref<!fir.char<1,10>>) -> !hlfir.expr<!fir.char<1,10>>
@@ -99,7 +99,7 @@ subroutine chained_elemental(x, y, z)
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_4:[^)]*]]) {{.*}}x
! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_7:[^)]*]]) {{.*}}y
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_10:[^)]*]]) {{.*}}z
-! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_4]] : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
+! CHECK: %[[VAL_12:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
! CHECK: ^bb0(%[[VAL_13:.*]]: index):
! CHECK: %[[VAL_14:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32>
! CHECK: %[[VAL_15:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_13]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32>
@@ -108,7 +108,7 @@ subroutine chained_elemental(x, y, z)
! CHECK: %[[VAL_18:.*]] = arith.addi %[[VAL_16]], %[[VAL_17]] : i32
! CHECK: hlfir.yield_element %[[VAL_18]] : i32
! CHECK: }
-! CHECK: %[[VAL_19:.*]] = hlfir.elemental %[[VAL_4]] : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
+! CHECK: %[[VAL_19:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
! CHECK: ^bb0(%[[VAL_20:.*]]: index):
! CHECK: %[[VAL_21:.*]] = hlfir.apply %[[VAL_22:.*]], %[[VAL_20]] : (!hlfir.expr<100xi32>, index) -> i32
! CHECK: %[[VAL_23:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[VAL_20]]) : (!fir.ref<!fir.array<100xi32>>, index) -> !fir.ref<i32>
@@ -129,7 +129,7 @@ subroutine lower_bounds(x)
! CHECK: %[[VAL_2:.*]] = arith.constant 100 : index
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %{{.*}}(%[[VAL_3:[^)]*]]) {{.*}}x
! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_5]] : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
+! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_5]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
! CHECK: ^bb0(%[[VAL_7:.*]]: index):
! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_1]], %[[VAL_8]] : index
diff --git a/flang/test/Lower/HLFIR/elemental-intrinsics.f90 b/flang/test/Lower/HLFIR/elemental-intrinsics.f90
index e188d06558f1ce..dd79688663cba4 100644
--- a/flang/test/Lower/HLFIR/elemental-intrinsics.f90
+++ b/flang/test/Lower/HLFIR/elemental-intrinsics.f90
@@ -11,7 +11,7 @@ subroutine simple_elemental(x,y)
! CHECK-LABEL: func.func @_QPsimple_elemental(
! CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_0:[a-z0-9]*]](%[[VAL_3:[a-z0-9]*]]) {{.*}}Ex
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_1:[a-z0-9]*]](%[[VAL_6:[a-z0-9]*]]) {{.*}}Ey
-! CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_6]] : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
+! CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_6]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
! CHECK: ^bb0(%[[VAL_9:.*]]: index):
! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<100xf32>>, index) -> !fir.ref<f32>
! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_10]] : !fir.ref<f32>
@@ -34,7 +34,7 @@ subroutine elemental_mixed_args(x,y, scalar)
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
! CHECK: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_1:[a-z0-9]*]](%[[VAL_8:[a-z0-9]*]]) {{.*}}Ey
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<f32>
-! CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_5]] : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
+! CHECK: %[[VAL_11:.*]] = hlfir.elemental %[[VAL_5]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
! CHECK: ^bb0(%[[VAL_12:.*]]: index):
! CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_12]]) : (!fir.ref<!fir.array<100xf32>>, index) -> !fir.ref<f32>
! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_13]] : !fir.ref<f32>
@@ -53,7 +53,7 @@ subroutine elemental_assumed_shape_arg(x)
! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_8:.*]]:3 = fir.box_dims %[[VAL_1]]#0, %[[VAL_7]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_10:.*]] = hlfir.elemental %[[VAL_9]] : (!fir.shape<1>) -> !hlfir.expr<?xf32> {
+! CHECK: %[[VAL_10:.*]] = hlfir.elemental %[[VAL_9]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xf32> {
! CHECK: ^bb0(%[[VAL_11:.*]]: index):
! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_1]]#0 (%[[VAL_11]]) : (!fir.box<!fir.array<?xf32>>, index) -> !fir.ref<f32>
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_12]] : !fir.ref<f32>
@@ -70,7 +70,7 @@ subroutine elemental_with_char_args(x,y)
! CHECK-LABEL: func.func @_QPelemental_with_char_args(
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_3:[a-z0-9]*]](%[[VAL_5:[a-z0-9]*]]) typeparams %[[VAL_2:[a-z0-9]*]]#1 {{.*}}Ex
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_1:[a-z0-9]*]] {{.*}}Ey
-! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_5]] : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
+! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_5]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xi32> {
! CHECK: ^bb0(%[[VAL_14:.*]]: index):
! CHECK: %[[VAL_15:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_14]]) typeparams %[[VAL_2]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
! CHECK: %[[VAL_18:.*]]:2 = fir.unboxchar %[[VAL_15]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
@@ -101,7 +101,7 @@ subroutine test_adjustl(x)
end subroutine
! CHECK-LABEL: func.func @_QPtest_adjustl(
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_3:.*]](%[[VAL_5:[a-z0-9]*]]) typeparams %[[VAL_2:[a-z0-9]*]]#1 {{.*}}Ex
-! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_2]]#1 : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
+! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_2]]#1 unordered : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
! CHECK: ^bb0(%[[VAL_8:.*]]: index):
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_8]]) typeparams %[[VAL_2]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
! CHECK: fir.call @_FortranAAdjustl
@@ -117,7 +117,7 @@ subroutine test_adjustr(x)
end subroutine
! CHECK-LABEL: func.func @_QPtest_adjustr(
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_3:.*]](%[[VAL_5:[a-z0-9]*]]) typeparams %[[VAL_2:[a-z0-9]*]]#1 {{.*}}Ex
-! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_2]]#1 : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
+! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_5]] typeparams %[[VAL_2]]#1 unordered : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
! CHECK: ^bb0(%[[VAL_8:.*]]: index):
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_8]]) typeparams %[[VAL_2]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
! CHECK: fir.call @_FortranAAdjustr
@@ -136,7 +136,7 @@ subroutine test_merge(x, y, mask)
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_2:[a-z0-9]*]](%[[VAL_4:[a-z0-9]*]]) {{.*}}Emask
! CHECK: %[[VAL_10:.*]]:2 = hlfir.declare %[[VAL_7:[a-z0-9]*]](%[[VAL_9:[a-z0-9]*]]) typeparams %[[VAL_6:[a-z0-9]*]]#1 {{.*}}Ex
! CHECK: %[[VAL_15:.*]]:2 = hlfir.declare %[[VAL_12:[a-z0-9]*]](%[[VAL_14:[a-z0-9]*]]) typeparams %[[VAL_11:[a-z0-9]*]]#1 {{.*}}Ey
-! CHECK: %[[VAL_16:.*]] = hlfir.elemental %[[VAL_9]] typeparams %[[VAL_6]]#1 : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
+! CHECK: %[[VAL_16:.*]] = hlfir.elemental %[[VAL_9]] typeparams %[[VAL_6]]#1 unordered : (!fir.shape<1>, index) -> !hlfir.expr<100x!fir.char<1,?>> {
! CHECK: ^bb0(%[[VAL_17:.*]]: index):
! CHECK: %[[VAL_18:.*]] = hlfir.designate %[[VAL_10]]#0 (%[[VAL_17]]) typeparams %[[VAL_6]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
! CHECK: %[[VAL_21:.*]]:2 = fir.unboxchar %[[VAL_18]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
diff --git a/flang/test/Lower/HLFIR/elemental-user-procedure-ref-polymorphic.f90 b/flang/test/Lower/HLFIR/elemental-user-procedure-ref-polymorphic.f90
index b4aca062cffd3c..ea3bd7c3456bb1 100644
--- a/flang/test/Lower/HLFIR/elemental-user-procedure-ref-polymorphic.f90
+++ b/flang/test/Lower/HLFIR/elemental-user-procedure-ref-polymorphic.f90
@@ -34,7 +34,7 @@ end function elem
! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_5]], %[[VAL_6]] : (!fir.class<!fir.ptr<!fir.array<?x!fir.type<_QMdef_some_typesTt{i:i32}>>>>, index) -> (index, index, index)
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_8]] : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
+! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
! CHECK: ^bb0(%[[VAL_10:.*]]: index):
! CHECK: %[[VAL_11:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_12:.*]]:3 = fir.box_dims %[[VAL_5]], %[[VAL_11]] : (!fir.class<!fir.ptr<!fir.array<?x!fir.type<_QMdef_some_typesTt{i:i32}>>>>, index) -> (index, index, index)
diff --git a/flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90 b/flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90
index cd0425fe5676ed..65a9aa37c700ff 100644
--- a/flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90
+++ b/flang/test/Lower/HLFIR/elemental-user-procedure-ref.f90
@@ -15,7 +15,7 @@ real elemental function elem(a, b)
! CHECK-LABEL: func.func @_QPby_addr(
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0:.*]] {{.*}}x
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_1:.*]](%[[VAL_4:[^)]*]]) {{.*}}y
-! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_4]] : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
+! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_4]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
! CHECK: ^bb0(%[[VAL_7:.*]]: index):
! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_7]]) : (!fir.ref<!fir.array<100xf32>>, index) -> !fir.ref<f32>
! CHECK: %[[VAL_9:.*]] = fir.call @_QPelem(%[[VAL_2]]#1, %[[VAL_8]]) fastmath<contract> : (!fir.ref<i32>, !fir.ref<f32>) -> f32
@@ -39,7 +39,7 @@ real elemental function elem_val(a, b)
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0:.*]] {{.*}}x
! CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_1:.*]](%[[VAL_5:[^)]*]]) {{.*}}y
! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_2]]#0 : !fir.ref<i32>
-! CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_5]] : (!fir.shape<2>) -> !hlfir.expr<10x20xf32> {
+! CHECK: %[[VAL_8:.*]] = hlfir.elemental %[[VAL_5]] unordered : (!fir.shape<2>) -> !hlfir.expr<10x20xf32> {
! CHECK: ^bb0(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_9]], %[[VAL_10]]) : (!fir.ref<!fir.array<10x20xf32>>, index, index) -> !fir.ref<f32>
! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_11]] : !fir.ref<f32>
@@ -64,7 +64,7 @@ real elemental function char_elem(a, b)
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2:.*]]#0 typeparams %[[VAL_2]]#1 {{.*}}x
! CHECK: %[[VAL_6:.*]] = arith.constant 100 : index
! CHECK: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_5:.*]](%[[VAL_7:.*]]) typeparams %[[VAL_4:.*]]#1 {{.*}}y
-! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_7]] : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
+! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_7]] unordered : (!fir.shape<1>) -> !hlfir.expr<100xf32> {
! CHECK: ^bb0(%[[VAL_10:.*]]: index):
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_8]]#0 (%[[VAL_10]]) typeparams %[[VAL_4]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
! CHECK: %[[VAL_12:.*]] = fir.call @_QPchar_elem(%[[VAL_3]]#0, %[[VAL_11]]) fastmath<contract> : (!fir.boxchar<1>, !fir.boxchar<1>) -> f32
diff --git a/flang/test/Lower/HLFIR/implicit-type-conversion.f90 b/flang/test/Lower/HLFIR/implicit-type-conversion.f90
index 07fc3aab0995c0..ec0fb6e3bb12c2 100644
--- a/flang/test/Lower/HLFIR/implicit-type-conversion.f90
+++ b/flang/test/Lower/HLFIR/implicit-type-conversion.f90
@@ -94,7 +94,7 @@ end subroutine test5
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> (index, index, index)
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
+! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] unordered : (!fir.shape<1>) -> !hlfir.expr<?xi32> {
! CHECK: ^bb0(%[[VAL_8:.*]]: index):
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_8]]) : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !fir.ref<!fir.logical<4>>
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]] : !fir.ref<!fir.logical<4>>
@@ -119,7 +119,7 @@ end subroutine test6
! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]]#0, %[[VAL_4]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_5]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
+! CHECK: %[[VAL_7:.*]] = hlfir.elemental %[[VAL_6]] unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
! CHECK: ^bb0(%[[VAL_8:.*]]: index):
! CHECK: %[[VAL_9:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[VAL_8]]) : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_9]] : !fir.ref<i32>
diff --git a/flang/test/Lower/HLFIR/matmul.f90 b/flang/test/Lower/HLFIR/matmul.f90
index 6e09c18c206578..6cf1495ad08c92 100644
--- a/flang/test/Lower/HLFIR/matmul.f90
+++ b/flang/test/Lower/HLFIR/matmul.f90
@@ -48,7 +48,7 @@ subroutine matmul2(c)
! CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
! CHECK-NEXT: %[[B_DIMS_1:.*]]:3 = fir.box_dims %[[B_BOX]], %[[C1]]
! CHECK-NEXT: %[[B_SHAPE:.*]] = fir.shape %[[B_DIMS_0]]#1, %[[B_DIMS_1]]#1
-! CHECK-NEXT: %[[ELEMENTAL:.*]] = hlfir.elemental %[[B_SHAPE]] : (!fir.shape<2>) -> !hlfir.expr<?x?xi32> {
+! CHECK-NEXT: %[[ELEMENTAL:.*]] = hlfir.elemental %[[B_SHAPE]] unordered : (!fir.shape<2>) -> !hlfir.expr<?x?xi32> {
! CHECK: }
! CHECK-NEXT: %[[A_BOX:.*]] = fir.load %{{.*}} : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
diff --git a/flang/test/Lower/HLFIR/structure-constructor.f90 b/flang/test/Lower/HLFIR/structure-constructor.f90
index 53b7c9d14b692f..3c8699543ee6ce 100644
--- a/flang/test/Lower/HLFIR/structure-constructor.f90
+++ b/flang/test/Lower/HLFIR/structure-constructor.f90
@@ -151,7 +151,7 @@ end subroutine test4
! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_24:.*]]:3 = fir.box_dims %[[VAL_21]], %[[VAL_23]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,2>>>>, index) -> (index, index, index)
! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_24]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_26:.*]] = hlfir.elemental %[[VAL_25]] typeparams %[[VAL_22]] : (!fir.shape<1>, i64) -> !hlfir.expr<?x!fir.char<1,?>> {
+! CHECK: %[[VAL_26:.*]] = hlfir.elemental %[[VAL_25]] typeparams %[[VAL_22]] unordered : (!fir.shape<1>, i64) -> !hlfir.expr<?x!fir.char<1,?>> {
! CHECK: ^bb0(%[[VAL_27:.*]]: index):
! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_29:.*]]:3 = fir.box_dims %[[VAL_21]], %[[VAL_28]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,2>>>>, index) -> (index, index, index)
diff --git a/flang/test/Lower/HLFIR/user-defined-assignment.f90 b/flang/test/Lower/HLFIR/user-defined-assignment.f90
index 5344379b5f7c8f..64ff2428d9e449 100644
--- a/flang/test/Lower/HLFIR/user-defined-assignment.f90
+++ b/flang/test/Lower/HLFIR/user-defined-assignment.f90
@@ -97,7 +97,7 @@ subroutine test_non_elemental_array(x)
! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_1]]#0, %[[VAL_3]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_5]] : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
+! CHECK: %[[VAL_6:.*]] = hlfir.elemental %[[VAL_5]] unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
! CHECK: ^bb0(%[[VAL_7:.*]]: index):
! CHECK: %[[VAL_8:.*]] = hlfir.designate %[[VAL_1]]#0 (%[[VAL_7]]) : (!fir.box<!fir.array<?xf32>>, index) -> !fir.ref<f32>
! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_8]] : !fir.ref<f32>
@@ -136,7 +136,7 @@ subroutine test_where_user_def_assignment(i, l, l2)
! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_4]]#0, %[[VAL_6]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> (index, index, index)
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]]#1 : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_8]] : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
+! CHECK: %[[VAL_9:.*]] = hlfir.elemental %[[VAL_8]] unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.logical<4>> {
! CHECK: ^bb0(%[[VAL_10:.*]]: index):
! CHECK: %[[VAL_11:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_10]]) : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !fir.ref<!fir.logical<4>>
! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_10]]) : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !fir.ref<!fir.logical<4>>
diff --git a/flang/test/Lower/HLFIR/vector-subscript-as-value.f90 b/flang/test/Lower/HLFIR/vector-subscript-as-value.f90
index 3e3daa8093183a..76b2285391dcbd 100644
--- a/flang/test/Lower/HLFIR/vector-subscript-as-value.f90
+++ b/flang/test/Lower/HLFIR/vector-subscript-as-value.f90
@@ -16,7 +16,7 @@ subroutine foo(x, y)
! CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_1:[a-z0-9]*]](%[[VAL_6:[a-z0-9]*]]) {{.*}}Ey
! CHECK: %[[VAL_8:.*]] = arith.constant 20 : index
! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_10:.*]] = hlfir.elemental %[[VAL_9]] : (!fir.shape<1>) -> !hlfir.expr<20xi32> {
+! CHECK: %[[VAL_10:.*]] = hlfir.elemental %[[VAL_9]] unordered : (!fir.shape<1>) -> !hlfir.expr<20xi32> {
! CHECK: ^bb0(%[[VAL_11:.*]]: index):
! CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[VAL_11]]) : (!fir.ref<!fir.array<20xi64>>, index) -> !fir.ref<i64>
! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_12]] : !fir.ref<i64>
@@ -49,7 +49,7 @@ subroutine foo2(x, y)
! CHECK: %[[VAL_13:.*]] = arith.constant 5 : index
! CHECK: %[[VAL_14:.*]] = arith.constant 20 : index
! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_12]], %[[VAL_14]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_16:.*]] = hlfir.elemental %[[VAL_15]] : (!fir.shape<2>) -> !hlfir.expr<4x20xi32> {
+! CHECK: %[[VAL_16:.*]] = hlfir.elemental %[[VAL_15]] unordered : (!fir.shape<2>) -> !hlfir.expr<4x20xi32> {
! CHECK: ^bb0(%[[VAL_17:.*]]: index, %[[VAL_18:.*]]: index):
! CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
! CHECK: %[[VAL_20:.*]] = arith.subi %[[VAL_17]], %[[VAL_19]] : index
@@ -79,7 +79,7 @@ subroutine foo3(x, y)
! CHECK: %[[VAL_10:.*]] = arith.constant 5 : index
! CHECK: %[[VAL_11:.*]] = arith.constant 20 : index
! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_9]], %[[VAL_11]] : (index, index) -> !fir.shape<2>
-! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_12]] : (!fir.shape<2>) -> !hlfir.expr<4x20xi32> {
+! CHECK: %[[VAL_13:.*]] = hlfir.elemental %[[VAL_12]] unordered : (!fir.shape<2>) -> !hlfir.expr<4x20xi32> {
! CHECK: ^bb0(%[[VAL_14:.*]]: index, %[[VAL_15:.*]]: index):
! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_14]], %[[VAL_16]] : index
@@ -136,7 +136,7 @@ subroutine foo4(at1, vector, i, j, k, l, step)
! CHECK: %[[VAL_36:.*]] = fir.shape %[[VAL_34]], %[[VAL_35]] : (index, index) -> !fir.shape<2>
! CHECK: %[[VAL_37:.*]] = fir.load %[[VAL_10]]#0 : !fir.ref<i64>
! CHECK: %[[VAL_38:.*]] = fir.load %[[VAL_11]]#0 : !fir.ref<i64>
-! CHECK: %[[VAL_39:.*]] = hlfir.elemental %[[VAL_33]] : (!fir.shape<2>) -> !hlfir.expr<?x?xf32> {
+! CHECK: %[[VAL_39:.*]] = hlfir.elemental %[[VAL_33]] unordered : (!fir.shape<2>) -> !hlfir.expr<?x?xf32> {
! CHECK: ^bb0(%[[VAL_40:.*]]: index, %[[VAL_41:.*]]: index):
! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
! CHECK: %[[VAL_43:.*]] = arith.subi %[[VAL_40]], %[[VAL_42]] : index
@@ -175,7 +175,7 @@ subroutine substring(c, vector, i, j)
! CHECK: %[[VAL_20:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_21:.*]] = arith.cmpi sgt, %[[VAL_19]], %[[VAL_20]] : index
! CHECK: %[[VAL_22:.*]] = arith.select %[[VAL_21]], %[[VAL_19]], %[[VAL_20]] : index
-! CHECK: %[[VAL_23:.*]] = hlfir.elemental %[[VAL_12]] typeparams %[[VAL_22]] : (!fir.shape<1>, index) -> !hlfir.expr<?x!fir.char<1,?>> {
+! CHECK: %[[VAL_23:.*]] = hlfir.elemental %[[VAL_12]] typeparams %[[VAL_22]] unordered : (!fir.shape<1>, index) -> !hlfir.expr<?x!fir.char<1,?>> {
! CHECK: ^bb0(%[[VAL_24:.*]]: index):
! CHECK: %[[VAL_25:.*]] = hlfir.designate %[[VAL_9]]#0 (%[[VAL_24]]) : (!fir.box<!fir.array<?xi64>>, index) -> !fir.ref<i64>
! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_25]] : !fir.ref<i64>
diff --git a/flang/test/Lower/HLFIR/vector-subscript-lhs.f90 b/flang/test/Lower/HLFIR/vector-subscript-lhs.f90
index f69925fe769559..48dfa5b0f20d6a 100644
--- a/flang/test/Lower/HLFIR/vector-subscript-lhs.f90
+++ b/flang/test/Lower/HLFIR/vector-subscript-lhs.f90
@@ -16,7 +16,7 @@ subroutine test_simple(x, vector)
! CHECK: } to {
! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
-! CHECK: hlfir.elemental_addr %[[VAL_8]] : !fir.shape<1> {
+! CHECK: hlfir.elemental_addr %[[VAL_8]] unordered : !fir.shape<1> {
! CHECK: ^bb0(%[[VAL_9:.*]]: index):
! CHECK: %[[VAL_10:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_9]]) : (!fir.ref<!fir.array<10xi64>>, index) -> !fir.ref<i64>
! CHECK: %[[VAL_11:.*]] = fir.load %[[VAL_10]] : !fir.ref<i64>
@@ -41,7 +41,7 @@ subroutine test_cleanup(x, vector, matrix)
! 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>
! CHECK: %[[VAL_13:.*]] = arith.constant 5 : index
! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
-! CHECK: hlfir.elemental_addr %[[VAL_14]] : !fir.shape<1> {
+! CHECK: hlfir.elemental_addr %[[VAL_14]] unordered : !fir.shape<1> {
! CHECK: ^bb0(%[[VAL_15:.*]]: index):
! CHECK: %[[VAL_16:.*]] = hlfir.apply %[[VAL_12]], %[[VAL_15]] : (!hlfir.expr<5xi64>, index) -> i64
! CHECK: %[[VAL_17:.*]] = hlfir.designate %[[VAL_10]]#0 (%[[VAL_16]]) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
@@ -67,7 +67,7 @@ subroutine test_nested_vectors(x, vector1, vector2, vector3)
! CHECK: } to {
! CHECK: %[[VAL_15:.*]] = arith.constant 6 : index
! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_17:.*]] = hlfir.elemental %[[VAL_16]] : (!fir.shape<1>) -> !hlfir.expr<6xi64> {
+! CHECK: %[[VAL_17:.*]] = hlfir.elemental %[[VAL_16]] unordered : (!fir.shape<1>) -> !hlfir.expr<6xi64> {
! CHECK: ^bb0(%[[VAL_18:.*]]: index):
! CHECK: %[[VAL_19:.*]] = hlfir.designate %[[VAL_12]]#0 (%[[VAL_18]]) : (!fir.ref<!fir.array<6xi64>>, index) -> !fir.ref<i64>
! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_19]] : !fir.ref<i64>
@@ -77,7 +77,7 @@ subroutine test_nested_vectors(x, vector1, vector2, vector3)
! CHECK: }
! CHECK: %[[VAL_23:.*]] = arith.constant 6 : index
! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_23]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_25:.*]] = hlfir.elemental %[[VAL_24]] : (!fir.shape<1>) -> !hlfir.expr<6xi64> {
+! CHECK: %[[VAL_25:.*]] = hlfir.elemental %[[VAL_24]] unordered : (!fir.shape<1>) -> !hlfir.expr<6xi64> {
! CHECK: ^bb0(%[[VAL_26:.*]]: index):
! CHECK: %[[VAL_27:.*]] = hlfir.apply %[[VAL_28:.*]], %[[VAL_26]] : (!hlfir.expr<6xi64>, index) -> i64
! CHECK: %[[VAL_29:.*]] = hlfir.designate %[[VAL_6]]#0 (%[[VAL_27]]) : (!fir.ref<!fir.array<10xi64>>, i64) -> !fir.ref<i64>
@@ -86,7 +86,7 @@ subroutine test_nested_vectors(x, vector1, vector2, vector3)
! CHECK: }
! CHECK: %[[VAL_31:.*]] = arith.constant 6 : index
! CHECK: %[[VAL_32:.*]] = fir.shape %[[VAL_31]] : (index) -> !fir.shape<1>
-! CHECK: hlfir.elemental_addr %[[VAL_32]] : !fir.shape<1> {
+! CHECK: hlfir.elemental_addr %[[VAL_32]] unordered : !fir.shape<1> {
! CHECK: ^bb0(%[[VAL_33:.*]]: index):
! CHECK: %[[VAL_34:.*]] = hlfir.apply %[[VAL_35:.*]], %[[VAL_33]] : (!hlfir.expr<6xi64>, index) -> i64
! CHECK: %[[VAL_36:.*]] = hlfir.designate %[[VAL_13]]#0 (%[[VAL_34]]) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
@@ -124,7 +124,7 @@ subroutine test_substring(x, vector)
! CHECK: %[[VAL_18:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_19:.*]] = arith.cmpi sgt, %[[VAL_17]], %[[VAL_18]] : index
! CHECK: %[[VAL_20:.*]] = arith.select %[[VAL_19]], %[[VAL_17]], %[[VAL_18]] : index
-! CHECK: hlfir.elemental_addr %[[VAL_10]] typeparams %[[VAL_20]] : !fir.shape<1>, index {
+! CHECK: hlfir.elemental_addr %[[VAL_10]] typeparams %[[VAL_20]] unordered : !fir.shape<1>, index {
! CHECK: ^bb0(%[[VAL_21:.*]]: index):
! CHECK: %[[VAL_22:.*]] = hlfir.designate %[[VAL_4]]#0 (%[[VAL_21]]) : (!fir.ref<!fir.array<10xi64>>, index) -> !fir.ref<i64>
! CHECK: %[[VAL_23:.*]] = fir.load %[[VAL_22]] : !fir.ref<i64>
@@ -172,7 +172,7 @@ subroutine test_hard_array_ref(x, vector1, vector2)
! CHECK: %[[VAL_33:.*]] = fir.call @_QPibaz() {{.*}}: () -> i64
! CHECK: %[[VAL_34:.*]] = arith.constant 20 : index
! CHECK: %[[VAL_35:.*]] = fir.shape %[[VAL_11]], %[[VAL_21]], %[[VAL_32]], %[[VAL_34]] : (index, index, index, index) -> !fir.shape<4>
-! CHECK: hlfir.elemental_addr %[[VAL_35]] : !fir.shape<4> {
+! CHECK: hlfir.elemental_addr %[[VAL_35]] unordered : !fir.shape<4> {
! CHECK: ^bb0(%[[VAL_36:.*]]: index, %[[VAL_37:.*]]: index, %[[VAL_38:.*]]: index, %[[VAL_39:.*]]: index):
! CHECK: %[[VAL_40:.*]] = hlfir.designate %[[VAL_5]]#0 (%[[VAL_36]]) : (!fir.ref<!fir.array<10xi64>>, index) -> !fir.ref<i64>
! CHECK: %[[VAL_41:.*]] = fir.load %[[VAL_40]] : !fir.ref<i64>
More information about the flang-commits
mailing list