[flang-commits] [flang] [draft][flang] Query backend support for quad-precision compilation decision (PR #182230)

Shunsuke Watanabe via flang-commits flang-commits at lists.llvm.org
Tue Mar 3 00:55:57 PST 2026


s-watanabe314 wrote:

I am considering how to address the regression tests. Currently, the 6 failing tests use the following condition for the check prefix:
```
FileCheck %s --check-prefixes=CHECK,%if flang-supports-f128-math %{F128%} %else %{F64%}`
```

This `flang-supports-f128-math` feature is set in the lit configuration files:

- flang/test/lit.cfg.py
```
if config.flang_runtime_f128_math_lib or config.have_ldbl_mant_dig_113:
    config.available_features.add("flang-supports-f128-math")
```

- flang/test/lit.site.cfg.py.in
```
config.flang_runtime_f128_math_lib = "@FLANG_RUNTIME_F128_MATH_LIB@"
config.have_ldbl_mant_dig_113 = "@HAVE_LDBL_MANT_DIG_113@"
```

This implies that the tests are checking whether fp128 or fp64 should be used based on information embedded at build time. This approach differs from the one taken in this patch.

To resolve this, would an implementation that dynamically determines the `flang-supports-f128-math` feature during testing be acceptable? For example, by calling the flang command at lit runtime to compile real(16) and setting flang-supports-f128-math based on the result, as shown below:

- Modified flang/test/lit.cfg.py
```diff
+def flang_supports_f128():
+    flang_exe = lit.util.which("flang", config.clang_tools_dir)
+
+    if not flang_exe:
+        return False
+
+    try:
+        testcode = b"real(16) :: x\nend"
+        flang_cmd = subprocess.run(
+            [flang_exe, "-fsyntax-only", "-"],
+            input=testcode,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+        )
+    except OSError:
+        return False
+
+    if flang_cmd.returncode == 0:
+        return True
+
 # Add features and substitutions to test F128 math support.
 # %f128-lib substitution may be used to generate check prefixes
 # for LIT tests checking for F128 library support.
-if config.flang_runtime_f128_math_lib or config.have_ldbl_mant_dig_113:
+if config.flang_runtime_f128_math_lib or config.have_ldbl_mant_dig_113 or flang_suppports_f128():
     config.available_features.add("flang-supports-f128-math")
```


However, even with this method, two other tests fail:
```
Failed Tests (2):
  Flang :: Lower/Intrinsics/ieee_class_queries.f90
  Flang :: Lower/Intrinsics/ieee_unordered.f90
```
These failures are due to the built `ieee_arithmetic.mod` not containing `kind=16` values. The build process needs to be modified to check if the built flang supports quad-precision and then build the module file accordingly. I haven't yet found a way to achieve this.

https://github.com/llvm/llvm-project/pull/182230


More information about the flang-commits mailing list