[flang-commits] [flang] bb6a1eb - Revert "[flang][openacc] Fix lowerbound when there is no subscripts"

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Tue May 9 12:59:29 PDT 2023


Author: Valentin Clement
Date: 2023-05-09T12:59:14-07:00
New Revision: bb6a1eb003320cdfd4a5887ad2cd8577275c2f95

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

LOG: Revert "[flang][openacc] Fix lowerbound when there is no subscripts"

This reverts commit 626aa8518d873c5760cd033fe49b1809c9de3494.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 187b8e9ccad9..faf1b7c02467 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -146,10 +146,12 @@ genBaseBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
     mlir::Value baseLb =
         fir::factory::readLowerBound(builder, loc, dataExv, dim, one);
     mlir::Value ext = fir::factory::readExtent(builder, loc, dataExv, dim);
-    mlir::Value lb = builder.createIntegerConstant(loc, idxTy, 0);
+    mlir::Value lb =
+        baseLb == one ? builder.createIntegerConstant(loc, idxTy, 0) : baseLb;
 
-    // ub = extent - 1
-    mlir::Value ub = builder.create<mlir::arith::SubIOp>(loc, ext, one);
+    // ub = baseLb + extent - 1
+    mlir::Value lbExt = builder.create<mlir::arith::AddIOp>(loc, ext, baseLb);
+    mlir::Value ub = builder.create<mlir::arith::SubIOp>(loc, lbExt, one);
     mlir::Value bound = builder.create<mlir::acc::DataBoundsOp>(
         loc, boundTy, lb, ub, mlir::Value(), one, false, baseLb);
     bounds.push_back(bound);

diff  --git a/flang/test/Lower/OpenACC/acc-enter-data.f90 b/flang/test/Lower/OpenACC/acc-enter-data.f90
index a6ee866e5ebb..1aa7f579945a 100644
--- a/flang/test/Lower/OpenACC/acc-enter-data.f90
+++ b/flang/test/Lower/OpenACC/acc-enter-data.f90
@@ -18,10 +18,12 @@ subroutine acc_enter_data
   !$acc enter data create(a)
 !CHECK: %[[ONE:.*]] = arith.constant 1 : index
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[C10]], %[[ONE]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[C10]], %[[ONE]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[ONE]] : index
 !CHECK: %[[BOUND0:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index)
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[EXTENT_C10]], %[[ONE]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[EXTENT_C10]], %[[ONE]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[ONE]] : index
 !CHECK: %[[BOUND1:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index)
 !CHECK: %[[CREATE_A:.*]] = acc.create varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%[[BOUND0]], %[[BOUND1]]) -> !fir.ref<!fir.array<10x10xf32>> {name = "a", structured = false}
 !CHECK: acc.enter_data dataOperands(%[[CREATE_A]] : !fir.ref<!fir.array<10x10xf32>>){{$}}
@@ -29,10 +31,12 @@ subroutine acc_enter_data
   !$acc enter data create(a) if(.true.)
 !CHECK: %[[ONE:.*]] = arith.constant 1 : index
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[C10]], %[[ONE]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[C10]], %[[ONE]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[ONE]] : index
 !CHECK: %[[BOUND0:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index)
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[EXTENT_C10]], %[[ONE]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[EXTENT_C10]], %[[ONE]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[ONE]] : index
 !CHECK: %[[BOUND1:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index)
 !CHECK: %[[CREATE_A:.*]] = acc.create varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%[[BOUND0]], %[[BOUND1]]) -> !fir.ref<!fir.array<10x10xf32>> {name = "a", structured = false}
 !CHECK: [[IF1:%.*]] = arith.constant true
@@ -41,10 +45,12 @@ subroutine acc_enter_data
   !$acc enter data create(a) if(ifCondition)
 !CHECK: %[[ONE:.*]] = arith.constant 1 : index
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[C10]], %[[ONE]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[C10]], %[[ONE]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[ONE]] : index
 !CHECK: %[[BOUND0:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index)
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[EXTENT_C10]], %[[ONE]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[EXTENT_C10]], %[[ONE]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[ONE]] : index
 !CHECK: %[[BOUND1:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[ONE]] : index)
 !CHECK: %[[CREATE_A:.*]] = acc.create varPtr(%[[A]] : !fir.ref<!fir.array<10x10xf32>>) bounds(%[[BOUND0]], %[[BOUND1]]) -> !fir.ref<!fir.array<10x10xf32>> {name = "a", structured = false}
 !CHECK: [[IFCOND:%.*]] = fir.load %{{.*}} : !fir.ref<!fir.logical<4>>
@@ -260,7 +266,6 @@ subroutine acc_enter_data_dummy(a, b, n, m)
 ! Test lowering of array section for non default lower bound.
 subroutine acc_enter_data_non_default_lb()
   integer :: a(0:9)
-  integer :: b(11:20)
 
 !CHECK-LABEL: func.func @_QPacc_enter_data_non_default_lb() {
 !CHECK: %[[BASELB:.*]] = arith.constant 0 : index
@@ -301,14 +306,6 @@ subroutine acc_enter_data_non_default_lb()
 !CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[ONE]] : index
 !CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%[[BASELB]] : index)
 !CHECK: %[[CREATE:.*]] = acc.create varPtr(%[[A]] : !fir.ref<!fir.array<10xi32>>) bounds(%[[BOUND]]) -> !fir.ref<!fir.array<10xi32>> {name = "a(4:)", structured = false}
-!CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.ref<!fir.array<10xi32>>)
-
-  !$acc enter data create(b)
-!CHECK: %[[ONE:.*]] = arith.constant 1 : index 
-!CHECK: %[[LB:.*]] = arith.constant 0 : index 
-!CHECK: %[[UB:.*]] = arith.subi %c10{{.*}}, %[[ONE]] : index 
-!CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[ONE]] : index) startIdx(%c11{{.*}} : index) 
-!CHECK: %[[CREATE:.*]] = acc.create varPtr(%1 : !fir.ref<!fir.array<10xi32>>) bounds(%[[BOUND]]) -> !fir.ref<!fir.array<10xi32>> {name = "b", structured = false} 
 !CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.ref<!fir.array<10xi32>>)
 
 end subroutine
@@ -601,7 +598,8 @@ subroutine acc_enter_data_derived_type()
 !CHECK: %[[C10:.*]] = arith.constant 10 : index
 !CHECK: %[[C1:.*]] = arith.constant 1 : index
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[C10]], %[[C1]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[C10]], %[[C1]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[C1]] : index
 !CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[C1]] : index) startIdx(%[[C1]] : index)
 !CHECK: %[[CREATE:.*]] = acc.create varPtr(%[[ARRAY_COORD]] : !fir.ref<!fir.array<10xf32>>) bounds(%[[BOUND]]) -> !fir.ref<!fir.array<10xf32>> {name = "a%array", structured = false}
 !CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.ref<!fir.array<10xf32>>)
@@ -657,7 +655,8 @@ subroutine acc_enter_data_derived_type()
 !CHECK: %[[C10:.*]] = arith.constant 10 : index
 !CHECK: %[[C1:.*]] = arith.constant 1 : index
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[C10]], %[[C1]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[C10]], %[[C1]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[C1]] : index
 !CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[C1]] : index) startIdx(%[[C1]] : index)
 !CHECK: %[[CREATE:.*]] = acc.create varPtr(%[[ARRAY_COORD]] : !fir.ref<!fir.array<10xf32>>) bounds(%[[BOUND]]) -> !fir.ref<!fir.array<10xf32>> {name = "b%d%array", structured = false}
 
@@ -688,7 +687,8 @@ subroutine acc_enter_data_derived_type()
 !CHECK: %[[C10:.*]] = arith.constant 10 : index
 !CHECK: %[[C1:.*]] = arith.constant 1 : index
 !CHECK: %[[LB:.*]] = arith.constant 0 : index
-!CHECK: %[[UB:.*]] = arith.subi %[[C10]], %[[C1]] : index
+!CHECK: %[[LBEXT:.*]] = arith.addi %[[C10]], %[[C1]] : index
+!CHECK: %[[UB:.*]] = arith.subi %[[LBEXT]], %[[C1]] : index
 !CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[C1]] : index) startIdx(%[[C1]] : index)
 !CHECK: %[[CREATE:.*]] = acc.create varPtr(%[[ARRAY_COORD]] : !fir.ref<!fir.array<10xf32>>) bounds(%[[BOUND]]) -> !fir.ref<!fir.array<10xf32>> {name = "d%d(1_8)%array", structured = false}
 !CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.ref<!fir.array<10xf32>>)


        


More information about the flang-commits mailing list