From 3e208966e8fb162f2af7ecc7052e0552fb1c3d92 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Wed, 22 May 2024 16:23:37 -0700 Subject: [PATCH] [flang][runtime] Correct SELECTED_LOGICAL_KIND() The implementation of the runtime version of this intrinsic function in https://github.com/llvm/llvm-project/pull/89691 was incorrect. Fix it to interpret its argument as a bit count. --- flang/runtime/numeric.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp index 52b5a56894d88..2225473c4690e 100644 --- a/flang/runtime/numeric.cpp +++ b/flang/runtime/numeric.cpp @@ -117,13 +117,13 @@ inline RT_API_ATTRS CppTypeFor SelectedIntKind(T x) { template inline RT_API_ATTRS CppTypeFor SelectedLogicalKind( T x) { - if (x <= 2) { + if (x <= 8) { return 1; - } else if (x <= 4) { + } else if (x <= 16) { return 2; - } else if (x <= 9) { + } else if (x <= 32) { return 4; - } else if (x <= 18) { + } else if (x <= 64) { return 8; } return -1;