[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
This commit is contained in:
Peter Klausler 2022-06-07 10:11:17 -07:00
parent 6bc2ad235a
commit bd577afe8f
1 changed files with 1 additions and 1 deletions

View File

@ -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) {