Skip to content

[flang] Don't needlessly instantiate distinct UNSIGNED cases for FINDLOC #120471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

klausler
Copy link
Contributor

The FINDLOC runtime doesn't need to distinguish between INTEGER and UNSIGNED data, so use the code for INTEGER also for UNSIGNED.

The FINDLOC runtime doesn't need to distinguish between INTEGER
and UNSIGNED data, so use the code for INTEGER also for UNSIGNED.
@klausler klausler requested a review from vzakhari December 18, 2024 19:32
@llvmbot llvmbot added flang:runtime flang Flang issues not falling into any other category labels Dec 18, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 18, 2024

@llvm/pr-subscribers-flang-runtime

Author: Peter Klausler (klausler)

Changes

The FINDLOC runtime doesn't need to distinguish between INTEGER and UNSIGNED data, so use the code for INTEGER also for UNSIGNED.


Full diff: https://github.com/llvm/llvm-project/pull/120471.diff

1 Files Affected:

  • (modified) flang/runtime/findloc.cpp (+3-18)
diff --git a/flang/runtime/findloc.cpp b/flang/runtime/findloc.cpp
index d05e9c58074c73..b9b1d7f7ab689f 100644
--- a/flang/runtime/findloc.cpp
+++ b/flang/runtime/findloc.cpp
@@ -159,14 +159,9 @@ struct NumericFindlocHelper {
         Terminator &terminator) const {
       switch (targetCat) {
       case TypeCategory::Integer:
-        ApplyIntegerKind<
-            HELPER<CAT, KIND, TypeCategory::Integer>::template Functor, void>(
-            targetKind, terminator, result, x, target, kind, dim, mask, back,
-            terminator);
-        break;
       case TypeCategory::Unsigned:
         ApplyIntegerKind<
-            HELPER<CAT, KIND, TypeCategory::Unsigned>::template Functor, void>(
+            HELPER<CAT, KIND, TypeCategory::Integer>::template Functor, void>(
             targetKind, terminator, result, x, target, kind, dim, mask, back,
             terminator);
         break;
@@ -235,13 +230,8 @@ void RTDEF(Findloc)(Descriptor &result, const Descriptor &x,
   RUNTIME_CHECK(terminator, xType.has_value() && targetType.has_value());
   switch (xType->first) {
   case TypeCategory::Integer:
-    ApplyIntegerKind<NumericFindlocHelper<TypeCategory::Integer,
-                         TotalNumericFindlocHelper>::template Functor,
-        void>(xType->second, terminator, targetType->first, targetType->second,
-        result, x, target, kind, 0, mask, back, terminator);
-    break;
   case TypeCategory::Unsigned:
-    ApplyIntegerKind<NumericFindlocHelper<TypeCategory::Unsigned,
+    ApplyIntegerKind<NumericFindlocHelper<TypeCategory::Integer,
                          TotalNumericFindlocHelper>::template Functor,
         void>(xType->second, terminator, targetType->first, targetType->second,
         result, x, target, kind, 0, mask, back, terminator);
@@ -331,13 +321,8 @@ void RTDEF(FindlocDim)(Descriptor &result, const Descriptor &x,
   RUNTIME_CHECK(terminator, xType.has_value() && targetType.has_value());
   switch (xType->first) {
   case TypeCategory::Integer:
-    ApplyIntegerKind<NumericFindlocHelper<TypeCategory::Integer,
-                         PartialNumericFindlocHelper>::template Functor,
-        void>(xType->second, terminator, targetType->first, targetType->second,
-        result, x, target, kind, dim, mask, back, terminator);
-    break;
   case TypeCategory::Unsigned:
-    ApplyIntegerKind<NumericFindlocHelper<TypeCategory::Unsigned,
+    ApplyIntegerKind<NumericFindlocHelper<TypeCategory::Integer,
                          PartialNumericFindlocHelper>::template Functor,
         void>(xType->second, terminator, targetType->first, targetType->second,
         result, x, target, kind, dim, mask, back, terminator);

Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@klausler klausler merged commit 9f3a611 into llvm:main Dec 18, 2024
8 of 9 checks passed
@klausler klausler deleted the unsigned branch December 18, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:runtime flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants