> Am 29.03.2026 um 07:13 schrieb Alexandre Oliva <[email protected]>:
>
>
> g++.dg/alias-checks.C requires vect_double outside vect.exp, where
> -msse2 would have got enabled, but that effective_target passes even
> when SSE2 is indeed disabled and we're testing on ancient 32-bit
> hardware that doesn't even support SSE2. Without SSE2, vectors of
> doubles aren't really available, and so we don't get the expected
> vectorizations and the test fails.
>
> ISTM, from the way vect_double is documented, that testing for
> sse2_runtime would be called for, but that feels excessive: since
> vect.exp enables -msse2 for compile-time vect tests, even when runtime
> support is not present, we should ideally be able to exercise
> compile-time vect_double tests. But we can't test for (let alone
> cache results) with test- or testset compiler flags, or with compiler
> macros they'd define, or even depending on whether we're running a
> compile- or run-time test. (The preexisting tests for __tune_atom__
> make me uncomfortable already.)
>
> So I'm sticking to the documented behavior of vect_double, even if
> that will lose us some compile-time vect_double testing on targets
> that can't run SSE2 code. Most x86 variants in use have SSE2 anyway,
> so it's probably not a significant loss.
>
> I've amended vect_doubleint_cvt and vect_intdouble_cvt while at that,
> though there aren't any failing uses thereof AFAICT.
>
> But then, when we attempt to test alias-checks.C on a target that
> supports SSE2, but doesn't have it enabled, vect_double passes and we
> still don't get the desired vectorization, because we haven't enabled
> it. Instead of adding machine-specific options to alias-checks.C, I'm
> moving it under g++.dg/vect/ and renaming it so that it gets, and
> doesn't override, the default vector options for each platform.
>
> Regstrapped on x86_64-linux-gnu. Also tested with ppc-vx7r2,
> ppc64-vx7r2, arm-vx7r2, aarch64-vx7r2, x86_64-vx7r2, and x86-vx7r2. Ok
> to install?
>
Moving the test is OK. But the vect_double check looks wrong to me, esp as you
are moving a compile test.
>
> for gcc/testsuite/ChangeLog
>
> * lib/target-supports.exp
> (check_effective_target_vect_double): Check for sse2_runtime.
> (check_effective_target_vect_doubleint_cvt): Likewise.
> (check_effective_target_vect_intdouble_cvt): Likewise.
> * g++.dg/alias-checks.C: Rename to...
> * g++.dg/vect/vect-alias-checks.C: ... this. Don't override
> vector options.
> ---
> gcc/testsuite/g++.dg/alias-checks.C | 86 -------------------------
> gcc/testsuite/g++.dg/vect/vect-alias-checks.C | 86 +++++++++++++++++++++++++
> gcc/testsuite/lib/target-supports.exp | 3 +
> 3 files changed, 89 insertions(+), 86 deletions(-)
> delete mode 100644 gcc/testsuite/g++.dg/alias-checks.C
> create mode 100644 gcc/testsuite/g++.dg/vect/vect-alias-checks.C
>
> diff --git a/gcc/testsuite/g++.dg/alias-checks.C
> b/gcc/testsuite/g++.dg/alias-checks.C
> deleted file mode 100644
> index b8ff3ad605c23..0000000000000
> --- a/gcc/testsuite/g++.dg/alias-checks.C
> +++ /dev/null
> @@ -1,86 +0,0 @@
> -
> -// { dg-do compile }
> -// { dg-require-effective-target c++17 }
> -// { dg-require-effective-target vect_double }
> -// { dg-options "-O3 -fdump-tree-vect-all" }
> -// { dg-skip-if "required hosted libstdc++ for cmath and iostream" { !
> hostedlib } }
> -
> -#include <cstdlib>
> -#include <cmath>
> -#include <iostream>
> -void DoIfClause(double *l, double *r, const double *m2, const double *m1,
> - const double *c, const double *p1, const double *p2, int istart, int
> iend)
> -{
> - constexpr double w5alpha[3][3] = {{1.0 / 3.0, -7.0 / 6.0, 11.0 / 6.0},
> - {-1.0 / 6.0, 5.0 / 6.0, 1.0 / 3.0},
> - {1.0 / 3.0, 5.0 / 6.0, -1.0 / 6.0}};
> - constexpr double w5gamma[3] = {0.1, 0.6, 0.3};
> - constexpr double eps = 1e-100;
> - constexpr double thirteen_thirds = 13.0 / 3.0;
> -
> - for (int i = istart; i <= iend; ++i) {
> - const double q0 = m2[i];
> - const double q1 = m1[i];
> - const double q2 = c[i];
> - const double q3 = p1[i];
> - const double q4 = p2[i];
> - double &ql = l[i];
> - double &qr = r[i];
> - double a = q0 - 2 * q1 + q2;
> - double b = q0 - 4.0 * q1 + 3.0 * q2;
> - double beta0 = thirteen_thirds * a * a + b * b + eps;
> - a = q1 - 2.0 * q2 + q3;
> - b = q3 - q1;
> - double beta1 = thirteen_thirds * a * a + b * b + eps;
> - a = q2 - 2.0 * q3 + q4;
> - b = q4 - 4.0 * q3 + 3.0 * q2;
> - double beta2 = thirteen_thirds * a * a + b * b + eps;
> - const double tau5 = std::abs(beta2 - beta0);
> -
> - beta0 = (beta0 + tau5) / beta0;
> - beta1 = (beta1 + tau5) / beta1;
> - beta2 = (beta2 + tau5) / beta2;
> -
> - double w0 = w5gamma[0] * beta0 + eps;
> - double w1 = w5gamma[1] * beta1 + eps;
> - double w2 = w5gamma[2] * beta2 + eps;
> - double wsum = 1.0 / (w0 + w1 + w2);
> - ql = w0 * (w5alpha[0][0] * q0 + w5alpha[0][1] * q1 + w5alpha[0][2] *
> q2);
> - ql += w1 * (w5alpha[1][0] * q1 + w5alpha[1][1] * q2 + w5alpha[1][2]
> * q3);
> - ql += w2 * (w5alpha[2][0] * q2 + w5alpha[2][1] * q3 + w5alpha[2][2]
> * q4);
> - ql *= wsum;
> - const double alpha_l = 3.0 * wsum * w0 * w1 * w2 /
> - (w5gamma[2] * w0 * w1 + w5gamma[1] * w0 * w2 +
> - w5gamma[0] * w1 * w2) +
> - eps;
> -
> - w0 = w5gamma[0] * beta2 + eps;
> - w1 = w5gamma[1] * beta1 + eps;
> - w2 = w5gamma[2] * beta0 + eps;
> - wsum = 1.0 / (w0 + w1 + w2);
> - qr = w0 * (w5alpha[0][0] * q4 + w5alpha[0][1] * q3 + w5alpha[0][2] *
> q2);
> - qr += w1 * (w5alpha[1][0] * q3 + w5alpha[1][1] * q2 + w5alpha[1][2]
> * q1);
> - qr += w2 * (w5alpha[2][0] * q2 + w5alpha[2][1] * q1 + w5alpha[2][2]
> * q0);
> - qr *= wsum;
> - const double alpha_r = 3.0 * wsum * w0 * w1 * w2 /
> - (w5gamma[2] * w0 * w1 + w5gamma[1] * w0 * w2 +
> - w5gamma[0] * w1 * w2) +
> - eps;
> -
> - double dq = q3 - q2;
> - {
> - const double dm = q2 - q1;
> - const double dp = dq;
> - const double dc = (dm * dp > 0.0) * 0.5 * (dm + dp);
> - dq = 0.5 * std::copysign(
> - std::min(std::fabs(dc),
> - 2.0 * std::min(std::fabs(dm), std::fabs(dp))),
> - dc);
> - }
> -
> - const double alpha_lin = 2.0 * alpha_l * alpha_r / (alpha_l +
> alpha_r);
> - ql = alpha_lin * ql + (1.0 - alpha_lin) * (q2 + dq);
> - qr = alpha_lin * qr + (1.0 - alpha_lin) * (q2 - dq);
> - }
> -}
> -/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
> diff --git a/gcc/testsuite/g++.dg/vect/vect-alias-checks.C
> b/gcc/testsuite/g++.dg/vect/vect-alias-checks.C
> new file mode 100644
> index 0000000000000..97c97d2c99e0d
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/vect/vect-alias-checks.C
> @@ -0,0 +1,86 @@
> +
> +// { dg-do compile }
> +// { dg-require-effective-target c++17 }
> +// { dg-require-effective-target vect_double }
> +// { dg-additional-options "-O3 -fdump-tree-vect-all" }
> +// { dg-skip-if "required hosted libstdc++ for cmath and iostream" { !
> hostedlib } }
> +
> +#include <cstdlib>
> +#include <cmath>
> +#include <iostream>
> +void DoIfClause(double *l, double *r, const double *m2, const double *m1,
> + const double *c, const double *p1, const double *p2, int istart, int
> iend)
> +{
> + constexpr double w5alpha[3][3] = {{1.0 / 3.0, -7.0 / 6.0, 11.0 / 6.0},
> + {-1.0 / 6.0, 5.0 / 6.0, 1.0 / 3.0},
> + {1.0 / 3.0, 5.0 / 6.0, -1.0 / 6.0}};
> + constexpr double w5gamma[3] = {0.1, 0.6, 0.3};
> + constexpr double eps = 1e-100;
> + constexpr double thirteen_thirds = 13.0 / 3.0;
> +
> + for (int i = istart; i <= iend; ++i) {
> + const double q0 = m2[i];
> + const double q1 = m1[i];
> + const double q2 = c[i];
> + const double q3 = p1[i];
> + const double q4 = p2[i];
> + double &ql = l[i];
> + double &qr = r[i];
> + double a = q0 - 2 * q1 + q2;
> + double b = q0 - 4.0 * q1 + 3.0 * q2;
> + double beta0 = thirteen_thirds * a * a + b * b + eps;
> + a = q1 - 2.0 * q2 + q3;
> + b = q3 - q1;
> + double beta1 = thirteen_thirds * a * a + b * b + eps;
> + a = q2 - 2.0 * q3 + q4;
> + b = q4 - 4.0 * q3 + 3.0 * q2;
> + double beta2 = thirteen_thirds * a * a + b * b + eps;
> + const double tau5 = std::abs(beta2 - beta0);
> +
> + beta0 = (beta0 + tau5) / beta0;
> + beta1 = (beta1 + tau5) / beta1;
> + beta2 = (beta2 + tau5) / beta2;
> +
> + double w0 = w5gamma[0] * beta0 + eps;
> + double w1 = w5gamma[1] * beta1 + eps;
> + double w2 = w5gamma[2] * beta2 + eps;
> + double wsum = 1.0 / (w0 + w1 + w2);
> + ql = w0 * (w5alpha[0][0] * q0 + w5alpha[0][1] * q1 + w5alpha[0][2] *
> q2);
> + ql += w1 * (w5alpha[1][0] * q1 + w5alpha[1][1] * q2 + w5alpha[1][2]
> * q3);
> + ql += w2 * (w5alpha[2][0] * q2 + w5alpha[2][1] * q3 + w5alpha[2][2]
> * q4);
> + ql *= wsum;
> + const double alpha_l = 3.0 * wsum * w0 * w1 * w2 /
> + (w5gamma[2] * w0 * w1 + w5gamma[1] * w0 * w2 +
> + w5gamma[0] * w1 * w2) +
> + eps;
> +
> + w0 = w5gamma[0] * beta2 + eps;
> + w1 = w5gamma[1] * beta1 + eps;
> + w2 = w5gamma[2] * beta0 + eps;
> + wsum = 1.0 / (w0 + w1 + w2);
> + qr = w0 * (w5alpha[0][0] * q4 + w5alpha[0][1] * q3 + w5alpha[0][2] *
> q2);
> + qr += w1 * (w5alpha[1][0] * q3 + w5alpha[1][1] * q2 + w5alpha[1][2]
> * q1);
> + qr += w2 * (w5alpha[2][0] * q2 + w5alpha[2][1] * q1 + w5alpha[2][2]
> * q0);
> + qr *= wsum;
> + const double alpha_r = 3.0 * wsum * w0 * w1 * w2 /
> + (w5gamma[2] * w0 * w1 + w5gamma[1] * w0 * w2 +
> + w5gamma[0] * w1 * w2) +
> + eps;
> +
> + double dq = q3 - q2;
> + {
> + const double dm = q2 - q1;
> + const double dp = dq;
> + const double dc = (dm * dp > 0.0) * 0.5 * (dm + dp);
> + dq = 0.5 * std::copysign(
> + std::min(std::fabs(dc),
> + 2.0 * std::min(std::fabs(dm), std::fabs(dp))),
> + dc);
> + }
> +
> + const double alpha_lin = 2.0 * alpha_l * alpha_r / (alpha_l +
> alpha_r);
> + ql = alpha_lin * ql + (1.0 - alpha_lin) * (q2 + dq);
> + qr = alpha_lin * qr + (1.0 - alpha_lin) * (q2 - dq);
> + }
> +}
> +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
> diff --git a/gcc/testsuite/lib/target-supports.exp
> b/gcc/testsuite/lib/target-supports.exp
> index 3653f322dc3bc..8a8bc8b50df28 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -4840,6 +4840,7 @@ proc check_effective_target_vect_intfloat_cvt { } {
> proc check_effective_target_vect_doubleint_cvt { } {
> return [check_cached_effective_target vect_doubleint_cvt {
> expr { ([check_effective_target_x86]
> + && [check_effective_target_sse2_runtime]
> && [check_no_compiler_messages vect_doubleint_cvt assembly {
> #ifdef __tune_atom__
> # error No double vectorizer support.
> @@ -4863,6 +4864,7 @@ proc check_effective_target_vect_doubleint_cvt { } {
> proc check_effective_target_vect_intdouble_cvt { } {
> return [check_cached_effective_target vect_intdouble_cvt {
> expr { ([check_effective_target_x86]
> + && [check_effective_target_sse2_runtime]
> && [check_no_compiler_messages vect_intdouble_cvt assembly {
> #ifdef __tune_atom__
> # error No double vectorizer support.
> @@ -8473,6 +8475,7 @@ proc check_effective_target_vect_float_strict { } {
> proc check_effective_target_vect_double { } {
> return [check_cached_effective_target vect_double {
> expr { ([check_effective_target_x86]
> + && [check_effective_target_sse2_runtime]
> && [check_no_compiler_messages vect_double assembly {
> #ifdef __tune_atom__
> # error No double vectorizer support.
>
> --
> Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/
> Free Software Activist FSFLA co-founder GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity.
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive!