Skip to content
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

[flang][test] Restrict Semantics/kinds04_q10.f90 to x86_64 #103724

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rorth
Copy link
Collaborator

@rorth rorth commented Aug 14, 2024

Flang :: Semantics/kinds04_q10.f90 FAILs on SPARC, both Solaris/sparcv9 and Linux/sparc64:

actual at 16: invalid argument on REAL(10) to REAL(4) conversion
actual at 20: invalid argument on REAL(10) to REAL(4) conversion
actual at 24: invalid argument on REAL(10) to REAL(4) conversion
actual at 31: invalid argument on REAL(10) to REAL(8) conversion
actual at 37: invalid argument on REAL(10) to REAL(8) conversion

This seems to be the same issue recently seen in PR #102890: even though the target in question supports REAL(10), the host does not.

Therefore this patch restricts the test to x86_64.

Tested on sparcv9-sun-solaris2.11, sparc64-unknown-linux-gnu, amd64-pc-solaris2.11, and x86_64-pc-linux-gnu.

`Flang :: Semantics/kinds04_q10.f90` `FAIL`s on SPARC, both Solaris/sparcv9
and Linux/sparc64:
```
actual at 16: invalid argument on REAL(10) to REAL(4) conversion
actual at 20: invalid argument on REAL(10) to REAL(4) conversion
actual at 24: invalid argument on REAL(10) to REAL(4) conversion
actual at 31: invalid argument on REAL(10) to REAL(8) conversion
actual at 37: invalid argument on REAL(10) to REAL(8) conversion
```
This seems to be the same issue recently seen in PR llvm#102890: even though
the target in question supports `REAL(10)`, the host does not.

Therefore this patch restricts the test to `x86_64`.

Tested on `sparcv9-sun-solaris2.11`, `sparc64-unknown-linux-gnu`,
`amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.
@rorth rorth requested review from jeanPerier and luporl August 14, 2024 09:12
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Aug 14, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 14, 2024

@llvm/pr-subscribers-flang-semantics

Author: Rainer Orth (rorth)

Changes

Flang :: Semantics/kinds04_q10.f90 FAILs on SPARC, both Solaris/sparcv9 and Linux/sparc64:

actual at 16: invalid argument on REAL(10) to REAL(4) conversion
actual at 20: invalid argument on REAL(10) to REAL(4) conversion
actual at 24: invalid argument on REAL(10) to REAL(4) conversion
actual at 31: invalid argument on REAL(10) to REAL(8) conversion
actual at 37: invalid argument on REAL(10) to REAL(8) conversion

This seems to be the same issue recently seen in PR #102890: even though the target in question supports REAL(10), the host does not.

Therefore this patch restricts the test to x86_64.

Tested on sparcv9-sun-solaris2.11, sparc64-unknown-linux-gnu, amd64-pc-solaris2.11, and x86_64-pc-linux-gnu.


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

1 Files Affected:

  • (modified) flang/test/Semantics/kinds04_q10.f90 (+1-1)
diff --git a/flang/test/Semantics/kinds04_q10.f90 b/flang/test/Semantics/kinds04_q10.f90
index d352daa1cbbf06..25121657da1202 100644
--- a/flang/test/Semantics/kinds04_q10.f90
+++ b/flang/test/Semantics/kinds04_q10.f90
@@ -8,7 +8,7 @@
 ! 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
+! REQUIRES: target=x86_64{{.*}}
 
 subroutine s(var)
   real :: realvar1 = 4.0E6_4

Copy link
Contributor

@luporl luporl left a comment

Choose a reason for hiding this comment

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

I wonder why this test seems to be failing only on SPARC, since there weren't complaints of it failing on other hosts. AArch64 hosts also don't support REAL(10), but, at least on the machine that I used, the test on #102890 worked correctly when targeting x86_64. In that test case, however, AArch64 and other targets were already being skipped.

I'm OK with restricting this test to x86_64 only, as long as an issue is opened to track this problem, of programs using REAL(10) failing to compile on some hosts, even when they are targeting x86_64. But it would be good to wait for other reviewers' comments on this.

@luporl
Copy link
Contributor

luporl commented Aug 14, 2024

#103928 may be related.
This would explain why no failures were observed on little endian targets.

@rorth
Copy link
Collaborator Author

rorth commented Aug 15, 2024

#103928 may be related. This would explain why no failures were observed on little endian targets.

I've just applied this patch and rebuilt/retested (with this patch to the testcase reverted). That one still FAILs, but directly comparing the flang-new -fc1 output, there are differences for the REAL(10) tests:

--- /homes/ro/k04.out.sparcv9.prev2	2024-08-15 11:10:27.946232000 +0200
+++ /homes/ro/k04.out.sparcv9	2024-08-15 11:07:41.005641000 +0200
@@ -1,5 +1,5 @@
 error: Semantic errors in flang/test/Semantics/kinds04_q10.f90
-flang/test/Semantics/kinds04_q10.f90:16:22: warning: invalid argument on REAL(10) to REAL(4) conversion
+flang/test/Semantics/kinds04_q10.f90:16:22: warning: underflow on REAL(10) to REAL(4) conversion
     real :: realvar3 = 4.0Q6
                        ^^^^^
 flang/test/Semantics/kinds04_q10.f90:18:22: portability: Explicit kind parameter together with non-'E' exponent letter is not standard
@@ -8,19 +8,19 @@
 flang/test/Semantics/kinds04_q10.f90:20:22: portability: Explicit kind parameter together with non-'E' exponent letter is not standard
     real :: realvar5 = 4.0Q6_10
                        ^^^^^
-flang/test/Semantics/kinds04_q10.f90:20:22: warning: invalid argument on REAL(10) to REAL(4) conversion
+flang/test/Semantics/kinds04_q10.f90:20:22: warning: underflow on REAL(10) to REAL(4) conversion
     real :: realvar5 = 4.0Q6_10
                        ^^^^^^^^
 flang/test/Semantics/kinds04_q10.f90:22:22: warning: Explicit kind parameter on real constant disagrees with exponent letter 'q'
     real :: realvar6 = 4.0Q6_16
                        ^^^^^
-flang/test/Semantics/kinds04_q10.f90:24:22: warning: invalid argument on REAL(10) to REAL(4) conversion
+flang/test/Semantics/kinds04_q10.f90:24:22: warning: underflow on REAL(10) to REAL(4) conversion
     real :: realvar8 = 4.0E6_10
                        ^^^^^^^^
 flang/test/Semantics/kinds04_q10.f90:27:23: error: Unsupported REAL(KIND=32)
     real :: realvar10 = 4.0E6_32
                         ^^^^^
-flang/test/Semantics/kinds04_q10.f90:31:36: warning: invalid argument on REAL(10) to REAL(8) conversion
+flang/test/Semantics/kinds04_q10.f90:31:36: warning: underflow on REAL(10) to REAL(8) conversion
     double precision :: doublevar3 = 4.0Q6
                                      ^^^^^
 flang/test/Semantics/kinds04_q10.f90:33:36: portability: Explicit kind parameter together with non-'E' exponent letter is not standard
@@ -29,7 +29,7 @@
 flang/test/Semantics/kinds04_q10.f90:35:36: warning: Explicit kind parameter on real constant disagrees with exponent letter 'q'
     double precision :: doublevar5 = 4.0Q6_16
                                      ^^^^^
-flang/test/Semantics/kinds04_q10.f90:37:36: warning: invalid argument on REAL(10) to REAL(8) conversion
+flang/test/Semantics/kinds04_q10.f90:37:36: warning: underflow on REAL(10) to REAL(8) conversion
     double precision :: doublevar7 = 4.0E6_10
                                      ^^^^^^^^
 flang/test/Semantics/kinds04_q10.f90:40:36: error: Unsupported REAL(KIND=32)

I've also tried a minimal testcase of a function returning REAL(10) and that produced the same assembler output on both Solaris/sparcv9 and Solaris/amd64 (each targetting x86_64-unknown-linux-gnu.

@DanielCChen
Copy link
Contributor

DanielCChen commented Aug 16, 2024

It seems to me that the code would "work" on little-endian system regardless if it supports REAL(10) is that the 10-byte literal was truncated to 10-byte FP format and then is assigned(convert?) to REAL(16) in FE. It is f128 at LLVM IR.
The code in FE that does these works for little-endian but didn't work properly for bid-endian system like AIX.

The IR for 1.00000000000000000001Q0_10 on little-endian (Linux on Power)

0xL00000000000000003FFF000000000000

The same literal on big-endian (AIX)

0xL00000000000000000000000000007FFF

The reason for invalid argument on REAL(10) to REAL(4) conversion only on big-endian system is that the 10-byte literal didn't pass the IsNotANumber() check in real.h.

@rorth
Copy link
Collaborator Author

rorth commented Aug 21, 2024

I wonder why this test seems to be failing only on SPARC, since there weren't complaints of it failing on other hosts. AArch64 hosts also don't support REAL(10), but, at least on the machine that I used, the test on #102890 worked correctly when targeting x86_64. In that test case, however, AArch64 and other targets were already being skipped.

I'm OK with restricting this test to x86_64 only, as long as an issue is opened to track this problem, of programs using REAL(10) failing to compile on some hosts, even when they are targeting x86_64. But it would be good to wait for other reviewers' comments on this.

Given @DanielCChen's findings and similar ones by myself when compiling a minimal version of kinds04_q10.f90 which contains only the REAL(10) cases, where there are differences like

-@_QFsEdoublevar3 = internal global double 4.000000e+06
+@_QFsEdoublevar3 = internal global double 0x7FFC000000000000

between the x86_64 and sparcv9 outputs, I wonder how we should proceed with this patch? Restrict it to x86_64 for now as suggested?

Maybe @DanielCChen is in a better position to file an Issue than I am, given that he's well familiar with the code?

@DanielCChen
Copy link
Contributor

DanielCChen commented Aug 27, 2024

The two test files, kinds04_q10.f90 and kinds04_q16.f90 are identical in terms of Fortran code.
The difference is (obviously) _q10.f90 runs only on x86 target and _q16_f90 only runs on non-x86 target.
The reason of splitting the same code into two different test files seems due to Flang FE issues different messages for the same code depending on the platform it is targeting.
The following examples are from the test file.

Example 1,

real :: realvar5 = 4.0Q6_10

x86:
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard

non-x86:
!WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'q'

Example 2:

real :: realvar6 = 4.0Q6_16

x86:
!WARNING: Explicit kind parameter on real constant disagrees with exponent letter 'q'

non-x86:
!PORTABILITY: Explicit kind parameter together with non-'E' exponent letter is not standard

I am not sure if I agree with the x86 message for the 2nd example as exponent letter q seems consistent with kind parameter 16.

On top of what is shown at the above, on AIX (big-endian), there is also an extra message for the code in the 1st example as

underflow on REAL(10) to REAL(4) conversion

It is due to the reason I mentioned in the previous post that on AIX, the constant is 0x7FFF (+infinity) rather than a valid number so it cannot be converted to REAL*16.

I fixed kinds04_q16.f90 that runs on non-x86 target for AIX via PR #104792.
As for the test case in this PR, kinds04_q10.f90, because it already excludes system-aix in the header, it is not an issue for AIX.

I think these two test files could be merged into one as the source code are identical, and use the --check-prefix to specify different checks for different platforms.

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.

4 participants