[flang-commits] [flang] [flang] Interpret 'Q' exponent letter as kind=16 even on x86 (PR #124158)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jan 23 09:32:28 PST 2025
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/124158
The compiler was interpreting 'Q' as an exponent letter in a literal real constant as meaning real(kind=10) on x86-64, which is the legacy 80387 80-bit extended precision floating-point type. It turns out that 'Q' means kind=16 with all other compilers, even for x86-64 targets. Change to conform.
>From 8bc57dfee1972288a82c403338a36f311b7bd7c9 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Thu, 23 Jan 2025 09:27:56 -0800
Subject: [PATCH] [flang] Interpret 'Q' exponent letter as kind=16 even on x86
The compiler was interpreting 'Q' as an exponent letter in a literal
real constant as meaning real(kind=10) on x86-64, which is the legacy
80387 80-bit extended precision floating-point type. It turns out
that 'Q' means kind=16 with all other compilers, even for x86-64
targets. Change to conform.
---
flang/lib/Common/default-kinds.cpp | 6 +-----
flang/lib/Frontend/CompilerInstance.cpp | 3 ---
flang/test/Semantics/kinds04_q10.f90 | 13 ++++---------
3 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/flang/lib/Common/default-kinds.cpp b/flang/lib/Common/default-kinds.cpp
index fbafd827ff0d0b..d2ca9103513617 100644
--- a/flang/lib/Common/default-kinds.cpp
+++ b/flang/lib/Common/default-kinds.cpp
@@ -11,11 +11,7 @@
namespace Fortran::common {
-IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() {
-#if __x86_64__
- quadPrecisionKind_ = 10;
-#endif
-}
+IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() {}
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultIntegerKind(
int k) {
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index 298790bae66558..dfd15b9c3c39d9 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -153,9 +153,6 @@ bool CompilerInstance::executeAction(FrontendAction &act) {
CompilerInvocation &invoc = this->getInvocation();
llvm::Triple targetTriple{llvm::Triple(invoc.getTargetOpts().triple)};
- if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
- invoc.getDefaultKinds().set_quadPrecisionKind(10);
- }
// Set some sane defaults for the frontend.
invoc.setDefaultFortranOpts();
diff --git a/flang/test/Semantics/kinds04_q10.f90 b/flang/test/Semantics/kinds04_q10.f90
index d352daa1cbbf06..aa5c4abe2f1dfc 100644
--- a/flang/test/Semantics/kinds04_q10.f90
+++ b/flang/test/Semantics/kinds04_q10.f90
@@ -1,14 +1,9 @@
-! RUN: %python %S/test_errors.py %s %flang_fc1 -triple x86_64-unknown-linux-gnu
+! RUN: %python %S/test_errors.py %s %flang_fc1
! C716 If both kind-param and exponent-letter appear, exponent-letter
! shall be E. (As an extension we also allow an exponent-letter which matches
! the kind-param)
! C717 The value of kind-param shall specify an approximation method that
! exists on the processor.
-!
-! This test is for x86_64, where exponent-letter 'q' is for
-! 10-byte extended precision
-! UNSUPPORTED: system-windows, system-aix
-! REQUIRES: x86-registered-target
subroutine s(var)
real :: realvar1 = 4.0E6_4
@@ -16,9 +11,9 @@ subroutine s(var)
real :: realvar3 = 4.0Q6
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
real :: realvar4 = 4.0D6_8
- !PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
- real :: realvar5 = 4.0Q6_10
!WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'q'
+ real :: realvar5 = 4.0Q6_10
+ !PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
real :: realvar6 = 4.0Q6_16
real :: realvar7 = 4.0E6_8
real :: realvar8 = 4.0E6_10
@@ -31,7 +26,7 @@ subroutine s(var)
double precision :: doublevar3 = 4.0Q6
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
double precision :: doublevar4 = 4.0D6_8
- !WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'q'
+ !PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard
double precision :: doublevar5 = 4.0Q6_16
double precision :: doublevar6 = 4.0E6_8
double precision :: doublevar7 = 4.0E6_10
More information about the flang-commits
mailing list