[flang-commits] [PATCH] D113699: [flang] Fix ORDER= argument to RESHAPE
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Nov 12 10:25:19 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85ec449352fb: [flang] Fix ORDER= argument to RESHAPE (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113699/new/
https://reviews.llvm.org/D113699
Files:
flang/include/flang/Evaluate/constant.h
flang/lib/Evaluate/constant.cpp
flang/runtime/transformational.cpp
flang/test/Evaluate/folding06.f90
Index: flang/test/Evaluate/folding06.f90
===================================================================
--- flang/test/Evaluate/folding06.f90
+++ flang/test/Evaluate/folding06.f90
@@ -63,4 +63,15 @@
.AND.(derived_result%i.EQ.derived_expected_result%i))
logical, parameter :: test_reshape_derived_2 = all(shape(derived_result).EQ.new_shape)
+
+ ! More complicated ORDER= arguments
+ integer, parameter :: int3d(2,3,4) = reshape([(j,j=1,24)],shape(int3d))
+ logical, parameter :: test_int3d = all([int3d] == [(j,j=1,24)])
+ logical, parameter :: test_reshape_order_1 = all([reshape(int3d, [2,3,4], order=[1,2,3])] == [(j,j=1,24)])
+ logical, parameter :: test_reshape_order_2 = all([reshape(int3d, [2,4,3], order=[1,3,2])] == [1,2,7,8,13,14,19,20,3,4,9,10,15,16,21,22,5,6,11,12,17,18,23,24])
+ logical, parameter :: test_reshape_order_3 = all([reshape(int3d, [3,2,4], order=[2,1,3])] == [1,3,5,2,4,6,7,9,11,8,10,12,13,15,17,14,16,18,19,21,23,20,22,24])
+ logical, parameter :: test_reshape_order_4 = all([reshape(int3d, [3,4,2], order=[2,3,1])] == [1,9,17,2,10,18,3,11,19,4,12,20,5,13,21,6,14,22,7,15,23,8,16,24])
+ logical, parameter :: test_reshape_order_5 = all([reshape(int3d, [4,2,3], order=[3,1,2])] == [1,4,7,10,13,16,19,22,2,5,8,11,14,17,20,23,3,6,9,12,15,18,21,24])
+ logical, parameter :: test_reshape_order_6 = all([reshape(int3d, [4,3,2], order=[3,2,1])] == [1,7,13,19,3,9,15,21,5,11,17,23,2,8,14,20,4,10,16,22,6,12,18,24])
+
end module
Index: flang/runtime/transformational.cpp
===================================================================
--- flang/runtime/transformational.cpp
+++ flang/runtime/transformational.cpp
@@ -406,7 +406,7 @@
RUNTIME_CHECK(
terminator, k >= 1 && k <= resultRank && !((values >> k) & 1));
values |= std::uint64_t{1} << k;
- dimOrder[k - 1] = j;
+ dimOrder[j] = k - 1;
}
} else {
for (int j{0}; j < resultRank; ++j) {
Index: flang/lib/Evaluate/constant.cpp
===================================================================
--- flang/lib/Evaluate/constant.cpp
+++ flang/lib/Evaluate/constant.cpp
@@ -85,7 +85,7 @@
if (dim < 1 || dim > rank || seenDimensions.test(dim - 1)) {
return std::nullopt;
}
- dimOrder[dim - 1] = j;
+ dimOrder[j] = dim - 1;
seenDimensions.set(dim - 1);
}
return dimOrder;
Index: flang/include/flang/Evaluate/constant.h
===================================================================
--- flang/include/flang/Evaluate/constant.h
+++ flang/include/flang/Evaluate/constant.h
@@ -50,7 +50,7 @@
// Validate dimension re-ordering like ORDER in RESHAPE.
// On success, return a vector that can be used as dimOrder in
-// ConstantBound::IncrementSubscripts().
+// ConstantBounds::IncrementSubscripts().
std::optional<std::vector<int>> ValidateDimensionOrder(
int rank, const std::vector<int> &order);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113699.386881.patch
Type: text/x-patch
Size: 2902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211112/c1f1cb34/attachment-0001.bin>
More information about the flang-commits
mailing list