[flang-commits] [PATCH] D127424: [flang][runtime] Fix runtime CSHIFT of rank>1 array case of negative shift count

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Jun 9 12:09:27 PDT 2022


klausler created this revision.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

The calculation of the source index was incorrect when a CSHIFT shift
count value is negative, for the implementation of CSHIFT for arrays
with rank >= 2.  (The vector CSHIFT is fine.)


https://reviews.llvm.org/D127424

Files:
  flang/runtime/transformational.cpp


Index: flang/runtime/transformational.cpp
===================================================================
--- flang/runtime/transformational.cpp
+++ flang/runtime/transformational.cpp
@@ -167,7 +167,7 @@
     }
     SubscriptValue &sourceDim{sourceAt[dim - 1]};
     sourceDim = dimLB + shiftCount % dimExtent;
-    if (shiftCount < 0) {
+    if (sourceDim < dimLB) {
       sourceDim += dimExtent;
     }
     for (resDim = 1; resDim <= dimExtent; ++resDim) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127424.435633.patch
Type: text/x-patch
Size: 465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220609/6c8e7953/attachment-0001.bin>


More information about the flang-commits mailing list