From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A4E973858436; Wed, 19 Jul 2023 13:26:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4E973858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689773200; bh=R326WBCfbeShEBwNml5ed3UwCKB5eVfvtI9IJBeUdUg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LIqBdfiC/FuPxGon1d7Lm7eJq/p3QIinbxheiWh5vVTHrEDVG8ek0BjpKuM+LXxMW i4W+0fiSkGvCskg6oMM7vHfLWMpGjSWtaTKxK0DqQOUrlHojQcg7Kz1RIcaA3Xy+Ov dvGn71lNbxx/o3md3zKSABVaAitdec5zkuORjM6A= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109543] Avoid using BLKmode for unions with a non-BLKmode member when possible Date: Wed, 19 Jul 2023 13:26:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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=3D109543 --- Comment #4 from Richard Biener --- I think for SRA the issue is that there's no access to any of the unions components and as Martin says it disqualifies total scalarization. I think total scalarization would be possible if we can use the one and only component type that's actually used (and that component is a register type) or if there's no component explicitely used and we have a register that's suitable to represent the whole bit representation of the union. At materialization time the only thing we have to make sure is that we not replace a[0] =3D X; with a[0].component =3D X-component_register; but retain the union typed copy like a[0] =3D V_C_E (X-component_register); (not sure if that's valid GIMPLE ...). The important thing is to preserve the TBAA behavior of both the original aggregate loads and the store which means we have to keep the union type visible in the access path, not only preserving the alias-set (at least I think so). That said, a vector-float isn't a good bit representation. There's eventually type_for_mode () using the union mode if it's not BLKmode. That might not be the worst choice.=