From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 14A6838582BC; Sat, 25 Feb 2023 22:06:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14A6838582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677362769; bh=FEBNhKGZ7aNulU6mSEnJ4GFwhsKgtSegy0sthScfxYk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hGsPF5aJOgx0O4TGenmc/HfF649yHvF3vMx3t0vd5CVAbELOECMORNHsK/1hZVBcf jOWK2VOA4cjPHWa9tuZ2QbCDZRD4IGsigfg+gDNSWU/X3cS+QKr7dH2WcuAOA9u8+D 5O/SL2iJDNAxs5/jQLYnAO62jcjVX9F5dV+YuDHM= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/55658] bitfields and __attribute__((packed)) generate horrible code on x86_64 Date: Sat, 25 Feb 2023 22:06:08 +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: 4.7.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia 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=3D55658 --- Comment #7 from Andrew Pinski --- diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc index 45bf2d18639..b44335dd406 100644 --- a/gcc/stor-layout.cc +++ b/gcc/stor-layout.cc @@ -3089,7 +3089,8 @@ get_best_mode (int bitsize, int bitpos, causes store_bit_field to keep a 128-bit memory reference, so that the final bitfield reference still has a MEM_EXPR and MEM_OFFSET. */ - && GET_MODE_ALIGNMENT (mode) <=3D align + && (GET_MODE_ALIGNMENT (mode) <=3D align + || (!STRICT_ALIGNMENT && currently_expanding_to_rtl)) && GET_MODE_BITSIZE (mode) <=3D largest_mode_bitsize) { *best_mode =3D mode; Should fix it, I still need to update the comment since it does say the che= ck should be disable while expanding and that is what the above does ... To get rid of the check the rest of the way is remove part of fold which do= es the comparison combing which I think might be too early to that ...=