From bd577afe8fcc92fb28b421db14e96207dcd86e97 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Tue, 7 Jun 2022 10:11:17 -0700 Subject: [PATCH] [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 --- flang/runtime/transformational.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp index ac12627..9a01681 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) { -- 2.7.4