[flang-commits] [flang] e0cd781 - [flang][openacc] Fix getBoundsString for reduction recipe name (#68146)

via flang-commits flang-commits at lists.llvm.org
Tue Oct 3 13:08:05 PDT 2023


Author: Valentin Clement (バレンタイン クレメン)
Date: 2023-10-03T13:08:00-07:00
New Revision: e0cd781f3b1c2207043d2b6b9027e340304f9d6e

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

LOG: [flang][openacc] Fix getBoundsString for reduction recipe name (#68146)

`getBoundsString` is used to generate the reduction recipe names when an
array section is provided. The lowerbound and upperbound were swapped.
This patch fixes it.

Added: 
    

Modified: 
    flang/lib/Lower/OpenACC.cpp
    flang/test/Lower/OpenACC/acc-reduction.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 57dd0fab2b9c69a..cc2a69c36809b10 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -492,8 +492,8 @@ std::string getBoundsString(llvm::SmallVector<mlir::Value> &bounds) {
             fir::getIntIfConstant(boundsOp.getLowerbound()) &&
             boundsOp.getUpperbound() &&
             fir::getIntIfConstant(boundsOp.getUpperbound())) {
-          boundStr << "lb" << *fir::getIntIfConstant(boundsOp.getUpperbound())
-                   << ".ub" << *fir::getIntIfConstant(boundsOp.getLowerbound());
+          boundStr << "lb" << *fir::getIntIfConstant(boundsOp.getLowerbound())
+                   << ".ub" << *fir::getIntIfConstant(boundsOp.getUpperbound());
         } else if (boundsOp.getExtent() &&
                    fir::getIntIfConstant(boundsOp.getExtent())) {
           boundStr << "ext" << *fir::getIntIfConstant(boundsOp.getExtent());

diff  --git a/flang/test/Lower/OpenACC/acc-reduction.f90 b/flang/test/Lower/OpenACC/acc-reduction.f90
index 20231c0f6c7bd43..ea058d031a21819 100644
--- a/flang/test/Lower/OpenACC/acc-reduction.f90
+++ b/flang/test/Lower/OpenACC/acc-reduction.f90
@@ -1059,7 +1059,7 @@ subroutine acc_reduction_add_static_slice(a)
 ! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[C1]] : index) startIdx(%[[C1]] : index)
 ! FIR:   %[[RED:.*]] = acc.reduction varPtr(%[[ARG0]] : !fir.ref<!fir.array<100xi32>>) bounds(%[[BOUND]]) -> !fir.ref<!fir.array<100xi32>> {name = "a(11:20)"}
 ! HLFIR: %[[RED:.*]] = acc.reduction varPtr(%[[DECLARG0]]#1 : !fir.ref<!fir.array<100xi32>>) bounds(%[[BOUND]]) -> !fir.ref<!fir.array<100xi32>> {name = "a(11:20)"}
-! CHECK: acc.parallel reduction(@reduction_add_section_lb19.ub10_ref_100xi32 -> %[[RED]] : !fir.ref<!fir.array<100xi32>>)
+! CHECK: acc.parallel reduction(@reduction_add_section_lb10.ub19_ref_100xi32 -> %[[RED]] : !fir.ref<!fir.array<100xi32>>)
 
 subroutine acc_reduction_add_dynamic_extent_add(a)
   integer :: a(:)


        


More information about the flang-commits mailing list