From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E25D43858D33; Tue, 5 Dec 2023 05:06:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E25D43858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701752778; bh=ZZ0h6laqc16yfF/CnblEyNZILQEtunFPC4NIhZKLrLM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Atu6xRMnmvWYsFHpm6Nj2wNfmuEy6j7yKdnl393gWXEzEaTOzKnyQQUYnw5E3yeik zR5ZLFYqk9ut34gpS9Y+bNKQqn9WJ5+5JHO6Ko/MOzJH6p/+cJEPnB7PhKa1V/iN80 AyTrIUcpK8j6F2otHTpD1EcO6zXH8pfurLeqxrmM= 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: Tue, 05 Dec 2023 05:06:18 +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: NEW 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 #8 from Chris Elrod --- > If it's designed the way you want it to be=EF=BC=8C another issue would b= e like, should we lower 512-bit vector builtins/intrinsic to ymm/xmm when -= mprefer-vector-width=3D256, the answer is we'd rather not.=20 To be clear, what I meant by > it would be great to respect > `-mprefer-vector-width=3D512`, it should ideally also be able to respect > vector builtins/intrinsics is that when someone uses 512 bit vector builtins, that codegen should gene= rate 512 bit code regardless of `mprefer-vector-width` settings. That is, as a developer, I would want 512 bit builtins to mean we get 512-b= it vector code generation. > If user explicitly use 512-bit vector type, builtins or intrinsics, gcc = will generate zmm no matter -mprefer-vector-width=3D. This is what I would want, and I'd also want it to apply to movement of `struct`s holding vector builtin objects, instead of the `ymm` usage as we = see here. > And yes, there could be some mismatches between 512-bit intrinsic and arc= hitecture tuning when you're using 512-bit intrinsic, and also rely on comp= iler autogen to handle struct > For such case, an explicit -mprefer-vector-width=3D512 is needed. Note the template partial specialization template struct Vector{ static constexpr ptrdiff_t W =3D N >=3D VecWidth ? VecWidth : ptrdiff_t(std::bit_ceil(size_t(N)));=20 static constexpr ptrdiff_t L =3D (N/W) + ((N%W)!=3D0); using V =3D Vec; V data[L]; static constexpr auto size()->ptrdiff_t{return N;} }; Thus, `Vector`s in this example may explicitly be structs containing arrays= of vector builtins. I would expect these structs to not need an `mprefer-vector-width=3D512` setting for producing 512 bit code handling th= is struct. Given small `L`, I would also expect passing this struct as an argument by value to a non-inlined function to be done in `zmm` registers when possible, for example.=