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

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Jun 13 11:34:34 PDT 2022


Author: Peter Klausler
Date: 2022-06-13T11:34:25-07:00
New Revision: bd577afe8fcc92fb28b421db14e96207dcd86e97

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

LOG: [flang][runtime] Fix runtime CSHIFT of rank>1 array case of negative shift count

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.)

Differential Revision: https://reviews.llvm.org/D127424

Added: 
    

Modified: 
    flang/runtime/transformational.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index ac12627293aa..9a0168167886 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -167,7 +167,7 @@ void RTNAME(Cshift)(Descriptor &result, const Descriptor &source,
     }
     SubscriptValue &sourceDim{sourceAt[dim - 1]};
     sourceDim = dimLB + shiftCount % dimExtent;
-    if (shiftCount < 0) {
+    if (sourceDim < dimLB) {
       sourceDim += dimExtent;
     }
     for (resDim = 1; resDim <= dimExtent; ++resDim) {


        


More information about the flang-commits mailing list