https://gcc.gnu.org/g:97db7868edf00dd721d11621eec3a0026cede185

commit 97db7868edf00dd721d11621eec3a0026cede185
Author: Alexandre Oliva <[email protected]>
Date:   Fri Mar 13 00:25:27 2026 -0300

    testsuite: vxworks: nonconstant I
    
    VxWorks expands the complex.h macro I to a function call, and that
    prevents the expected vectorization.
    
    I propose an effective target test for whether macro I can be used as
    an initializer for a global variable, that rules out function calls,
    and add that as a requirement to the complex vectorization tests that
    use I within otherwise-vectorizable code.
    
    The introduced effective target doesn't get sourcebuild.texi
    documentation, like other libc ones.
    
    
    for  gcc/testsuite/ChangeLog
    
            * lib/target-supports.exp
            (check_effective_target_libc_I_init): New.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-add-double.c:
            Require it.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-add-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-add-double.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-add-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-add-half-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mla-double.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mla-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mla-half-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mls-double.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mls-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mls-half-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mul-double.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mul-float.c:
            Likewise.
            * gcc.dg/vect/complex/fast-math-complex-mul-half-float.c:
            Likewise.

Diff:
---
 .../gcc.dg/vect/complex/fast-math-complex-add-double.c         |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-add-float.c          |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-add-half-float.c     |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mla-double.c         |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mla-float.c          |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mla-half-float.c     |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mls-double.c         |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mls-float.c          |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mls-half-float.c     |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mul-double.c         |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mul-float.c          |  1 +
 .../gcc.dg/vect/complex/fast-math-complex-mul-half-float.c     |  1 +
 gcc/testsuite/lib/target-supports.exp                          | 10 ++++++++++
 13 files changed, 22 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-double.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-double.c
index 32ef5faeaa86..d3e53702a5dc 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-double.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-double.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_double } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE double
diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-float.c
index e9fd02ea88e8..125ea1b64672 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_float } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE float
diff --git 
a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-half-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-half-float.c
index 9f1888425443..248b9dc3e676 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-half-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-add-half-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math --param vect-epilogues-nomask=0" } */
 /* { dg-require-effective-target vect_complex_add_half } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-require-effective-target arm_v8_3a_fp16_complex_neon_ok } */
 /* { dg-add-options arm_v8_3a_fp16_complex_neon } */
 
diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-double.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-double.c
index c4796ae60f4a..44de521fd743 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-double.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-double.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_double } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE double
diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-float.c
index ba2c99dc5ee4..afea8181dbd1 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_float } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE float
diff --git 
a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-half-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-half-float.c
index 9c1424e52d42..fab47cb9ed25 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-half-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mla-half-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_half } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-require-effective-target arm_v8_3a_fp16_complex_neon_ok } */
 /* { dg-add-options arm_v8_3a_fp16_complex_neon } */
 
diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-double.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-double.c
index a69c788bacfa..6e5d159351a9 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-double.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-double.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_double } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE double
diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-float.c
index 6fa3da79d326..e4c14378aac4 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_float } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE float
diff --git 
a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-half-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-half-float.c
index c21f8402b589..4148c14cc3a6 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-half-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mls-half-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_half } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-require-effective-target arm_v8_3a_fp16_complex_neon_ok } */
 /* { dg-add-options arm_v8_3a_fp16_complex_neon } */
 
diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-double.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-double.c
index e91239838b6c..8dd6cf4024c2 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-double.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-double.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_double } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE double
diff --git a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-float.c
index 0d1fee681cb5..a967a69b82c9 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_float } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-add-options arm_v8_3a_complex_neon } */
 
 #define TYPE float
diff --git 
a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-half-float.c 
b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-half-float.c
index 8793eff0aff9..5c2747bbee88 100644
--- a/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-half-float.c
+++ b/gcc/testsuite/gcc.dg/vect/complex/fast-math-complex-mul-half-float.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-additional-options "-ffast-math" } */
 /* { dg-require-effective-target vect_complex_add_half } */
+/* { dg-require-effective-target libc_I_init } */
 /* { dg-require-effective-target arm_v8_3a_fp16_complex_neon_ok } */
 /* { dg-add-options arm_v8_3a_fp16_complex_neon } */
 
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 2bb4a9a08218..bfb8ecadf880 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -10636,6 +10636,16 @@ proc check_effective_target_libc_has_complex_functions 
{} {
     }]
 }
 
+# Return true if target's libc defines complex I as a constant that
+# can be used in an initializer.
+
+proc check_effective_target_libc_I_init {} {
+    return [check_no_compiler_messages libc_I_init object {
+       #include <complex.h>
+       const _Complex float i = I;
+    }]
+}
+
 # Return 1 if
 #   (a) an error of a few ULP is expected in string to floating-point
 #       conversion functions; and

Reply via email to