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

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Mon Apr 29 20:24:07 PDT 2024


https://github.com/clementval created https://github.com/llvm/llvm-project/pull/90551

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

@ImanHosseini 

>From 44791b5d3644685179d62a8bdbc0a3fbd212ecd7 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Mon, 29 Apr 2024 20:22:34 -0700
Subject: [PATCH] [flang][cuda] Fix iv store in cuf kernel

---
 flang/lib/Lower/Bridge.cpp                           | 4 +---
 flang/test/Lower/CUDA/cuda-kernel-loop-directive.cuf | 1 +
 2 files changed, 2 insertions(+), 3 deletions(-)

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