diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -647,7 +647,7 @@ llvm::SmallVector loops; llvm::SmallVector ivs; - for (auto ext : seqTy.getShape()) { + for (auto ext : llvm::reverse(seqTy.getShape())) { auto lb = builder.create( loc, idxTy, builder.getIntegerAttr(idxTy, 0)); auto ub = builder.create( diff --git a/flang/test/Lower/OpenACC/acc-reduction.f90 b/flang/test/Lower/OpenACC/acc-reduction.f90 --- a/flang/test/Lower/OpenACC/acc-reduction.f90 +++ b/flang/test/Lower/OpenACC/acc-reduction.f90 @@ -123,7 +123,7 @@ ! CHECK: } combiner { ! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref>, %[[ARG1:.*]]: !fir.ref>): ! CHECK: %[[LB0:.*]] = arith.constant 0 : index -! CHECK: %[[UB0:.*]] = arith.constant 99 : index +! CHECK: %[[UB0:.*]] = arith.constant 1 : index ! CHECK: %[[STEP0:.*]] = arith.constant 1 : index ! CHECK: fir.do_loop %[[IV0:.*]] = %[[LB0]] to %[[UB0]] step %[[STEP0]] { ! CHECK: %[[LB1:.*]] = arith.constant 0 : index @@ -131,7 +131,7 @@ ! CHECK: %[[STEP1:.*]] = arith.constant 1 : index ! CHECK: fir.do_loop %[[IV1:.*]] = %[[LB1]] to %[[UB1]] step %[[STEP1]] { ! CHECK: %[[LB2:.*]] = arith.constant 0 : index -! CHECK: %[[UB2:.*]] = arith.constant 1 : index +! CHECK: %[[UB2:.*]] = arith.constant 99 : index ! CHECK: %[[STEP2:.*]] = arith.constant 1 : index ! CHECK: fir.do_loop %[[IV2:.*]] = %[[LB2]] to %[[UB2]] step %[[STEP2]] { ! CHECK: %[[COORD1:.*]] = fir.coordinate_of %[[ARG0]], %[[IV0]], %[[IV1]], %[[IV2]] : (!fir.ref>, index, index, index) -> !fir.ref @@ -153,11 +153,11 @@ ! CHECK: } combiner { ! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref>, %[[ARG1:.*]]: !fir.ref>): ! CHECK: %[[LB0:.*]] = arith.constant 0 : index -! CHECK: %[[UB0:.*]] = arith.constant 99 : index +! CHECK: %[[UB0:.*]] = arith.constant 9 : index ! CHECK: %[[STEP0:.*]] = arith.constant 1 : index ! CHECK: fir.do_loop %[[IV0:.*]] = %[[LB0]] to %[[UB0]] step %[[STEP0]] { ! CHECK: %[[LB1:.*]] = arith.constant 0 : index -! CHECK: %[[UB1:.*]] = arith.constant 9 : index +! CHECK: %[[UB1:.*]] = arith.constant 99 : index ! CHECK: %[[STEP1:.*]] = arith.constant 1 : index ! CHECK: fir.do_loop %[[IV1:.*]] = %[[LB1]] to %[[UB1]] step %[[STEP1]] { ! CHECK: %[[COORD1:.*]] = fir.coordinate_of %[[ARG0]], %[[IV0]], %[[IV1]] : (!fir.ref>, index, index) -> !fir.ref