[flang-commits] [flang] 0469bb9 - [flang][cuda] Fix lowering when step is a variable (#119421)
via flang-commits
flang-commits at lists.llvm.org
Tue Dec 10 09:48:18 PST 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-12-10T09:48:15-08:00
New Revision: 0469bb91aa82b331052d314de53546548e6eb060
URL: https://github.com/llvm/llvm-project/commit/0469bb91aa82b331052d314de53546548e6eb060
DIFF: https://github.com/llvm/llvm-project/commit/0469bb91aa82b331052d314de53546548e6eb060.diff
LOG: [flang][cuda] Fix lowering when step is a variable (#119421)
Add missing conversion.
Added:
Modified:
flang/lib/Lower/Bridge.cpp
flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
Removed:
################################################################################
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index ce8e18bea26db5..de2b941b688bee 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -3037,8 +3037,10 @@ class FirConverter : public Fortran::lower::AbstractConverter {
fir::getBase(genExprValue(*Fortran::semantics::GetExpr(bounds->upper),
stmtCtx))));
if (bounds->step)
- steps.push_back(fir::getBase(
- genExprValue(*Fortran::semantics::GetExpr(bounds->step), stmtCtx)));
+ steps.push_back(builder->createConvert(
+ crtLoc, idxTy,
+ fir::getBase(genExprValue(
+ *Fortran::semantics::GetExpr(bounds->step), stmtCtx))));
else // If `step` is not present, assume it is `1`.
steps.push_back(builder->createIntegerConstant(loc, idxTy, 1));
diff --git a/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf b/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
index aac569b6eb35bd..09aefc055e6fa1 100644
--- a/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
+++ b/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
@@ -98,3 +98,18 @@ end subroutine
! CHECK-LABEL: func.func @_QPsub2
! CHECK: cuf.kernel
+
+subroutine sub3()
+ integer, device :: a(10), b(10)
+ integer :: lb = 1
+ integer :: n = 10
+ integer :: s = 1
+
+ !$cuf kernel do <<< *, * >>>
+ do i = lb, n, s
+ a(i) = a(i) * b(i)
+ end do
+end
+
+! CHECK-LABEL: func.func @_QPsub3
+! CHECK: cuf.kernel
More information about the flang-commits
mailing list