Skip to content

Commit 16e63ef

Browse files
committed
Revert commits up to the first approach
1 parent bbaf50b commit 16e63ef

File tree

16 files changed

+202
-212
lines changed

16 files changed

+202
-212
lines changed

flang/lib/Lower/DirectivesCommon.h

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,12 @@ static inline void genOmpAccAtomicCaptureStatement(
139139
mlir::Value toAddress,
140140
[[maybe_unused]] const AtomicListT *leftHandClauseList,
141141
[[maybe_unused]] const AtomicListT *rightHandClauseList,
142-
mlir::Location loc) {
142+
mlir::Type elementType, mlir::Location loc) {
143143
// Generate `atomic.read` operation for atomic assigment statements
144144
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
145-
mlir::Type elementType = fir::unwrapRefType(toAddress.getType());
146145

147146
processOmpAtomicTODO<AtomicListT>(elementType, loc);
148147

149-
if (toAddress.getType() != fromAddress.getType()) {
150-
// Allow for implicit type conversion. The `toAddress` operand will have
151-
// the same reference type as `fromAddress`, but its value should be
152-
// interpreted as `elementType`.
153-
mlir::Value convertOp = firOpBuilder.create<fir::ConvertOp>(
154-
loc, fromAddress.getType(), toAddress);
155-
convertOp.getDefiningOp()->moveAfter(toAddress.getDefiningOp());
156-
toAddress = convertOp;
157-
}
158148
if constexpr (std::is_same<AtomicListT,
159149
Fortran::parser::OmpAtomicClauseList>()) {
160150
// If no hint clause is specified, the effect is as if
@@ -419,12 +409,14 @@ void genOmpAccAtomicRead(Fortran::lower::AbstractConverter &converter,
419409
Fortran::lower::StatementContext stmtCtx;
420410
const Fortran::semantics::SomeExpr &fromExpr =
421411
*Fortran::semantics::GetExpr(assignmentStmtExpr);
412+
mlir::Type elementType = converter.genType(fromExpr);
422413
mlir::Value fromAddress =
423414
fir::getBase(converter.genExprAddr(fromExpr, stmtCtx));
424415
mlir::Value toAddress = fir::getBase(converter.genExprAddr(
425416
*Fortran::semantics::GetExpr(assignmentStmtVariable), stmtCtx));
426417
genOmpAccAtomicCaptureStatement(converter, fromAddress, toAddress,
427-
leftHandClauseList, rightHandClauseList, loc);
418+
leftHandClauseList, rightHandClauseList,
419+
elementType, loc);
428420
}
429421

430422
/// Processes an atomic construct with update clause.
@@ -540,10 +532,13 @@ void genOmpAccAtomicCapture(Fortran::lower::AbstractConverter &converter,
540532
if (Fortran::semantics::checkForSingleVariableOnRHS(stmt1)) {
541533
if (Fortran::semantics::checkForSymbolMatch(stmt2)) {
542534
// Atomic capture construct is of the form [capture-stmt, update-stmt]
535+
const Fortran::semantics::SomeExpr &fromExpr =
536+
*Fortran::semantics::GetExpr(stmt1Expr);
537+
mlir::Type elementType = converter.genType(fromExpr);
543538
genOmpAccAtomicCaptureStatement<AtomicListT>(
544539
converter, stmt2LHSArg, stmt1LHSArg,
545540
/*leftHandClauseList=*/nullptr,
546-
/*rightHandClauseList=*/nullptr, loc);
541+
/*rightHandClauseList=*/nullptr, elementType, loc);
547542
genOmpAccAtomicUpdateStatement<AtomicListT>(
548543
converter, stmt2LHSArg, stmt2VarType, stmt2Var, stmt2Expr,
549544
/*leftHandClauseList=*/nullptr,
@@ -554,25 +549,31 @@ void genOmpAccAtomicCapture(Fortran::lower::AbstractConverter &converter,
554549
mlir::Value stmt2RHSArg =
555550
fir::getBase(converter.genExprValue(assign2.rhs, stmtCtx));
556551
firOpBuilder.setInsertionPointToStart(&block);
552+
const Fortran::semantics::SomeExpr &fromExpr =
553+
*Fortran::semantics::GetExpr(stmt1Expr);
554+
mlir::Type elementType = converter.genType(fromExpr);
557555
genOmpAccAtomicCaptureStatement<AtomicListT>(
558556
converter, stmt2LHSArg, stmt1LHSArg,
559557
/*leftHandClauseList=*/nullptr,
560-
/*rightHandClauseList=*/nullptr, loc);
558+
/*rightHandClauseList=*/nullptr, elementType, loc);
561559
genOmpAccAtomicWriteStatement<AtomicListT>(
562560
converter, stmt2LHSArg, stmt2RHSArg,
563561
/*leftHandClauseList=*/nullptr,
564562
/*rightHandClauseList=*/nullptr, loc);
565563
}
566564
} else {
567565
// Atomic capture construct is of the form [update-stmt, capture-stmt]
566+
const Fortran::semantics::SomeExpr &fromExpr =
567+
*Fortran::semantics::GetExpr(stmt2Expr);
568+
mlir::Type elementType = converter.genType(fromExpr);
568569
genOmpAccAtomicUpdateStatement<AtomicListT>(
569570
converter, stmt1LHSArg, stmt1VarType, stmt1Var, stmt1Expr,
570571
/*leftHandClauseList=*/nullptr,
571572
/*rightHandClauseList=*/nullptr, loc, atomicCaptureOp);
572573
genOmpAccAtomicCaptureStatement<AtomicListT>(
573574
converter, stmt1LHSArg, stmt2LHSArg,
574575
/*leftHandClauseList=*/nullptr,
575-
/*rightHandClauseList=*/nullptr, loc);
576+
/*rightHandClauseList=*/nullptr, elementType, loc);
576577
}
577578
firOpBuilder.setInsertionPointToEnd(&block);
578579
if constexpr (std::is_same<AtomicListT,

flang/test/Fir/convert-to-llvm-openmp-and-fir.fir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,11 @@ func.func @_QPsimple_reduction(%arg0: !fir.ref<!fir.array<100x!fir.logical<4>>>
781781
// -----
782782

783783
// CHECK: llvm.func @_QPs
784-
// CHECK: omp.atomic.read %{{.*}} = %{{.*}} : !llvm.ptr, !llvm.struct<(f32, f32)>
784+
// CHECK: omp.atomic.read %{{.*}} = %{{.*}} : !llvm.ptr, !llvm.ptr, !llvm.struct<(f32, f32)>
785785

786786
func.func @_QPs(%arg0: !fir.ref<complex<f32>> {fir.bindc_name = "x"}) {
787787
%0 = fir.alloca complex<f32> {bindc_name = "v", uniq_name = "_QFsEv"}
788-
omp.atomic.read %0 = %arg0 : !fir.ref<complex<f32>>, complex<f32>
788+
omp.atomic.read %0 = %arg0 : !fir.ref<complex<f32>>, !fir.ref<complex<f32>>, complex<f32>
789789
return
790790
}
791791

flang/test/Lower/OpenACC/acc-atomic-capture.f90

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ program acc_atomic_capture_test
1111
!CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %2 {uniq_name = "_QFEy"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
1212
!CHECK: %[[temp:.*]] = fir.load %[[X_DECL]]#0 : !fir.ref<i32>
1313
!CHECK: acc.atomic.capture {
14-
!CHECK: acc.atomic.read %[[X_DECL]]#1 = %[[Y_DECL]]#1 : !fir.ref<i32>, i32
14+
!CHECK: acc.atomic.read %[[X_DECL]]#1 = %[[Y_DECL]]#1 : !fir.ref<i32>, !fir.ref<i32>, i32
1515
!CHECK: acc.atomic.update %[[Y_DECL]]#1 : !fir.ref<i32> {
1616
!CHECK: ^bb0(%[[ARG:.*]]: i32):
1717
!CHECK: %[[result:.*]] = arith.addi %[[temp]], %[[ARG]] : i32
@@ -32,7 +32,7 @@ program acc_atomic_capture_test
3232
!CHECK: %[[result:.*]] = arith.muli %[[temp]], %[[ARG]] : i32
3333
!CHECK: acc.yield %[[result]] : i32
3434
!CHECK: }
35-
!CHECK: acc.atomic.read %[[X_DECL]]#1 = %[[Y_DECL]]#1 : !fir.ref<i32>, i32
35+
!CHECK: acc.atomic.read %[[X_DECL]]#1 = %[[Y_DECL]]#1 : !fir.ref<i32>, !fir.ref<i32>, i32
3636
!CHECK: }
3737

3838
!$acc atomic capture
@@ -47,7 +47,7 @@ program acc_atomic_capture_test
4747
!CHECK: %[[result_noreassoc:.*]] = hlfir.no_reassoc %[[result]] : i32
4848
!CHECK: %[[result:.*]] = arith.addi %[[constant_20]], %[[result_noreassoc]] : i32
4949
!CHECK: acc.atomic.capture {
50-
!CHECK: acc.atomic.read %[[X_DECL]]#1 = %[[Y_DECL]]#1 : !fir.ref<i32>, i32
50+
!CHECK: acc.atomic.read %[[X_DECL]]#1 = %[[Y_DECL]]#1 : !fir.ref<i32>, !fir.ref<i32>, i32
5151
!CHECK: acc.atomic.write %[[Y_DECL]]#1 = %[[result]] : !fir.ref<i32>, i32
5252
!CHECK: }
5353

@@ -82,7 +82,7 @@ subroutine pointers_in_atomic_capture()
8282
!CHECK: %[[result:.*]] = arith.addi %[[ARG]], %[[loaded_value]] : i32
8383
!CHECK: acc.yield %[[result]] : i32
8484
!CHECK: }
85-
!CHECK: acc.atomic.read %[[loaded_B_addr]] = %[[loaded_A_addr]] : !fir.ptr<i32>, i32
85+
!CHECK: acc.atomic.read %[[loaded_B_addr]] = %[[loaded_A_addr]] : !fir.ptr<i32>, !fir.ptr<i32>, i32
8686
!CHECK: }
8787
integer, pointer :: a, b
8888
integer, target :: c, d
@@ -118,7 +118,7 @@ subroutine capture_with_convert_f32_to_i32()
118118
! CHECK: %[[MUL:.*]] = arith.mulf %{{.*}}, %[[CST]] fastmath<contract> : f32
119119
! CHECK: %[[CONV:.*]] = fir.convert %[[MUL]] : (f32) -> i32
120120
! CHECK: acc.atomic.capture {
121-
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[K_DECL]]#1 : !fir.ref<i32>, i32
121+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[K_DECL]]#1 : !fir.ref<i32>, !fir.ref<i32>, i32
122122
! CHECK: acc.atomic.write %[[K_DECL]]#1 = %[[CONV]] : !fir.ref<i32>, i32
123123
! CHECK: }
124124

@@ -138,15 +138,14 @@ end subroutine capture_with_convert_i32_to_f64
138138
! CHECK: %[[V_DECL:.*]]:2 = hlfir.declare %[[V]] {uniq_name = "_QFcapture_with_convert_i32_to_f64Ev"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
139139
! CHECK: %[[X:.*]] = fir.alloca f64 {bindc_name = "x", uniq_name = "_QFcapture_with_convert_i32_to_f64Ex"}
140140
! CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X]] {uniq_name = "_QFcapture_with_convert_i32_to_f64Ex"} : (!fir.ref<f64>) -> (!fir.ref<f64>, !fir.ref<f64>)
141-
! CHECK: %[[X_CONV:.*]] = fir.convert %[[X_DECL]]#1 : (!fir.ref<f64>) -> !fir.ref<i32>
142141
! CHECK: %[[CST:.*]] = arith.constant 1.000000e+00 : f64
143142
! CHECK: hlfir.assign %[[CST]] to %[[X_DECL]]#0 : f64, !fir.ref<f64>
144143
! CHECK: %c0_i32 = arith.constant 0 : i32
145144
! CHECK: hlfir.assign %c0_i32 to %[[V_DECL]]#0 : i32, !fir.ref<i32>
146145
! CHECK: %[[LOAD:.*]] = fir.load %[[V_DECL]]#0 : !fir.ref<i32>
147146
! CHECK: %[[CONV:.*]] = fir.convert %[[LOAD]] : (i32) -> f64
148147
! CHECK: acc.atomic.capture {
149-
! CHECK: acc.atomic.read %[[V_DECL]] = %[[X_CONV]]#1 : !fir.ref<f64>, i32
148+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[X_DECL]]#1 : !fir.ref<i32>, !fir.ref<f64>, f64
150149
! CHECK: acc.atomic.write %[[X_DECL]]#1 = %[[CONV]] : !fir.ref<f64>, f64
151150
! CHECK: }
152151

@@ -170,20 +169,16 @@ end subroutine capture_with_convert_f64_to_i32
170169
! CHECK: hlfir.assign %c1_i32 to %[[X_DECL]]#0 : i32, !fir.ref<i32>
171170
! CHECK: %[[CST:.*]] = arith.constant 0.000000e+00 : f64
172171
! CHECK: hlfir.assign %[[CST]] to %[[V_DECL]]#0 : f64, !fir.ref<f64>
173-
! CHECK: %[[ALLOCA]] = fir.alloca i32
174-
! CHECK: %[[LOAD1:.*]] = fir.load %[[V_DECL]]#0 : !fir.ref<f64>
172+
! CHECK: %[[LOAD:.*]] = fir.load %[[V_DECL]]#0 : !fir.ref<f64>
175173
! CHECK: acc.atomic.capture {
176174
! CHECK: acc.atomic.update %[[X_DECL]]#1 : !fir.ref<i32> {
177175
! CHECK: ^bb0(%arg0: i32):
178-
! CHECK: %[[MUL:.*]] = arith.mulf %[[LOAD1]], %[[LOAD1]] fastmath<contract> : f64
179-
! CHECK: %[[CONV1:.*]] = fir.convert %[[MUL]] : (f64) -> i32
180-
! CHECK: acc.yield %[[CONV1]] : i32
176+
! CHECK: %[[MUL:.*]] = arith.mulf %[[LOAD]], %[[LOAD]] fastmath<contract> : f64
177+
! CHECK: %[[CONV:.*]] = fir.convert %[[MUL]] : (f64) -> i32
178+
! CHECK: acc.yield %[[CONV]] : i32
181179
! CHECK: }
182-
! CHECK: acc.atomic.read %[[ALLOCA]] = %[[X_DECL]]#1 : !fir.ref<i32>, i32
180+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[X_DECL]]#1 : !fir.ref<f64>, !fir.ref<i32>, i32
183181
! CHECK: }
184-
! CHECK: %[[LOAD2:.*]] = fir.load %[[ALLOCA]] : !fir.ref<i32>
185-
! CHECK: %[[CONV2:.*]] = fir.convert %[[LOAD2]] : (i32) -> f64
186-
! CHECK: fir.store %[[CONV2]] to %[[V_DECL]]#1 : !fir.ref<f64>
187182

188183
subroutine capture_with_convert_i32_to_f32()
189184
real(4) :: x
@@ -205,21 +200,16 @@ end subroutine capture_with_convert_i32_to_f32
205200
! CHECK: hlfir.assign %[[CST]] to %[[X_DECL]]#0 : f32, !fir.ref<f32>
206201
! CHECK: %c0_i32 = arith.constant 0 : i32
207202
! CHECK: hlfir.assign %c0_i32 to %[[V_DECL]]#0 : i32, !fir.ref<i32>
208-
! CHECK: %[[ALLOCA:.*]] = fir.alloca f32
209-
! CHECK: %[[LOAD1:.*]] = fir.load %[[ALLOCA]] : !fir.ref<f32>
210-
! CHECK: %[[CONV1:.*]] = fir.convert %5 : (f32) -> i32
203+
! CHECK: %[[LOAD:.*]] = fir.load %[[V_DECL]]#0 : !fir.ref<i32>
211204
! CHECK: acc.atomic.capture {
212-
! CHECK: acc.atomic.read %[[ALLOCA]] = %[[X_DECL]]#1 : !fir.ref<f32>, f32
205+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[X_DECL]]#1 : !fir.ref<i32>, !fir.ref<f32>, f32
213206
! CHECK: acc.atomic.update %[[X_DECL]]#1 : !fir.ref<f32> {
214207
! CHECK: ^bb0(%arg0: f32):
215-
! CHECK: %[[CONV2:.*]] = fir.convert %[[CONV1]] : (i32) -> f32
216-
! CHECK: %[[ADD:.*]] = arith.addf %arg0, %[[CONV2]] fastmath<contract> : f32
208+
! CHECK: %[[CONV:.*]] = fir.convert %[[LOAD]] : (i32) -> f32
209+
! CHECK: %[[ADD:.*]] = arith.addf %arg0, %[[CONV]] fastmath<contract> : f32
217210
! CHECK: acc.yield %[[ADD]] : f32
218211
! CHECK: }
219212
! CHECK: }
220-
! CHECK: %[[LOAD2:.*]] = fir.load %[[ALLOCA]] : !fir.ref<f32>
221-
! CHECK: %[[CONV3:.*]] = fir.convert %[[LOAD2]] : (f32) -> i32
222-
! CHECK: fir.store %[[CONV3]] to %[[V_DECL]]#1 : !fir.ref<i32>
223213

224214
subroutine array_ref_in_atomic_capture1
225215
integer :: x(10), v
@@ -235,7 +225,7 @@ end subroutine array_ref_in_atomic_capture1
235225
! CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X]](%{{.*}}) {uniq_name = "_QFarray_ref_in_atomic_capture1Ex"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
236226
! CHECK: %[[X_REF:.*]] = hlfir.designate %[[X_DECL]]#0 (%{{.*}}) : (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
237227
! CHECK: acc.atomic.capture {
238-
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[X_REF]] : !fir.ref<i32>, i32
228+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[X_REF]] : !fir.ref<i32>, !fir.ref<i32>, i32
239229
! CHECK: acc.atomic.update %[[X_REF]] : !fir.ref<i32> {
240230
! CHECK: ^bb0(%[[VAL_7:.*]]: i32):
241231
! CHECK: %[[VAL_8:.*]] = arith.addi %[[VAL_7]], %{{.*}} : i32
@@ -262,7 +252,7 @@ end subroutine array_ref_in_atomic_capture2
262252
! CHECK: %[[VAL_8:.*]] = arith.addi %[[VAL_7]], %{{.*}} : i32
263253
! CHECK: acc.yield %[[VAL_8]] : i32
264254
! CHECK: }
265-
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[X_REF]] : !fir.ref<i32>, i32
255+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[X_REF]] : !fir.ref<i32>, !fir.ref<i32>, i32
266256
! CHECK: }
267257

268258
subroutine comp_ref_in_atomic_capture1
@@ -283,7 +273,7 @@ end subroutine comp_ref_in_atomic_capture1
283273
! CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X]] {uniq_name = "_QFcomp_ref_in_atomic_capture1Ex"} : (!fir.ref<!fir.type<_QFcomp_ref_in_atomic_capture1Tt1{c:i32}>>) -> (!fir.ref<!fir.type<_QFcomp_ref_in_atomic_capture1Tt1{c:i32}>>, !fir.ref<!fir.type<_QFcomp_ref_in_atomic_capture1Tt1{c:i32}>>)
284274
! CHECK: %[[C:.*]] = hlfir.designate %[[X_DECL]]#0{"c"} : (!fir.ref<!fir.type<_QFcomp_ref_in_atomic_capture1Tt1{c:i32}>>) -> !fir.ref<i32>
285275
! CHECK: acc.atomic.capture {
286-
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[C]] : !fir.ref<i32>, i32
276+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[C]] : !fir.ref<i32>, !fir.ref<i32>, i32
287277
! CHECK: acc.atomic.update %[[C]] : !fir.ref<i32> {
288278
! CHECK: ^bb0(%[[VAL_5:.*]]: i32):
289279
! CHECK: %[[VAL_6:.*]] = arith.addi %[[VAL_5]], %{{.*}} : i32
@@ -314,5 +304,5 @@ end subroutine comp_ref_in_atomic_capture2
314304
! CHECK: %[[VAL_6:.*]] = arith.addi %[[VAL_5]], %{{.*}} : i32
315305
! CHECK: acc.yield %[[VAL_6]] : i32
316306
! CHECK: }
317-
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[C]] : !fir.ref<i32>, i32
307+
! CHECK: acc.atomic.read %[[V_DECL]]#1 = %[[C]] : !fir.ref<i32>, !fir.ref<i32>, i32
318308
! CHECK: }

flang/test/Lower/OpenACC/acc-atomic-read.f90

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end program acc_atomic_test
1313
! CHECK: %[[G_DECL:.*]]:2 = hlfir.declare %[[VAR_G]] {uniq_name = "_QFEg"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
1414
! CHECK: %[[VAR_H:.*]] = fir.alloca f32 {bindc_name = "h", uniq_name = "_QFEh"}
1515
! CHECK: %[[H_DECL:.*]]:2 = hlfir.declare %[[VAR_H]] {uniq_name = "_QFEh"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
16-
! CHECK: acc.atomic.read %[[G_DECL]]#1 = %[[H_DECL]]#1 : !fir.ref<f32>, f32
16+
! CHECK: acc.atomic.read %[[G_DECL]]#1 = %[[H_DECL]]#1 : !fir.ref<f32>, !fir.ref<f32>, f32
1717
! CHECK: return
1818
! CHECK: }
1919

@@ -39,21 +39,20 @@ subroutine atomic_read_pointer()
3939
! CHECK: %[[BOX_ADDR_X:.*]] = fir.box_addr %[[LOAD_X]] : (!fir.box<!fir.ptr<i32>>) -> !fir.ptr<i32>
4040
! CHECK: %[[LOAD_Y:.*]] = fir.load %[[Y_DECL]]#0 : !fir.ref<!fir.box<!fir.ptr<i32>>>
4141
! CHECK: %[[BOX_ADDR_Y:.*]] = fir.box_addr %[[LOAD_Y]] : (!fir.box<!fir.ptr<i32>>) -> !fir.ptr<i32>
42-
! CHECK: acc.atomic.read %[[BOX_ADDR_Y]] = %[[BOX_ADDR_X]] : !fir.ptr<i32>, i32
42+
! CHECK: acc.atomic.read %[[BOX_ADDR_Y]] = %[[BOX_ADDR_X]] : !fir.ptr<i32>, !fir.ptr<i32>, i32
4343
! CHECK: }
4444

45-
subroutine atomic_read_with_convert()
45+
subroutine atomic_read_with_cast()
4646
integer(4) :: x
4747
integer(8) :: y
4848

4949
!$acc atomic read
5050
y = x
5151
end
5252

53-
! CHECK-LABEL: func.func @_QPatomic_read_with_convert() {
54-
! CHECK: %[[X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFatomic_read_with_convertEx"}
55-
! CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X]] {uniq_name = "_QFatomic_read_with_convertEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
56-
! CHECK: %[[X_CONV:.*]] = fir.convert %[[X_DECL]]#1 : (!fir.ref<i32>) -> !fir.ref<i64>
57-
! CHECK: %[[Y:.*]] = fir.alloca i64 {bindc_name = "y", uniq_name = "_QFatomic_read_with_convertEy"}
58-
! CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[Y]] {uniq_name = "_QFatomic_read_with_convertEy"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>)
59-
! CHECK: acc.atomic.read %[[Y_DECL]]#1 = %[[X_CONV]] : !fir.ref<i64>, i32
53+
! CHECK-LABEL: func.func @_QPatomic_read_with_cast() {
54+
! CHECK: %[[X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFatomic_read_with_castEx"}
55+
! CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X]] {uniq_name = "_QFatomic_read_with_castEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
56+
! CHECK: %[[Y:.*]] = fir.alloca i64 {bindc_name = "y", uniq_name = "_QFatomic_read_with_castEy"}
57+
! CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[Y]] {uniq_name = "_QFatomic_read_with_castEy"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>)
58+
! CHECK: acc.atomic.read %[[Y_DECL]]#1 = %[[X_DECL]]#1 : !fir.ref<i64>, !fir.ref<i32>, i32

flang/test/Lower/OpenACC/acc-atomic-update-array.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ subroutine atomic_read_array1(r, n, x)
4545
! CHECK: %[[DECL_X:.*]]:2 = hlfir.declare %[[ARG2]] dummy_scope %{{[0-9]+}} {uniq_name = "_QFatomic_read_array1Ex"} : (!fir.ref<f32>, !fir.dscope) -> (!fir.ref<f32>, !fir.ref<f32>)
4646
! CHECK: %[[DECL_R:.*]]:2 = hlfir.declare %[[ARG0]](%{{.*}}) dummy_scope %{{[0-9]+}} {uniq_name = "_QFatomic_read_array1Er"} : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.ref<!fir.array<?xf32>>)
4747
! CHECK: %[[DES:.*]] = hlfir.designate %[[DECL_R]]#0 (%{{.*}}) : (!fir.box<!fir.array<?xf32>>, i64) -> !fir.ref<f32>
48-
! CHECK: acc.atomic.read %[[DECL_X]]#1 = %[[DES]] : !fir.ref<f32>, f32
48+
! CHECK: acc.atomic.read %[[DECL_X]]#1 = %[[DES]] : !fir.ref<f32>, !fir.ref<f32>, f32
4949

5050
subroutine atomic_write_array1(r, n, x)
5151
implicit none
@@ -88,5 +88,5 @@ subroutine atomic_capture_array1(r, n, x, y)
8888
! CHECK: %[[ADD:.*]] = arith.addf %[[ARG]], %[[LOAD]] fastmath<contract> : f32
8989
! CHECK: acc.yield %[[ADD]] : f32
9090
! CHECK: }
91-
! CHECK: acc.atomic.read %[[DECL_Y]]#1 = %[[R_I]] : !fir.ref<f32>, f32
91+
! CHECK: acc.atomic.read %[[DECL_Y]]#1 = %[[R_I]] : !fir.ref<f32>, !fir.ref<f32>, f32
9292
! CHECK: }

flang/test/Lower/OpenMP/atomic-capture.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ program OmpAtomicCapture
2222
!CHECK: %[[TEMP:.*]] = arith.muli %[[VAL_Y_LOADED]], %[[ARG]] : i32
2323
!CHECK: omp.yield(%[[TEMP]] : i32)
2424
!CHECK: }
25-
!CHECK: omp.atomic.read %[[VAL_X_DECLARE]]#1 = %[[VAL_Y_DECLARE]]#1 : !fir.ref<i32>, i32
25+
!CHECK: omp.atomic.read %[[VAL_X_DECLARE]]#1 = %[[VAL_Y_DECLARE]]#1 : !fir.ref<i32>, !fir.ref<i32>, i32
2626
!CHECK: }
2727
!$omp atomic hint(omp_sync_hint_uncontended) capture
2828
y = x * y
@@ -36,7 +36,7 @@ program OmpAtomicCapture
3636
!CHECK: %[[NO_REASSOC:.*]] = hlfir.no_reassoc %[[SUB]] : i32
3737
!CHECK: %[[ADD:.*]] = arith.addi %[[VAL_20]], %[[NO_REASSOC]] : i32
3838
!CHECK: omp.atomic.capture hint(nonspeculative) memory_order(acquire) {
39-
!CHECK: omp.atomic.read %[[VAL_X_DECLARE]]#1 = %[[VAL_Y_DECLARE]]#1 : !fir.ref<i32>, i32
39+
!CHECK: omp.atomic.read %[[VAL_X_DECLARE]]#1 = %[[VAL_Y_DECLARE]]#1 : !fir.ref<i32>, !fir.ref<i32>, i32
4040
!CHECK: omp.atomic.write %[[VAL_Y_DECLARE]]#1 = %[[ADD]] : !fir.ref<i32>, i32
4141
!CHECK: }
4242
!CHECK: return
@@ -88,7 +88,7 @@ subroutine pointers_in_atomic_capture()
8888
!CHECK: %[[TEMP:.*]] = arith.addi %[[ARG]], %[[VAL_B]] : i32
8989
!CHECK: omp.yield(%[[TEMP]] : i32)
9090
!CHECK: }
91-
!CHECK: omp.atomic.read %[[VAL_B_BOX_ADDR]] = %[[VAL_A_BOX_ADDR]] : !fir.ptr<i32>, i32
91+
!CHECK: omp.atomic.read %[[VAL_B_BOX_ADDR]] = %[[VAL_A_BOX_ADDR]] : !fir.ptr<i32>, !fir.ptr<i32>, i32
9292
!CHECK: }
9393
!CHECK: return
9494
!CHECK: }

0 commit comments

Comments
 (0)