From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6C28C3858C35; Sun, 3 Dec 2023 13:58:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C28C3858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701611882; bh=Flj4NdqkUxCE3/uwuHq9PYllskM+vfe0XeqjoZFFERE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SRq6VSSEKuuykhew4g7aiFgq9S4wsGUT3AOfLsHGh5obYOBSomUvBgDrQFRE0pK8l aVnyrHnO7xlOEWap3Tr94FxNZnFVXoS7So3PUKzgGCkslEhSPQtwEe717neozrJMgw L9pPY/A3LaHBbbhJuARbu0nBYi3BJ9DbNiMQtlZM= From: "elrodc at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112824] Stack spills and vector splitting with vector builtins Date: Sun, 03 Dec 2023 13:58:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: elrodc at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112824 --- Comment #3 from Chris Elrod --- > I thought I hit the important cases, but my non-minimal example still get= s unnecessary register splits and stack spills, so maybe I missed places, o= r perhaps there's another issue. Adding the unroll pragma to the `Vector`'s operator + and *: template [[gnu::always_inline]] constexpr auto operator+(Vector x, Vector = y) -> Vector { Vector z; #pragma GCC unroll 16 for (ptrdiff_t n =3D 0; n < Vector::L; ++n) z.data[n] =3D x.data[n= ] + y.data[n]; return z; } template [[gnu::always_inline]] constexpr auto operator*(Vector x, Vector = y) -> Vector { Vector z; #pragma GCC unroll 16 for (ptrdiff_t n =3D 0; n < Vector::L; ++n) z.data[n] =3D x.data[n= ] * y.data[n]; return z; } template [[gnu::always_inline]] constexpr auto operator+(T x, Vector y) -> Vector { Vector z; #pragma GCC unroll 16 for (ptrdiff_t n =3D 0; n < Vector::L; ++n) z.data[n] =3D x + y.da= ta[n]; return z; } template [[gnu::always_inline]] constexpr auto operator*(T x, Vector y) -> Vector { Vector z; #pragma GCC unroll 16 for (ptrdiff_t n =3D 0; n < Vector::L; ++n) z.data[n] =3D x * y.da= ta[n]; return z; } does not improve code generation (still get the same problem), so that's a reproducer for such an issue.=