Skip to content

[flang] Support KNINT and KIDNNT legacy intrinsic functions #79190

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
Jan 26, 2024

Conversation

klausler
Copy link
Contributor

These specific intrinsic functions are legacy names that map to the standard generic NINT(..., KIND=8).

These specific intrinsic functions are legacy names that map
to the standard generic NINT(..., KIND=8).
@klausler klausler requested a review from vzakhari January 23, 2024 18:58
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jan 23, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 23, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

These specific intrinsic functions are legacy names that map to the standard generic NINT(..., KIND=8).


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

2 Files Affected:

  • (modified) flang/lib/Evaluate/intrinsics.cpp (+6)
  • (modified) flang/test/Evaluate/folding02.f90 (+17-13)
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index da6d5970089884c..9bacb6d825ae5ac 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1113,6 +1113,12 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
     {{"kiabs", {{"a", TypePattern{IntType, KindCode::exactKind, 8}}},
          TypePattern{IntType, KindCode::exactKind, 8}},
         "abs"},
+    {{"kidnnt", {{"a", DoublePrecision}},
+         TypePattern{IntType, KindCode::exactKind, 8}},
+        "nint"},
+    {{"knint", {{"a", DefaultReal}},
+         TypePattern{IntType, KindCode::exactKind, 8}},
+        "nint"},
     {{"len", {{"string", DefaultChar, Rank::anyOrAssumedRank}}, DefaultInt,
         Rank::scalar, IntrinsicClass::inquiryFunction}},
     {{"lge", {{"string_a", DefaultChar}, {"string_b", DefaultChar}},
diff --git a/flang/test/Evaluate/folding02.f90 b/flang/test/Evaluate/folding02.f90
index 6374be35286cef2..89e2a09aa31b727 100644
--- a/flang/test/Evaluate/folding02.f90
+++ b/flang/test/Evaluate/folding02.f90
@@ -277,18 +277,22 @@ module m
     (1.3223499632715445262221010125358588993549346923828125_8, &
      1.7371201007364975854585509296157397329807281494140625_8))
 
-! Extension specific intrinsic variants of ABS
-  logical, parameter, test_babs1 = kind(babs(-1_1)) == 1
-  logical, parameter, test_babs2 = babs(-1_1) == 1_1
-  logical, parameter, test_iiabs1 = kind(iiabs(-1_2)) == 2
-  logical, parameter, test_iiabs2 = iiabs(-1_2) == 1_2
-  logical, parameter, test_jiabs1 = kind(jiabs(-1_4)) == 4
-  logical, parameter, test_jiabs2 = jiabs(-1_4) == 1_4
-  logical, parameter, test_kiabs1 = kind(kiabs(-1_8)) == 8
-  logical, parameter, test_kiabs2 = kiabs(-1_8) == 1_8
-  logical, parameter, test_zabs1 = kind(zabs((3._8,4._8))) == 8
-  logical, parameter, test_zabs2 = zabs((3._8,4._8)) == 5_8
-  logical, parameter, test_cdabs1 = kind(cdabs((3._8,4._8))) == kind(1.d0)
-  logical, parameter, test_cdabs2 = cdabs((3._8,4._8)) == real(5, kind(1.d0))
+! Extension specific intrinsic variants
+  logical, parameter :: test_babs1 = kind(babs(-1_1)) == 1
+  logical, parameter :: test_babs2 = babs(-1_1) == 1_1
+  logical, parameter :: test_iiabs1 = kind(iiabs(-1_2)) == 2
+  logical, parameter :: test_iiabs2 = iiabs(-1_2) == 1_2
+  logical, parameter :: test_jiabs1 = kind(jiabs(-1_4)) == 4
+  logical, parameter :: test_jiabs2 = jiabs(-1_4) == 1_4
+  logical, parameter :: test_kiabs1 = kind(kiabs(-1_8)) == 8
+  logical, parameter :: test_kiabs2 = kiabs(-1_8) == 1_8
+  logical, parameter :: test_zabs1 = kind(zabs((3._8,4._8))) == 8
+  logical, parameter :: test_zabs2 = zabs((3._8,4._8)) == 5_8
+  logical, parameter :: test_cdabs1 = kind(cdabs((3._8,4._8))) == kind(1.d0)
+  logical, parameter :: test_cdabs2 = cdabs((3._8,4._8)) == real(5, kind(1.d0))
+  logical, parameter :: test_kidnnt1 = kind(kidnnt(2.5d0)) == 8
+  logical, parameter :: test_kidnnt2 = kidnnt(2.5d0) == 3
+  logical, parameter :: test_knint1 = kind(knint(2.5)) == 8
+  logical, parameter :: test_knint2 = knint(2.5) == 3
 
 end

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

@klausler klausler merged commit 71e01d9 into llvm:main Jan 26, 2024
@klausler klausler deleted the bug1507 branch January 26, 2024 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants