[flang-commits] [flang] aa96793 - [flang] Change return type of reduction intrinsics
Jacob Crawley via flang-commits
flang-commits at lists.llvm.org
Fri May 19 07:35:59 PDT 2023
Author: Jacob Crawley
Date: 2023-05-19T14:32:06Z
New Revision: aa9679304011170905a37758c6ce5c0c6e7a6265
URL: https://github.com/llvm/llvm-project/commit/aa9679304011170905a37758c6ce5c0c6e7a6265
DIFF: https://github.com/llvm/llvm-project/commit/aa9679304011170905a37758c6ce5c0c6e7a6265.diff
LOG: [flang] Change return type of reduction intrinsics
Comments in the recent patch https://reviews.llvm.org/D149964,
mentioned that using hlfir_ExprType in cases where intrinsics
return simple scalars adds unnecessary abstraction that isn't
needed unless an array type is being used.
This patch modifies the HLFIR operations for product, sum and any
so that they only return a hlfir_ExprType when the result is an array,
otherwise they will return just the simple scalar type.
Differential Revision: https://reviews.llvm.org/D150877
Added:
Modified:
flang/include/flang/Optimizer/HLFIR/HLFIROps.td
flang/lib/Lower/ConvertCall.cpp
flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
flang/test/HLFIR/any-lowering.fir
flang/test/HLFIR/any.fir
flang/test/HLFIR/flang-experimental-hlfir-flag.f90
flang/test/HLFIR/invalid.fir
flang/test/HLFIR/product-lowering.fir
flang/test/HLFIR/product.fir
flang/test/HLFIR/sum-lowering.fir
flang/test/HLFIR/sum.fir
flang/test/Lower/HLFIR/any.f90
flang/test/Lower/HLFIR/product.f90
flang/test/Lower/HLFIR/sum.f90
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/HLFIR/HLFIROps.td b/flang/include/flang/Optimizer/HLFIR/HLFIROps.td
index 1fe3ebac429d..572faf06d14c 100644
--- a/flang/include/flang/Optimizer/HLFIR/HLFIROps.td
+++ b/flang/include/flang/Optimizer/HLFIR/HLFIROps.td
@@ -329,7 +329,7 @@ def hlfir_AnyOp : hlfir_Op<"any", []> {
Optional<AnyIntegerType>:$dim
);
- let results = (outs hlfir_ExprType);
+ let results = (outs AnyFortranValue);
let assemblyFormat = [{
$mask (`dim` $dim^)? attr-dict `:` functional-type(operands, results)
@@ -355,7 +355,7 @@ def hlfir_ProductOp : hlfir_Op<"product", [AttrSizedOperandSegments,
"::mlir::arith::FastMathFlags::none">:$fastmath
);
- let results = (outs hlfir_ExprType);
+ let results = (outs AnyFortranValue);
let assemblyFormat = [{
$array (`dim` $dim^)? (`mask` $mask^)? attr-dict `:` functional-type(operands, results)
@@ -400,7 +400,7 @@ def hlfir_SumOp : hlfir_Op<"sum", [AttrSizedOperandSegments,
"::mlir::arith::FastMathFlags::none">:$fastmath
);
- let results = (outs hlfir_ExprType);
+ let results = (outs AnyFortranValue);
let assemblyFormat = [{
$array (`dim` $dim^)? (`mask` $mask^)? attr-dict `:` functional-type(operands, results)
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index d2d91735e21a..17fbdc437aa8 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -1356,11 +1356,12 @@ genHLFIRIntrinsicRefCore(PreparedActualArguments &loweredActuals,
if (auto array = normalisedResult.dyn_cast<fir::SequenceType>()) {
resultShape = hlfir::ExprType::Shape{array.getShape()};
elementType = array.getEleTy();
- } else {
- elementType = normalisedResult;
+ return hlfir::ExprType::get(builder.getContext(), resultShape,
+ elementType,
+ /*polymorphic=*/false);
}
- return hlfir::ExprType::get(builder.getContext(), resultShape, elementType,
- /*polymorphic=*/false);
+ elementType = normalisedResult;
+ return elementType;
};
auto buildSumOperation = [](fir::FirOpBuilder &builder, mlir::Location loc,
diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
index b399a457d13d..9619eb0c1f70 100644
--- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
+++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
@@ -451,31 +451,41 @@ mlir::LogicalResult hlfir::AnyOp::verify() {
assert(results.size() == 1);
mlir::Value mask = getMask();
+ mlir::Value dim = getDim();
fir::SequenceType maskTy =
hlfir::getFortranElementOrSequenceType(mask.getType())
.cast<fir::SequenceType>();
mlir::Type logicalTy = maskTy.getEleTy();
llvm::ArrayRef<int64_t> maskShape = maskTy.getShape();
- hlfir::ExprType resultTy = results[0].cast<hlfir::ExprType>();
- // Result is of the same type as MASK
- if (resultTy.getElementType() != logicalTy)
- return emitOpError(
- "result must have the same element type as MASK argument");
-
- if (resultTy.isArray()) {
+ mlir::Type resultType = results[0];
+ if (mlir::isa<fir::LogicalType>(resultType)) {
// Result is of the same type as MASK
- if (resultTy.getEleTy() != logicalTy)
+ if (resultType != logicalTy)
return emitOpError(
"result must have the same element type as MASK argument");
- llvm::ArrayRef<int64_t> resultShape = resultTy.getShape();
+ } else if (auto resultExpr =
+ mlir::dyn_cast_or_null<hlfir::ExprType>(resultType)) {
+ // Result should only be in hlfir.expr form if it is an array
+ if (maskShape.size() > 1 && dim != nullptr) {
+ if (!resultExpr.isArray())
+ return emitOpError("result must be an array");
- // Result has rank n-1
- if (resultShape.size() != (maskShape.size() - 1))
- return emitOpError("result rank must be one less than MASK");
- }
+ if (resultExpr.getEleTy() != logicalTy)
+ return emitOpError(
+ "result must have the same element type as MASK argument");
+ llvm::ArrayRef<int64_t> resultShape = resultExpr.getShape();
+ // Result has rank n-1
+ if (resultShape.size() != (maskShape.size() - 1))
+ return emitOpError("result rank must be one less than MASK");
+ } else {
+ return emitOpError("result must be of logical type");
+ }
+ } else {
+ return emitOpError("result must be of logical type");
+ }
return mlir::success();
}
@@ -538,6 +548,7 @@ static mlir::LogicalResult verifyReductionOp(ReductionOp reductionOp) {
assert(results.size() == 1);
mlir::Value array = reductionOp->getArray();
+ mlir::Value dim = reductionOp->getDim();
mlir::Value mask = reductionOp->getMask();
fir::SequenceType arrayTy =
@@ -545,7 +556,6 @@ static mlir::LogicalResult verifyReductionOp(ReductionOp reductionOp) {
.cast<fir::SequenceType>();
mlir::Type numTy = arrayTy.getEleTy();
llvm::ArrayRef<int64_t> arrayShape = arrayTy.getShape();
- hlfir::ExprType resultTy = results[0].cast<hlfir::ExprType>();
if (mask) {
fir::SequenceType maskSeq =
@@ -572,25 +582,35 @@ static mlir::LogicalResult verifyReductionOp(ReductionOp reductionOp) {
}
}
- if (resultTy.isArray()) {
+ mlir::Type resultType = results[0];
+ if (hlfir::isFortranScalarNumericalType(resultType)) {
// Result is of the same type as ARRAY
- if (resultTy.getEleTy() != numTy)
+ if (resultType != numTy)
return reductionOp->emitOpError(
"result must have the same element type as ARRAY argument");
- llvm::ArrayRef<int64_t> resultShape = resultTy.getShape();
-
- // Result has rank n-1
- if (resultShape.size() != (arrayShape.size() - 1))
+ } else if (auto resultExpr =
+ mlir::dyn_cast_or_null<hlfir::ExprType>(resultType)) {
+ if (arrayShape.size() > 1 && dim != nullptr) {
+ if (!resultExpr.isArray())
+ return reductionOp->emitOpError("result must be an array");
+
+ if (resultExpr.getEleTy() != numTy)
+ return reductionOp->emitOpError(
+ "result must have the same element type as ARRAY argument");
+
+ llvm::ArrayRef<int64_t> resultShape = resultExpr.getShape();
+ // Result has rank n-1
+ if (resultShape.size() != (arrayShape.size() - 1))
+ return reductionOp->emitOpError(
+ "result rank must be one less than ARRAY");
+ } else {
return reductionOp->emitOpError(
- "result rank must be one less than ARRAY");
+ "result must be of numerical scalar type");
+ }
} else {
- // Result is of the same type as ARRAY
- if (resultTy.getElementType() != numTy)
- return reductionOp->emitOpError(
- "result must have the same element type as ARRAY argument");
+ return reductionOp->emitOpError("result must be of numerical scalar type");
}
-
return mlir::success();
}
diff --git a/flang/test/HLFIR/any-lowering.fir b/flang/test/HLFIR/any-lowering.fir
index 2c750ce35bd3..ef8b89502931 100644
--- a/flang/test/HLFIR/any-lowering.fir
+++ b/flang/test/HLFIR/any-lowering.fir
@@ -5,9 +5,8 @@
func.func @_QPany1(%arg0: !fir.box<!fir.array<?x!fir.logical<4>>> {fir.bindc_name = "a"}, %arg1: !fir.ref<!fir.logical<4>> {fir.bindc_name = "s"}) {
%0:2 = hlfir.declare %arg0 {uniq_name = "_QFany1Ea"} : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>)
%1:2 = hlfir.declare %arg1 {uniq_name = "_QFany1Es"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
- %2 = hlfir.any %0#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
- hlfir.assign %2 to %1#0 : !hlfir.expr<!fir.logical<4>>, !fir.ref<!fir.logical<4>>
- hlfir.destroy %2 : !hlfir.expr<!fir.logical<4>>
+ %2 = hlfir.any %0#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.logical<4>
+ hlfir.assign %2 to %1#0 : !fir.logical<4>, !fir.ref<!fir.logical<4>>
return
}
// CHECK-LABEL: func.func @_QPany1(
diff --git a/flang/test/HLFIR/any.fir b/flang/test/HLFIR/any.fir
index cccbf831f306..dbea5ba478b9 100644
--- a/flang/test/HLFIR/any.fir
+++ b/flang/test/HLFIR/any.fir
@@ -4,71 +4,71 @@
// mask is an expression of known shape
func.func @any0(%arg0: !hlfir.expr<2x!fir.logical<4>>) {
- %any = hlfir.any %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> !fir.logical<4>
return
}
// CHECK: func.func @any0(%[[ARRAY:.*]]: !hlfir.expr<2x!fir.logical<4>>) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!hlfir.expr<2x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!hlfir.expr<2x!fir.logical<4>>) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
// mask is an expression of assumed shape
func.func @any1(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
- %any = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !fir.logical<4>
return
}
// CHECK: func.func @any1(%[[ARRAY:.*]]: !hlfir.expr<?x!fir.logical<4>>) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!hlfir.expr<?x!fir.logical<4>>) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
// mask is a boxed array
func.func @any2(%arg0: !fir.box<!fir.array<2x!fir.logical<4>>>) {
- %any = hlfir.any %arg0 : (!fir.box<!fir.array<2x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 : (!fir.box<!fir.array<2x!fir.logical<4>>>) -> !fir.logical<4>
return
}
// CHECK: func.func @any2(%[[ARRAY:.*]]: !fir.box<!fir.array<2x!fir.logical<4>>>) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<2x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<2x!fir.logical<4>>>) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
// mask is an assumed shape boxed array
func.func @any3(%arg0: !fir.box<!fir.array<?x!fir.logical<4>>>){
- %any = hlfir.any %arg0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.logical<4>
return
}
// CHECK: func.func @any3(%[[ARRAY:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
// mask is a 2-dimensional array
func.func @any4(%arg0: !fir.box<!fir.array<?x?x!fir.logical<4>>>){
- %any = hlfir.any %arg0 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !fir.logical<4>
return
}
// CHECK: func.func @any4(%[[ARRAY:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
// mask and dim argument
func.func @any5(%arg0: !fir.box<!fir.array<?x!fir.logical<4>>>, %arg1: i32) {
- %any = hlfir.any %arg0 dim %arg1 : (!fir.box<!fir.array<?x!fir.logical<4>>>, i32) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 dim %arg1 : (!fir.box<!fir.array<?x!fir.logical<4>>>, i32) -> !fir.logical<4>
return
}
// CHECK: func.func @any5(%[[ARRAY:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>, %[[DIM:.*]]: i32) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] dim %[[DIM]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, i32) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] dim %[[DIM]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, i32) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
// hlfir.any with dim argument with an unusual type
func.func @any6(%arg0: !fir.box<!fir.array<?x!fir.logical<4>>>, %arg1: index) {
- %any = hlfir.any %arg0 dim %arg1 : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 dim %arg1 : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) ->!fir.logical<4>
return
}
// CHECK: func.func @any6(%[[ARRAY:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>, %[[DIM:.*]]: index) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] dim %[[DIM]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] dim %[[DIM]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, index) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -94,20 +94,20 @@ func.func @any8(%arg0: !fir.box<!fir.array<2x2x!fir.logical<4>>>, %arg1: i32) {
// hlfir.any with mask argument of ref<array<>> type
func.func @any9(%arg0: !fir.ref<!fir.array<?x!fir.logical<4>>>) {
- %any = hlfir.any %arg0 : (!fir.ref<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+ %any = hlfir.any %arg0 : (!fir.ref<!fir.array<?x!fir.logical<4>>>) -> !fir.logical<4>
return
}
// CHECK: func.func @any9(%[[ARRAY:.*]]: !fir.ref<!fir.array<?x!fir.logical<4>>>) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.ref<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.ref<!fir.array<?x!fir.logical<4>>>) -> !fir.logical<4>
// CHECK-NEXT: return
// CHECK-NEXT: }
// hlfir.any with fir.logical<8> type
func.func @any10(%arg0: !fir.box<!fir.array<?x!fir.logical<8>>>) {
- %any = hlfir.any %arg0 : (!fir.box<!fir.array<?x!fir.logical<8>>>) -> !hlfir.expr<!fir.logical<8>>
+ %any = hlfir.any %arg0 : (!fir.box<!fir.array<?x!fir.logical<8>>>) -> !fir.logical<8>
return
}
// CHECK: func.func @any10(%[[ARRAY:.*]]: !fir.box<!fir.array<?x!fir.logical<8>>>) {
-// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<?x!fir.logical<8>>>) -> !hlfir.expr<!fir.logical<8>>
+// CHECK-NEXT: %[[ANY:.*]] = hlfir.any %[[ARRAY]] : (!fir.box<!fir.array<?x!fir.logical<8>>>) -> !fir.logical<8>
// CHECK-NEXT: return
// CHECK-NEXT: }
diff --git a/flang/test/HLFIR/flang-experimental-hlfir-flag.f90 b/flang/test/HLFIR/flang-experimental-hlfir-flag.f90
index a375d2726104..4d9191c6d486 100644
--- a/flang/test/HLFIR/flang-experimental-hlfir-flag.f90
+++ b/flang/test/HLFIR/flang-experimental-hlfir-flag.f90
@@ -13,7 +13,6 @@ subroutine test(a, res)
! CHECK-DAG: %[[RES_VAR:.*]]:2 = hlfir.declare %[[RES]]
! CHECK-NEXT: %[[SUM_RES:.*]] = hlfir.sum %[[A_VAR]]#0
! CHECK-NEXT: hlfir.assign %[[SUM_RES]] to %[[RES_VAR]]#0
-! CHECK-NEXT: hlfir.destroy %[[SUM_RES]]
! CHECK-NEXT: return
! CHECK-NEXT: }
diff --git a/flang/test/HLFIR/invalid.fir b/flang/test/HLFIR/invalid.fir
index e4e9cd00b41b..e1c95c1046dc 100644
--- a/flang/test/HLFIR/invalid.fir
+++ b/flang/test/HLFIR/invalid.fir
@@ -299,13 +299,13 @@ func.func @bad_concat_4(%arg0: !fir.ref<!fir.char<1,30>>) {
// -----
func.func @bad_any1(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
// expected-error at +1 {{'hlfir.any' op result must have the same element type as MASK argument}}
- %0 = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<8>>
+ %0 = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !fir.logical<8>
}
// -----
-func.func @bad_any2(%arg0: !hlfir.expr<?x?x!fir.logical<4>>) {
+func.func @bad_any2(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32) {
// expected-error at +1 {{'hlfir.any' op result must have the same element type as MASK argument}}
- %0 = hlfir.any %arg0 : (!hlfir.expr<?x?x!fir.logical<4>>) -> !hlfir.expr<?x!fir.logical<8>>
+ %0 = hlfir.any %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<?x!fir.logical<8>>
}
// -----
@@ -314,11 +314,28 @@ func.func @bad_any3(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32){
%0 = hlfir.any %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<?x?x!fir.logical<4>>
}
+// -----
+func.func @bad_any4(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32) {
+ // expected-error at +1 {{'hlfir.any' op result must be an array}}
+ %0 = hlfir.any %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<!fir.logical<4>>
+}
+
+// -----
+func.func @bad_any5(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
+ // expected-error at +1 {{'hlfir.any' op result must be of logical type}}
+ %0 = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> i32
+}
+
+// -----
+func.func @bad_any6(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
+ // expected-error at +1 {{'hlfir.any' op result must be of logical type}}
+ %0 = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<4>>
+}
// -----
func.func @bad_product1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
// expected-error at +1 {{'hlfir.product' op result must have the same element type as ARRAY argument}}
- %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<f32>
+ %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
}
// -----
@@ -334,15 +351,33 @@ func.func @bad_product3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.b
}
// -----
-func.func @bad_product4(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
+func.func @bad_product4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
// expected-error at +1 {{'hlfir.product' op result rank must be one less than ARRAY}}
- %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
+ %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
+}
+
+// -----
+func.func @bad_product5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
+ // expected-error at +1 {{'hlfir.product' op result must be of numerical scalar type}}
+ %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
+}
+
+// -----
+func.func @bad_product6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
+ // expected-error at +1 {{'hlfir.product' op result must be an array}}
+ %0 = hlfir.product %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
+}
+
+// -----
+func.func @bad_product7(%arg0: !hlfir.expr<?xi32>){
+ // expected-error at +1 {{'hlfir.product' op result must be of numerical scalar type}}
+ %0 = hlfir.product %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<i32>
}
// -----
func.func @bad_sum1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
// expected-error at +1 {{'hlfir.sum' op result must have the same element type as ARRAY argument}}
- %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<f32>
+ %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
}
// -----
@@ -358,9 +393,27 @@ func.func @bad_sum3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.box<!
}
// -----
-func.func @bad_sum4(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
+func.func @bad_sum4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
// expected-error at +1 {{'hlfir.sum' op result rank must be one less than ARRAY}}
- %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
+ %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
+}
+
+// -----
+func.func @bad_sum5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
+ // expected-error at +1 {{'hlfir.sum' op result must be of numerical scalar type}}
+ %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
+}
+
+// -----
+func.func @bad_sum6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
+ // expected-error at +1 {{'hlfir.sum' op result must be an array}}
+ %0 = hlfir.sum %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
+}
+
+// -----
+func.func @bad_sum7(%arg0: !hlfir.expr<?xi32>){
+ // expected-error at +1 {{'hlfir.sum' op result must be of numerical scalar type}}
+ %0 = hlfir.sum %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<i32>
}
// -----
diff --git a/flang/test/HLFIR/product-lowering.fir b/flang/test/HLFIR/product-lowering.fir
index e22869ffc4c7..aedc49967327 100644
--- a/flang/test/HLFIR/product-lowering.fir
+++ b/flang/test/HLFIR/product-lowering.fir
@@ -5,9 +5,8 @@
func.func @_QPproduct1(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}, %arg1: !fir.ref<i32> {fir.bindc_name = "s"}) {
%0:2 = hlfir.declare %arg0 {uniq_name = "_QFsum1Ea"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
%1:2 = hlfir.declare %arg1 {uniq_name = "_QFsum1Es"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
- %2 = hlfir.product %0#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> !hlfir.expr<i32>
- hlfir.assign %2 to %1#0 : !hlfir.expr<i32>, !fir.ref<i32>
- hlfir.destroy %2 : !hlfir.expr<i32>
+ %2 = hlfir.product %0#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> i32
+ hlfir.assign %2 to %1#0 : i32, !fir.ref<i32>
return
}
@@ -77,9 +76,8 @@ func.func @_QPproduct3(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}
%0:2 = hlfir.declare %arg0 {uniq_name = "_QFproduct3Ea"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
%1:2 = hlfir.declare %arg2 {uniq_name = "_QFproduct3Em"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
%2:2 = hlfir.declare %arg1 {uniq_name = "_QFproduct3Es"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
- %3 = hlfir.product %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> !hlfir.expr<i32>
- hlfir.assign %3 to %2#0 : !hlfir.expr<i32>, !fir.ref<i32>
- hlfir.destroy %3 : !hlfir.expr<i32>
+ %3 = hlfir.product %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> i32
+ hlfir.assign %3 to %2#0 : i32, !fir.ref<i32>
return
}
@@ -103,9 +101,8 @@ func.func @_QPproduct4(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}
%0:2 = hlfir.declare %arg0 {uniq_name = "_QFproduct4Ea"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
%1:2 = hlfir.declare %arg2 {uniq_name = "_QFproduct4Em"} : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>)
%2:2 = hlfir.declare %arg1 {uniq_name = "_QFproduct4Es"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
- %3 = hlfir.product %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
- hlfir.assign %3 to %2#0 : !hlfir.expr<i32>, !fir.ref<i32>
- hlfir.destroy %3 : !hlfir.expr<i32>
+ %3 = hlfir.product %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
+ hlfir.assign %3 to %2#0 : i32, !fir.ref<i32>
return
}
diff --git a/flang/test/HLFIR/product.fir b/flang/test/HLFIR/product.fir
index b0c7dfe1797e..e10a4a2ee074 100644
--- a/flang/test/HLFIR/product.fir
+++ b/flang/test/HLFIR/product.fir
@@ -10,7 +10,7 @@ func.func @product0(%arg0: !hlfir.expr<42xi32>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @product0(%[[ARRAY:.*]]: !hlfir.expr<42xi32>) {
@@ -20,7 +20,7 @@ func.func @product0(%arg0: !hlfir.expr<42xi32>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL]] to %[[MASK]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %0 : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -32,7 +32,7 @@ func.func @product1(%arg0: !hlfir.expr<?xi32>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @product1(%[[ARRAY:.*]]: !hlfir.expr<?xi32>) {
@@ -42,7 +42,7 @@ func.func @product1(%arg0: !hlfir.expr<?xi32>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL:.*]] to %[[MASK:.*]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %[[MASK:.*]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.product %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -54,7 +54,7 @@ func.func @product2(%arg0: !fir.box<!fir.array<42xi32>>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @product2(%[[ARRAY:.*]]: !fir.box<!fir.array<42xi32>>) {
@@ -64,7 +64,7 @@ func.func @product2(%arg0: !fir.box<!fir.array<42xi32>>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL:.*]] to %[[MASK:.*]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %[[MASK:.*]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.product %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -76,7 +76,7 @@ func.func @product3(%arg0: !fir.box<!fir.array<?xi32>>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @product3(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>) {
@@ -86,55 +86,55 @@ func.func @product3(%arg0: !fir.box<!fir.array<?xi32>>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL:.*]] to %[[MASK:.*]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %[[MASK:.*]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.product %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// known shape expr mask
func.func @product4(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !hlfir.expr<42x!fir.logical<4>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @product4(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !hlfir.expr<42x!fir.logical<4>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// assumed shape expr mask
func.func @product5(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !hlfir.expr<?x!fir.logical<4>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @product5(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !hlfir.expr<?x!fir.logical<4>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// known shape array mask
func.func @product6(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.box<!fir.array<42x!fir.logical<4>>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> i32
return
}
// CHECK: func.func @product6(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.box<!fir.array<42x!fir.logical<4>>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// assumed shape array mask
func.func @product7(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.box<!fir.array<?x!fir.logical<4>>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+ %0 = hlfir.product %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
return
}
// CHECK: func.func @product7(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.product %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -181,11 +181,11 @@ func.func @product9(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: i32) {
// hlfir.product with only an array argument
func.func @product10(%arg0: !fir.box<!fir.array<?x?xi32>>) {
- %product = hlfir.product %arg0 : (!fir.box<!fir.array<?x?xi32>>) -> !hlfir.expr<i32>
+ %product = hlfir.product %arg0 : (!fir.box<!fir.array<?x?xi32>>) -> i32
return
}
// CHECK: func.func @product10(%[[ARRAY:.*]]: !fir.box<!fir.array<?x?xi32>>
-// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] : (!fir.box<!fir.array<?x?xi32>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] : (!fir.box<!fir.array<?x?xi32>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -201,11 +201,11 @@ func.func @product11(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: i32) {
// hlfir.product with array and mask argument
func.func @product12(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.logical<4>) {
- %product = hlfir.product %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> !hlfir.expr<i32>
+ %product = hlfir.product %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> i32
return
}
// CHECK: func.func @product12(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.logical<4>
-// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -221,20 +221,20 @@ func.func @product13(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: index) {
// hlfir.product with mask argument of unusual type
func.func @product14(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: i1) {
- %product = hlfir.product %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, i1) -> !hlfir.expr<i32>
+ %product = hlfir.product %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, i1) -> i32
return
}
// CHECK: func.func @product14(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: i1
-// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, i1) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, i1) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// hlfir.product with mask argument of ref<array<>> type
func.func @product15(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.ref<!fir.array<?x!fir.logical<4>>>) {
- %product = hlfir.product %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+ %product = hlfir.product %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> i32
return
}
// CHECK: func.func @product15(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.ref<!fir.array<?x!fir.logical<4>>>
-// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[PRODUCT:.*]] = hlfir.product %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
diff --git a/flang/test/HLFIR/sum-lowering.fir b/flang/test/HLFIR/sum-lowering.fir
index c031f6dacf27..8f5ddd7f5585 100644
--- a/flang/test/HLFIR/sum-lowering.fir
+++ b/flang/test/HLFIR/sum-lowering.fir
@@ -5,9 +5,8 @@
func.func @_QPsum1(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}, %arg1: !fir.ref<i32> {fir.bindc_name = "s"}) {
%0:2 = hlfir.declare %arg0 {uniq_name = "_QFsum1Ea"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
%1:2 = hlfir.declare %arg1 {uniq_name = "_QFsum1Es"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
- %2 = hlfir.sum %0#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> !hlfir.expr<i32>
- hlfir.assign %2 to %1#0 : !hlfir.expr<i32>, !fir.ref<i32>
- hlfir.destroy %2 : !hlfir.expr<i32>
+ %2 = hlfir.sum %0#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> i32
+ hlfir.assign %2 to %1#0 : i32, !fir.ref<i32>
return
}
// CHECK-LABEL: func.func @_QPsum1(
@@ -76,9 +75,8 @@ func.func @_QPsum3(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}, %a
%0:2 = hlfir.declare %arg0 {uniq_name = "_QFsum3Ea"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
%1:2 = hlfir.declare %arg2 {uniq_name = "_QFsum3Em"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
%2:2 = hlfir.declare %arg1 {uniq_name = "_QFsum3Es"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
- %3 = hlfir.sum %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> !hlfir.expr<i32>
- hlfir.assign %3 to %2#0 : !hlfir.expr<i32>, !fir.ref<i32>
- hlfir.destroy %3 : !hlfir.expr<i32>
+ %3 = hlfir.sum %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> i32
+ hlfir.assign %3 to %2#0 : i32, !fir.ref<i32>
return
}
// CHECK-LABEL: func.func @_QPsum3(
@@ -101,9 +99,8 @@ func.func @_QPsum4(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}, %a
%0:2 = hlfir.declare %arg0 {uniq_name = "_QFsum4Ea"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
%1:2 = hlfir.declare %arg2 {uniq_name = "_QFsum4Em"} : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> (!fir.box<!fir.array<?x!fir.logical<4>>>, !fir.box<!fir.array<?x!fir.logical<4>>>)
%2:2 = hlfir.declare %arg1 {uniq_name = "_QFsum4Es"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
- %3 = hlfir.sum %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
- hlfir.assign %3 to %2#0 : !hlfir.expr<i32>, !fir.ref<i32>
- hlfir.destroy %3 : !hlfir.expr<i32>
+ %3 = hlfir.sum %0#0 mask %1#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
+ hlfir.assign %3 to %2#0 : i32, !fir.ref<i32>
return
}
// CHECK-LABEL: func.func @_QPsum4(
diff --git a/flang/test/HLFIR/sum.fir b/flang/test/HLFIR/sum.fir
index 45388c33091e..a33873edcce9 100644
--- a/flang/test/HLFIR/sum.fir
+++ b/flang/test/HLFIR/sum.fir
@@ -10,7 +10,7 @@ func.func @sum0(%arg0: !hlfir.expr<42xi32>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @sum0(%[[ARRAY:.*]]: !hlfir.expr<42xi32>) {
@@ -20,7 +20,7 @@ func.func @sum0(%arg0: !hlfir.expr<42xi32>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL]] to %[[MASK]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %0 : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<42xi32>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -32,7 +32,7 @@ func.func @sum1(%arg0: !hlfir.expr<?xi32>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @sum1(%[[ARRAY:.*]]: !hlfir.expr<?xi32>) {
@@ -42,7 +42,7 @@ func.func @sum1(%arg0: !hlfir.expr<?xi32>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL:.*]] to %[[MASK:.*]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %[[MASK:.*]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.sum %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!hlfir.expr<?xi32>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -54,7 +54,7 @@ func.func @sum2(%arg0: !fir.box<!fir.array<42xi32>>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @sum2(%[[ARRAY:.*]]: !fir.box<!fir.array<42xi32>>) {
@@ -64,7 +64,7 @@ func.func @sum2(%arg0: !fir.box<!fir.array<42xi32>>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL:.*]] to %[[MASK:.*]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %[[MASK:.*]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.sum %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<42xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -76,7 +76,7 @@ func.func @sum3(%arg0: !fir.box<!fir.array<?xi32>>) {
%true_logical = fir.convert %true : (i1) -> !fir.logical<4>
fir.store %true_logical to %mask : !fir.ref<!fir.logical<4>>
%mask_box = fir.embox %mask : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
- %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %mask_box : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @sum3(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>) {
@@ -86,55 +86,55 @@ func.func @sum3(%arg0: !fir.box<!fir.array<?xi32>>) {
// CHECK-NEXT: %[[LOGICAL:.*]] = fir.convert %[[TRUE]] : (i1) -> !fir.logical<4>
// CHECK-NEXT: fir.store %[[LOGICAL:.*]] to %[[MASK:.*]] : !fir.ref<!fir.logical<4>>
// CHECK-NEXT: %[[BOX:.*]] = fir.embox %[[MASK:.*]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
-// CHECK-NEXT: hlfir.sum %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY:.*]] dim %[[C1]] mask %[[BOX]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// known shape expr mask
func.func @sum4(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !hlfir.expr<42x!fir.logical<4>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @sum4(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !hlfir.expr<42x!fir.logical<4>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<42x!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// assumed shape expr mask
func.func @sum5(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !hlfir.expr<?x!fir.logical<4>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> i32
return
}
// CHECK: func.func @sum5(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !hlfir.expr<?x!fir.logical<4>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !hlfir.expr<?x!fir.logical<4>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// known shape array mask
func.func @sum6(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.box<!fir.array<42x!fir.logical<4>>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> i32
return
}
// CHECK: func.func @sum6(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.box<!fir.array<42x!fir.logical<4>>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<42x!fir.logical<4>>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// assumed shape array mask
func.func @sum7(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.box<!fir.array<?x!fir.logical<4>>>) {
%c_1 = arith.constant 1 : index
- %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+ %0 = hlfir.sum %arg0 dim %c_1 mask %arg1 : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
return
}
// CHECK: func.func @sum7(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>) {
// CHECK-NEXT: %[[C1:.*]] = arith.constant 1 : index
-// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: hlfir.sum %[[ARRAY]] dim %[[C1]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, index, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -180,11 +180,11 @@ func.func @sum9(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: i32) {
// hlfir.sum with only an array argument
func.func @sum10(%arg0: !fir.box<!fir.array<?x?xi32>>) {
- %sum = hlfir.sum %arg0 : (!fir.box<!fir.array<?x?xi32>>) -> !hlfir.expr<i32>
+ %sum = hlfir.sum %arg0 : (!fir.box<!fir.array<?x?xi32>>) -> i32
return
}
// CHECK: func.func @sum10(%[[ARRAY:.*]]: !fir.box<!fir.array<?x?xi32>>
-// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] : (!fir.box<!fir.array<?x?xi32>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] : (!fir.box<!fir.array<?x?xi32>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -200,11 +200,11 @@ func.func @sum11(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: i32) {
// hlfir.sum with array and mask argument
func.func @sum12(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.logical<4>) {
- %sum = hlfir.sum %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> !hlfir.expr<i32>
+ %sum = hlfir.sum %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> i32
return
}
// CHECK: func.func @sum12(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.logical<4>
-// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.logical<4>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
@@ -220,20 +220,20 @@ func.func @sum13(%arg0: !fir.box<!fir.array<?x?xi32>>, %arg1: index) {
// hlfir.sum with mask argument of unusual type
func.func @sum14(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: i1) {
- %sum = hlfir.sum %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, i1) -> !hlfir.expr<i32>
+ %sum = hlfir.sum %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, i1) -> i32
return
}
// CHECK: func.func @sum14(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: i1
-// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, i1) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, i1) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
// hlfir.sum with mask argument of ref<array<>> type
func.func @sum15(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.ref<!fir.array<?x!fir.logical<4>>>) {
- %sum = hlfir.sum %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+ %sum = hlfir.sum %arg0 mask %arg1 : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> i32
return
}
// CHECK: func.func @sum15(%[[ARRAY:.*]]: !fir.box<!fir.array<?xi32>>, %[[MASK:.*]]: !fir.ref<!fir.array<?x!fir.logical<4>>>
-// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
+// CHECK-NEXT: %[[SUM:.*]] = hlfir.sum %[[ARRAY]] mask %[[MASK]] : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?x!fir.logical<4>>>) -> i32
// CHECK-NEXT: return
// CHECK-NEXT: }
diff --git a/flang/test/Lower/HLFIR/any.f90 b/flang/test/Lower/HLFIR/any.f90
index f4e66cb571ea..ac2f9bae43ec 100644
--- a/flang/test/Lower/HLFIR/any.f90
+++ b/flang/test/Lower/HLFIR/any.f90
@@ -10,9 +10,8 @@ subroutine any1(a, s)
! CHECK: %[[ARG1:.*]]: !fir.ref<!fir.logical<4>>
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG0]]
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
-! CHECK-NEXT: %[[EXPR:.*]] = hlfir.any %[[MASK]]#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<!fir.logical<4>>
-! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<!fir.logical<4>>, !fir.ref<!fir.logical<4>>
-! CHECK-NEXT: hlfir.destroy %[[EXPR]]
+! CHECK-NEXT: %[[EXPR:.*]] = hlfir.any %[[MASK]]#0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.logical<4>
+! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !fir.logical<4>, !fir.ref<!fir.logical<4>>
! CHECK-NEXT: return
! CHECK-NEXT: }
diff --git a/flang/test/Lower/HLFIR/product.f90 b/flang/test/Lower/HLFIR/product.f90
index 148d53bf2ccd..274888336b3b 100644
--- a/flang/test/Lower/HLFIR/product.f90
+++ b/flang/test/Lower/HLFIR/product.f90
@@ -10,9 +10,8 @@ subroutine product1(a, s)
! CHECK: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}, %[[ARG1:.*]]: !fir.ref<i32>
! CHECK-DAG: %[[ARRAY:.*]]:2 = hlfir.declare %[[ARG0]]
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
-! CHECK-NEXT: %[[EXPR:.*]] = hlfir.product %[[ARRAY]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> !hlfir.expr<i32>
-! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<i32>, !fir.ref<i32>
-! CHECK-NEXT: hlfir.destroy %[[EXPR]]
+! CHECK-NEXT: %[[EXPR:.*]] = hlfir.product %[[ARRAY]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> i32
+! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
! CHECK-NEXT: return
! CHECK-NEXT: }
@@ -44,9 +43,8 @@ subroutine product3(a, s, m)
! CHECK-DAG: %[[ARRAY:.*]]:2 = hlfir.declare %[[ARG0]]
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG2]]
-! CHECK-NEXT: %[[EXPR:.*]] = hlfir.product %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> !hlfir.expr<i32>
-! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<i32>, !fir.ref<i32>
-! CHECK-NEXT: hlfir.destroy %[[EXPR]]
+! CHECK-NEXT: %[[EXPR:.*]] = hlfir.product %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> i32
+! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
! CHECK-NEXT: return
! CHECK-NEXT: }
@@ -56,15 +54,13 @@ subroutine product4(a, s, m)
logical :: m(:)
s = PRODUCT(a, m)
end subroutine
-
! CHECK-LABEL: func.func @_QPproduct4(
! CHECK: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}, %arg1: !fir.ref<i32> {fir.bindc_name = "s"}, %arg2: !fir.box<!fir.array<?x!fir.logical<4>>> {fir.bindc_name = "m"})
! CHECK-DAG: %[[ARRAY:.*]]:2 = hlfir.declare %[[ARG0]]
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG2]]
-! CHECK-NEXT: %[[EXPR:.*]] = hlfir.product %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
-! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<i32>, !fir.ref<i32>
-! CHECK-NEXT: hlfir.destroy %[[EXPR]]
+! CHECK-NEXT: %[[EXPR:.*]] = hlfir.product %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
+! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
! CHECK-NEXT: return
! CHECK-NEXT: }
@@ -74,7 +70,6 @@ subroutine product5(s)
integer :: a(2,2) = reshape((/1, 2, 3, 4/), [2,2])
s = PRODUCT(a, 1, .true.)
end subroutine
-
! CHECK-LABEL: func.func @_QPproduct5(
! CHECK: %[[ARG0:.*]]: !fir.ref<!fir.array<2xi32>>
! CHECK-DAG: %[[ADDR:.*]] = fir.address_of({{.*}}) : !fir.ref<!fir.array<2x2xi32>>
@@ -96,7 +91,6 @@ subroutine product6(a, s, d)
real :: a(:,:), s(:)
s = PRODUCT(a, (d))
end subroutine
-
! CHECK-LABEL: func.func @_QPproduct6(
! CHECK: %[[ARG0:.*]]: !fir.box<!fir.array<?x?xf32>> {fir.bindc_name = "a"}, %[[ARG1:.*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "s"}, %[[ARG2:.*]]: !fir.ref<!fir.box<!fir.ptr<i32>>> {fir.bindc_name = "d"})
! CHECK-DAG: %[[ARRAY:.*]]:2 = hlfir.declare %[[ARG0]]
diff --git a/flang/test/Lower/HLFIR/sum.f90 b/flang/test/Lower/HLFIR/sum.f90
index 32a2423da698..72dbb5b95607 100644
--- a/flang/test/Lower/HLFIR/sum.f90
+++ b/flang/test/Lower/HLFIR/sum.f90
@@ -10,10 +10,8 @@ subroutine sum1(a, s)
! CHECK: %[[ARG0:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}, %[[ARG1:.*]]: !fir.ref<i32>
! CHECK-DAG: %[[ARRAY:.*]]:2 = hlfir.declare %[[ARG0]]
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
-! CHECK-NEXT: %[[EXPR:.*]] = hlfir.sum %[[ARRAY]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) ->
-!hlfir.expr<i32>
-! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<i32>, !fir.ref<i32>
-! CHECK-NEXT: hlfir.destroy %[[EXPR]]
+! CHECK-NEXT: %[[EXPR:.*]] = hlfir.sum %[[ARRAY]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>) -> i32
+! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
! CHECK-NEXT: return
! CHECK-NEXT: }
@@ -45,9 +43,8 @@ subroutine sum3(a, s, m)
! CHECK-DAG: %[[ARRAY:.*]]:2 = hlfir.declare %[[ARG0]]
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG2]]
-! CHECK-NEXT: %[[EXPR:.*]] = hlfir.sum %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> !hlfir.expr<i32>
-! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<i32>, !fir.ref<i32>
-! CHECK-NEXT: hlfir.destroy %[[EXPR]]
+! CHECK-NEXT: %[[EXPR:.*]] = hlfir.sum %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.logical<4>>) -> i32
+! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
! CHECK-NEXT: return
! CHECK-NEXT: }
@@ -62,9 +59,8 @@ subroutine sum4(a, s, m)
! CHECK-DAG: %[[ARRAY:.*]]:2 = hlfir.declare %[[ARG0]]
! CHECK-DAG: %[[OUT:.*]]:2 = hlfir.declare %[[ARG1]]
! CHECK-DAG: %[[MASK:.*]]:2 = hlfir.declare %[[ARG2]]
-! CHECK-NEXT: %[[EXPR:.*]] = hlfir.sum %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> !hlfir.expr<i32>
-! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : !hlfir.expr<i32>, !fir.ref<i32>
-! CHECK-NEXT: hlfir.destroy %[[EXPR]]
+! CHECK-NEXT: %[[EXPR:.*]] = hlfir.sum %[[ARRAY]]#0 mask %[[MASK]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
+! CHECK-NEXT: hlfir.assign %[[EXPR]] to %[[OUT]]#0 : i32, !fir.ref<i32>
! CHECK-NEXT: return
! CHECK-NEXT: }
More information about the flang-commits
mailing list