Skip to content

Commit 0469bb9

Browse files
authored
[flang][cuda] Fix lowering when step is a variable (#119421)
Add missing conversion.
1 parent a42aa8f commit 0469bb9

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,8 +3037,10 @@ class FirConverter : public Fortran::lower::AbstractConverter {
30373037
fir::getBase(genExprValue(*Fortran::semantics::GetExpr(bounds->upper),
30383038
stmtCtx))));
30393039
if (bounds->step)
3040-
steps.push_back(fir::getBase(
3041-
genExprValue(*Fortran::semantics::GetExpr(bounds->step), stmtCtx)));
3040+
steps.push_back(builder->createConvert(
3041+
crtLoc, idxTy,
3042+
fir::getBase(genExprValue(
3043+
*Fortran::semantics::GetExpr(bounds->step), stmtCtx))));
30423044
else // If `step` is not present, assume it is `1`.
30433045
steps.push_back(builder->createIntegerConstant(loc, idxTy, 1));
30443046

flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,18 @@ end subroutine
9898

9999
! CHECK-LABEL: func.func @_QPsub2
100100
! CHECK: cuf.kernel
101+
102+
subroutine sub3()
103+
integer, device :: a(10), b(10)
104+
integer :: lb = 1
105+
integer :: n = 10
106+
integer :: s = 1
107+
108+
!$cuf kernel do <<< *, * >>>
109+
do i = lb, n, s
110+
a(i) = a(i) * b(i)
111+
end do
112+
end
113+
114+
! CHECK-LABEL: func.func @_QPsub3
115+
! CHECK: cuf.kernel

0 commit comments

Comments
 (0)