From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8EE073858C5E; Thu, 12 Oct 2023 08:45:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EE073858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697100352; bh=i0d7i15alKqvKiBkZXG7k4tRKIB7mvb143bvjNWyKPU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mkWQsLiKXNnQnokHtv05r+ukZBlTPaT+wNks53YZA0Gt+R+sdFaONr46OvylNuQla ECgkZU9lZxhwSB9uaHg315S0mETqJIskXy6PSXWWhaZ87WDLBqmcP1TS4wJY63XOWK 7baEN+VSkWQZoce5P0gatGWrXdEp5+7wD+Zj2BKI= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111779] Fail to vectorize the struct include struct Date: Thu, 12 Oct 2023 08:45:51 +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: component bug_status everconfirmed cc cf_reconfirmed_on 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=3D111779 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c |tree-optimization Status|UNCONFIRMED |NEW Ever confirmed|0 |1 CC| |jamborm at gcc dot gnu.org Last reconfirmed| |2023-10-12 --- Comment #1 from Richard Biener --- The issue is the aggregate copy: t.c:26:22: missed: not vectorized: more than one data ref in stmt: a =3D *= _3; which SRA fails to scalarize: [local count: 955630224]: # s_23 =3D PHI # i_25 =3D PHI _1 =3D (long unsigned int) i_25; _2 =3D _1 * 24; _3 =3D x_16(D) + _2; a =3D *_3; _4 =3D BIT_FIELD_REF ; _12 =3D _4 & 1; _6 =3D (int) _12; s_18 =3D _6 + s_23; a =3D{v} {CLOBBER(eol)}; i_20 =3D i_25 + 1; if (y_14(D) > i_20) Candidate (2778): a ... ! Disqualifying a - No scalar replacements to be created. the BIT_FIELD_REF is already created by early folding in optimize_bit_field_compare folding (int) a.b4.f !=3D 0 s =3D ((int) NON_LVALUE_EXPR > & 1) + s; SRA could handle BIT_FIELD_REFs just fine - esp. quantities with a byte size. And then this folding is just premature... Removing the folding that handles BF !=3D CST fixes it. I know removing all of it, esp. BF !=3D BF will regress some stuff. I'll put this half-way patch through testing. diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 82299bb7f1d..3db383360d6 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -4695,7 +4695,7 @@ optimize_bit_field_compare (location_t loc, enum tree_code code, return 0; if (const_p) - rreversep =3D lreversep; + return 0; else { /* If this is not a constant, we can only do something if bit positio= ns,=