[flang-commits] [flang] b8ecdcd - [flang] Fix the vector version of EOSHIFT with a BOUNDARY argument

Peter Steinfeld via flang-commits flang-commits at lists.llvm.org
Tue Aug 17 15:21:59 PDT 2021


Author: Peter Steinfeld
Date: 2021-08-17T15:20:15-07:00
New Revision: b8ecdcdd817cfe8ef187503726400971357c6854

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

LOG: [flang] Fix the vector version of EOSHIFT with a BOUNDARY argument

When the vector version of EOSHIFT was called, the BOUNDARY argument was being
ignored.  I fixed that and added a test that would not pass without this fix.

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

Added: 
    

Modified: 
    flang/runtime/transformational.cpp
    flang/unittests/Runtime/Transformational.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index 3fc294bc948bc..1bf93386dd88a 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -284,6 +284,8 @@ void RTNAME(EoshiftVector)(Descriptor &result, const Descriptor &source,
     SubscriptValue sourceAt{lb + j - 1 + shift};
     if (sourceAt >= lb && sourceAt < lb + extent) {
       CopyElement(result, &j, source, &sourceAt, terminator);
+    } else if (boundary) {
+      CopyElement(result, &j, *boundary, 0, terminator);
     }
   }
 }

diff  --git a/flang/unittests/Runtime/Transformational.cpp b/flang/unittests/Runtime/Transformational.cpp
index 1394e53aefc66..52e0b7ecfec0c 100644
--- a/flang/unittests/Runtime/Transformational.cpp
+++ b/flang/unittests/Runtime/Transformational.cpp
@@ -110,6 +110,26 @@ TEST(Transformational, Shifts) {
         *result.ZeroBasedIndexedElement<std::int32_t>(j), eoshiftExpect1[j]);
   }
   result.Destroy();
+
+  // VECTOR EOSHIFT
+  StaticDescriptor<0> boundaryDescriptor;
+  Descriptor vectorBoundary{boundaryDescriptor.descriptor()};
+  std::int32_t boundaryValue{343};
+  vectorBoundary.Establish(TypeCategory::Integer, 4,
+      const_cast<void *>(reinterpret_cast<const void *>(&boundaryValue)), 0);
+  RTNAME(EoshiftVector)
+  (vectorResult, *vector, 2, &vectorBoundary, __FILE__, __LINE__);
+  EXPECT_EQ(vectorResult.type(), array->type());
+  EXPECT_EQ(vectorResult.rank(), 1);
+  EXPECT_EQ(vectorResult.GetDimension(0).LowerBound(), 1);
+  EXPECT_EQ(vectorResult.GetDimension(0).Extent(), 6);
+  EXPECT_EQ(vectorResult.type(), (TypeCode{TypeCategory::Integer, 4}));
+  static std::int32_t eoshiftVectorExpect[6]{3, 4, 5, 6, 343, 343};
+  for (int j{0}; j < 6; ++j) {
+    EXPECT_EQ(*vectorResult.ZeroBasedIndexedElement<std::int32_t>(j),
+        eoshiftVectorExpect[j]);
+  }
+  vectorResult.Destroy();
 }
 
 TEST(Transformational, Pack) {


        


More information about the flang-commits mailing list