Skip to content

Delete duplicated hlfir.declare op of induction variables of do concurrent when inside cuf kernel directive. #134467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3209,13 +3209,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
builder->restoreInsertionPoint(insPt);
}

// Create the hlfir.declare operation using the symbol's name
auto declareOp = builder->create<hlfir::DeclareOp>(
loc, ivValue, toStringRef(name.symbol->name()));
ivValue = declareOp.getResult(0);

// Bind the symbol to the declared variable
bindSymbol(*name.symbol, ivValue);
Fortran::lower::SymbolBox hsb = localSymbols.lookupSymbol(*name.symbol);
fir::ExtendedValue extIvValue = symBoxToExtendedValue(hsb);
ivValue = fir::getBase(extIvValue);
ivValues.push_back(ivValue);
ivTypes.push_back(idxTy);
ivLocs.push_back(loc);
Expand Down
11 changes: 7 additions & 4 deletions flang/test/Lower/CUDA/cuda-doconc.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ subroutine doconc1
end

! CHECK: func.func @_QPdoconc1() {
! CHECK: %[[DECL:.*]]:2 = hlfir.declare %{{.*}}#0 {uniq_name = "_QFdoconc1Ei"} : (!fir.ref<index>) -> (!fir.ref<index>, !fir.ref<index>)
! CHECK: cuf.kernel<<<*, *>>>
! CHECK: %[[DECL:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFdoconc1Ei"} : (!fir.ref<index>) -> (!fir.ref<index>, !fir.ref<index>)
! CHECK: cuf.kernel<<<*, *>>> (%arg0 : index)
! CHECK: fir.store %arg0 to %[[DECL]]#0 : !fir.ref<index>
! CHECK: %{{.*}} = fir.load %[[DECL]]#0 : !fir.ref<index>

subroutine doconc2
Expand All @@ -32,8 +33,10 @@ subroutine doconc2
end

! CHECK: func.func @_QPdoconc2() {
! CHECK: %[[DECLI:.*]]:2 = hlfir.declare %{{.*}}#0 {uniq_name = "_QFdoconc2Ei"} : (!fir.ref<index>) -> (!fir.ref<index>, !fir.ref<index>)
! CHECK: %[[DECLJ:.*]]:2 = hlfir.declare %{{.*}}#0 {uniq_name = "_QFdoconc2Ej"} : (!fir.ref<index>) -> (!fir.ref<index>, !fir.ref<index>)
! CHECK: %[[DECLI:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFdoconc2Ei"} : (!fir.ref<index>) -> (!fir.ref<index>, !fir.ref<index>)
! CHECK: %[[DECLJ:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFdoconc2Ej"} : (!fir.ref<index>) -> (!fir.ref<index>, !fir.ref<index>)
! CHECK: cuf.kernel<<<*, *>>> (%arg0 : index, %arg1 : index) = (%{{.*}}, %{{.*}} : index, index) to (%{{.*}}, %{{.*}} : index, index) step (%{{.*}}, %{{.*}} : index, index) {
! CHECK: fir.store %arg0 to %[[DECLI]]#0 : !fir.ref<index>
! CHECK: fir.store %arg1 to %[[DECLJ]]#0 : !fir.ref<index>
! CHECK: %{{.*}} = fir.load %[[DECLI]]#0 : !fir.ref<index>
! CHECK: %{{.*}} = fir.load %[[DECLJ]]#0 : !fir.ref<index>
Loading