Skip to content

Commit 1b7cbe1

Browse files
authored
[flang][OpenMP] Create unique reduction decls for different logical kinds (#146558)
Some Fujitsu tests showed incorrect results because we were sharing reduction declarations for different kinds for logical variables.
1 parent 651c520 commit 1b7cbe1

10 files changed

+66
-42
lines changed

flang/lib/Lower/OpenMP/ReductionProcessor.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,17 @@ std::string ReductionProcessor::getReductionName(
149149
reductionName = "multiply_reduction";
150150
break;
151151
case omp::clause::DefinedOperator::IntrinsicOperator::AND:
152-
return "and_reduction";
152+
reductionName = "and_reduction";
153+
break;
153154
case omp::clause::DefinedOperator::IntrinsicOperator::EQV:
154-
return "eqv_reduction";
155+
reductionName = "eqv_reduction";
156+
break;
155157
case omp::clause::DefinedOperator::IntrinsicOperator::OR:
156-
return "or_reduction";
158+
reductionName = "or_reduction";
159+
break;
157160
case omp::clause::DefinedOperator::IntrinsicOperator::NEQV:
158-
return "neqv_reduction";
161+
reductionName = "neqv_reduction";
162+
break;
159163
default:
160164
reductionName = "other_reduction";
161165
break;
@@ -673,9 +677,6 @@ void ReductionProcessor::processReductionArguments(
673677
const auto &kindMap = firOpBuilder.getKindMap();
674678
std::string reductionName;
675679
ReductionIdentifier redId;
676-
mlir::Type redNameTy = redType;
677-
if (mlir::isa<fir::LogicalType>(redType.getEleTy()))
678-
redNameTy = builder.getI1Type();
679680

680681
if (const auto &redDefinedOp =
681682
std::get_if<omp::clause::DefinedOperator>(&redOperator.u)) {
@@ -697,8 +698,7 @@ void ReductionProcessor::processReductionArguments(
697698
break;
698699
}
699700

700-
reductionName =
701-
getReductionName(intrinsicOp, kindMap, redNameTy, isByRef);
701+
reductionName = getReductionName(intrinsicOp, kindMap, redType, isByRef);
702702
} else if (const auto *reductionIntrinsic =
703703
std::get_if<omp::clause::ProcedureDesignator>(
704704
&redOperator.u)) {
@@ -709,7 +709,7 @@ void ReductionProcessor::processReductionArguments(
709709
redId = getReductionType(*reductionIntrinsic);
710710
reductionName =
711711
getReductionName(getRealName(*reductionIntrinsic).ToString(), kindMap,
712-
redNameTy, isByRef);
712+
redType, isByRef);
713713
} else {
714714
TODO(currentLocation, "Unexpected reduction type");
715715
}

flang/test/Lower/OpenMP/wsloop-reduction-logical-and-byref.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
! NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
55

6-
! CHECK-LABEL: omp.declare_reduction @and_reduction : !fir.ref<!fir.logical<4>>
6+
! CHECK-LABEL: omp.declare_reduction @and_reduction_byref_l32 : !fir.ref<!fir.logical<4>>
77
! CHECK-SAME: alloc {
88
! CHECK: %[[REF:.*]] = fir.alloca !fir.logical<4>
99
! CHECK: omp.yield(%[[REF]] : !fir.ref<!fir.logical<4>>)
@@ -42,7 +42,7 @@
4242
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
4343
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
4444
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
45-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @and_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
45+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @and_reduction_byref_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
4646
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
4747
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reductionEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
4848
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reductionEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -90,7 +90,7 @@ end subroutine simple_reduction
9090
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
9191
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
9292
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
93-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @and_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
93+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @and_reduction_byref_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
9494
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
9595
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reduction_switch_orderEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
9696
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reduction_switch_orderEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -147,7 +147,7 @@ subroutine simple_reduction_switch_order(y)
147147
! CHECK: %[[VAL_20:.*]] = arith.constant 1 : i32
148148
! CHECK: %[[VAL_21:.*]] = arith.constant 100 : i32
149149
! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i32
150-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(byref @and_reduction %[[VAL_7]]#0 -> %[[VAL_23:.*]], byref @and_reduction %[[VAL_9]]#0 -> %[[VAL_24:.*]], byref @and_reduction %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
150+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(byref @and_reduction_byref_l32 %[[VAL_7]]#0 -> %[[VAL_23:.*]], byref @and_reduction_byref_l32 %[[VAL_9]]#0 -> %[[VAL_24:.*]], byref @and_reduction_byref_l32 %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
151151
! CHECK-NEXT: omp.loop_nest (%[[VAL_26:.*]]) : i32 = (%[[VAL_20]]) to (%[[VAL_21]]) inclusive step (%[[VAL_22]]) {
152152
! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFmultiple_reductionsEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
153153
! CHECK: %[[VAL_27:.*]]:2 = hlfir.declare %[[VAL_23]] {uniq_name = "_QFmultiple_reductionsEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)

flang/test/Lower/OpenMP/wsloop-reduction-logical-and.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
! NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
55

6-
! CHECK-LABEL: omp.declare_reduction @and_reduction : !fir.logical<4> init {
6+
! CHECK-LABEL: omp.declare_reduction @and_reduction_l32 : !fir.logical<4> init {
77
! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.logical<4>):
88
! CHECK: %[[VAL_1:.*]] = arith.constant true
99
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (i1) -> !fir.logical<4>
@@ -34,7 +34,7 @@
3434
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
3535
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
3636
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
37-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@and_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
37+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@and_reduction_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
3838
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
3939
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reductionEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
4040
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reductionEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -82,7 +82,7 @@ end subroutine simple_reduction
8282
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
8383
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
8484
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
85-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@and_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
85+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@and_reduction_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
8686
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
8787
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reduction_switch_orderEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
8888
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reduction_switch_orderEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -139,7 +139,7 @@ subroutine simple_reduction_switch_order(y)
139139
! CHECK: %[[VAL_20:.*]] = arith.constant 1 : i32
140140
! CHECK: %[[VAL_21:.*]] = arith.constant 100 : i32
141141
! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i32
142-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(@and_reduction %[[VAL_7]]#0 -> %[[VAL_23:.*]], @and_reduction %[[VAL_9]]#0 -> %[[VAL_24:.*]], @and_reduction %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
142+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(@and_reduction_l32 %[[VAL_7]]#0 -> %[[VAL_23:.*]], @and_reduction_l32 %[[VAL_9]]#0 -> %[[VAL_24:.*]], @and_reduction_l32 %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
143143
! CHECK-NEXT: omp.loop_nest (%[[VAL_26:.*]]) : i32 = (%[[VAL_20]]) to (%[[VAL_21]]) inclusive step (%[[VAL_22]]) {
144144
! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFmultiple_reductionsEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
145145
! CHECK: %[[VAL_27:.*]]:2 = hlfir.declare %[[VAL_23]] {uniq_name = "_QFmultiple_reductionsEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)

flang/test/Lower/OpenMP/wsloop-reduction-logical-eqv-byref.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
! NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
55

6-
! CHECK-LABEL: omp.declare_reduction @eqv_reduction : !fir.ref<!fir.logical<4>>
6+
! CHECK-LABEL: omp.declare_reduction @eqv_reduction_byref_l32 : !fir.ref<!fir.logical<4>>
77
! CHECK-SAME: alloc {
88
! CHECK: %[[REF:.*]] = fir.alloca !fir.logical<4>
99
! CHECK: omp.yield(%[[REF]] : !fir.ref<!fir.logical<4>>)
@@ -42,7 +42,7 @@
4242
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
4343
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
4444
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
45-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @eqv_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
45+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @eqv_reduction_byref_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
4646
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
4747
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reductionEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
4848
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reductionEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -89,7 +89,7 @@ subroutine simple_reduction(y)
8989
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
9090
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
9191
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
92-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @eqv_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
92+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(byref @eqv_reduction_byref_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
9393
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
9494
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reduction_switch_orderEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
9595
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reduction_switch_orderEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -146,7 +146,7 @@ subroutine simple_reduction_switch_order(y)
146146
! CHECK: %[[VAL_20:.*]] = arith.constant 1 : i32
147147
! CHECK: %[[VAL_21:.*]] = arith.constant 100 : i32
148148
! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i32
149-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(byref @eqv_reduction %[[VAL_7]]#0 -> %[[VAL_23:.*]], byref @eqv_reduction %[[VAL_9]]#0 -> %[[VAL_24:.*]], byref @eqv_reduction %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
149+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(byref @eqv_reduction_byref_l32 %[[VAL_7]]#0 -> %[[VAL_23:.*]], byref @eqv_reduction_byref_l32 %[[VAL_9]]#0 -> %[[VAL_24:.*]], byref @eqv_reduction_byref_l32 %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
150150
! CHECK-NEXT: omp.loop_nest (%[[VAL_26:.*]]) : i32 = (%[[VAL_20]]) to (%[[VAL_21]]) inclusive step (%[[VAL_22]]) {
151151
! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFmultiple_reductionsEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
152152
! CHECK: %[[VAL_27:.*]]:2 = hlfir.declare %[[VAL_23]] {uniq_name = "_QFmultiple_reductionsEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)

flang/test/Lower/OpenMP/wsloop-reduction-logical-eqv.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
! NOTE: Assertions have been autogenerated by utils/generate-test-checks.py
55

6-
! CHECK-LABEL: omp.declare_reduction @eqv_reduction : !fir.logical<4> init {
6+
! CHECK-LABEL: omp.declare_reduction @eqv_reduction_l32 : !fir.logical<4> init {
77
! CHECK: ^bb0(%[[VAL_0:.*]]: !fir.logical<4>):
88
! CHECK: %[[VAL_1:.*]] = arith.constant true
99
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (i1) -> !fir.logical<4>
@@ -34,7 +34,7 @@
3434
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
3535
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
3636
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
37-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@eqv_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
37+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@eqv_reduction_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
3838
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
3939
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reductionEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
4040
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reductionEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -81,7 +81,7 @@ subroutine simple_reduction(y)
8181
! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i32
8282
! CHECK: %[[VAL_13:.*]] = arith.constant 100 : i32
8383
! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
84-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@eqv_reduction %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
84+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_10:.*]] : !fir.ref<i32>) reduction(@eqv_reduction_l32 %[[VAL_4]]#0 -> %[[VAL_15:.*]] : !fir.ref<!fir.logical<4>>) {
8585
! CHECK-NEXT: omp.loop_nest (%[[VAL_16:.*]]) : i32 = (%[[VAL_12]]) to (%[[VAL_13]]) inclusive step (%[[VAL_14]]) {
8686
! CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_10]] {uniq_name = "_QFsimple_reduction_switch_orderEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
8787
! CHECK: %[[VAL_17:.*]]:2 = hlfir.declare %[[VAL_15]] {uniq_name = "_QFsimple_reduction_switch_orderEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
@@ -138,7 +138,7 @@ subroutine simple_reduction_switch_order(y)
138138
! CHECK: %[[VAL_20:.*]] = arith.constant 1 : i32
139139
! CHECK: %[[VAL_21:.*]] = arith.constant 100 : i32
140140
! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i32
141-
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(@eqv_reduction %[[VAL_7]]#0 -> %[[VAL_23:.*]], @eqv_reduction %[[VAL_9]]#0 -> %[[VAL_24:.*]], @eqv_reduction %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
141+
! CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_18:.*]] : !fir.ref<i32>) reduction(@eqv_reduction_l32 %[[VAL_7]]#0 -> %[[VAL_23:.*]], @eqv_reduction_l32 %[[VAL_9]]#0 -> %[[VAL_24:.*]], @eqv_reduction_l32 %[[VAL_11]]#0 -> %[[VAL_25:.*]] : !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>) {
142142
! CHECK-NEXT: omp.loop_nest (%[[VAL_26:.*]]) : i32 = (%[[VAL_20]]) to (%[[VAL_21]]) inclusive step (%[[VAL_22]]) {
143143
! CHECK: %[[VAL_19:.*]]:2 = hlfir.declare %[[VAL_18]] {uniq_name = "_QFmultiple_reductionsEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
144144
! CHECK: %[[VAL_27:.*]]:2 = hlfir.declare %[[VAL_23]] {uniq_name = "_QFmultiple_reductionsEx"} : (!fir.ref<!fir.logical<4>>) -> (!fir.ref<!fir.logical<4>>, !fir.ref<!fir.logical<4>>)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s | FileCheck %s
2+
3+
! Check that logical reductions of different kinds do not end up using the same
4+
! reduction declaration
5+
6+
! CHECK-LABEL: omp.declare_reduction @or_reduction_l64 : !fir.logical<8> init {
7+
! CHECK-LABEL: omp.declare_reduction @or_reduction_l32 : !fir.logical<4> init {
8+
9+
subroutine test(a4, a8, sz)
10+
integer :: sz
11+
logical(4), dimension(sz) :: a4
12+
logical(8), dimension(sz) :: a8
13+
14+
logical(4) :: res4 = .false.
15+
logical(8) :: res8 = .false.
16+
integer i
17+
18+
! CHECK: omp.wsloop private({{.*}}) reduction(@or_reduction_l32 {{.*}}, @or_reduction_l64 {{.*}}) {
19+
!$omp do reduction(.or.:res4, res8)
20+
do i = 1,sz
21+
res4 = res4 .or. a4(i)
22+
res8 = res8 .or. a8(i)
23+
enddo
24+
end subroutine

0 commit comments

Comments
 (0)