[flang-commits] [flang] f815d1f - [flang][cuda] Fix iv store in cuf kernel (#90551)

via flang-commits flang-commits at lists.llvm.org
Tue Apr 30 08:27:32 PDT 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-30T08:27:28-07:00
New Revision: f815d1f71f644a6cfd2c22bf7898a1034be235ad

URL: https://github.com/llvm/llvm-project/commit/f815d1f71f644a6cfd2c22bf7898a1034be235ad
DIFF: https://github.com/llvm/llvm-project/commit/f815d1f71f644a6cfd2c22bf7898a1034be235ad.diff

LOG: [flang][cuda] Fix iv store in cuf kernel (#90551)

Store of the current induction value to the user IV was not placed
correctly in the body of the cuf kernel.

@ImanHosseini

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 b42909eaaacc45..d00346433255ee 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -2651,9 +2651,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
       builder->create<fir::StoreOp>(loc, convArg, value);
     }
 
-    builder->create<fir::FirEndOp>(loc);
-    builder->setInsertionPointToStart(&b);
-
     Fortran::lower::pft::Evaluation *crtEval = &getEval();
     if (crtEval->lowerAsStructured()) {
       crtEval = &crtEval->getFirstNestedEvaluation();
@@ -2665,6 +2662,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
     for (Fortran::lower::pft::Evaluation &e : crtEval->getNestedEvaluations())
       genFIR(e);
 
+    builder->create<fir::FirEndOp>(loc);
     builder->setInsertionPointAfter(op);
     localSymbols.popScope();
   }

diff  --git a/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf b/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
index 9b728cd19eb552..d80542f76c92ed 100644
--- a/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
+++ b/flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf
@@ -24,6 +24,7 @@ subroutine sub1()
 ! CHECK-NOT: fir.do_loop
 ! CHECK: %[[ARG0_I32:.*]] = fir.convert %[[ARG0]] : (index) -> i32
 ! CHECK: fir.store %[[ARG0_I32]] to %[[IV]]#1 : !fir.ref<i32>
+! CHECK: hlfir.assign
 
 
   !$cuf kernel do <<< *, * >>>


        


More information about the flang-commits mailing list