From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13251 invoked by alias); 6 Feb 2012 10:51:10 -0000 Received: (qmail 13214 invoked by uid 22791); 6 Feb 2012 10:51:09 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 06 Feb 2012 10:50:57 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/52134] New: Does not fold (x * 4) & -4 Date: Mon, 06 Feb 2012 10:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-02/txt/msg00582.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52134 Bug #: 52134 Summary: Does not fold (x * 4) & -4 Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: middle-end AssignedTo: unassigned@gcc.gnu.org ReportedBy: rguenth@gcc.gnu.org CC: ebotcazou@gcc.gnu.org We appearantly do not fold ((sizetype) MAX_EXPR + 2) * 4 BIT_AND_EXPR -4 as it happens for TYPE_SIZE_UNIT of a struct for gnat.dg/opt9.adb. This causes an issue with trying to compute the extent/padding of a trailing bitfield in such a struct when you do size_diffop (TYPE_SIZE_UNIT (DECL_CONTEXT (field)), DECL_FIELD_OFFSET (repr)); where repr is the first field of a bitfield group and field is the last field of a bitfield group. The above expression computes non-constant ((ssizetype) (((sizetype) MAX_EXPR + 2) * 4) & -4) - (ssizetype) ((sizetype) MAX_EXPR * 4) Not sure if such an expression cannot be reliably required to be constant in ada though. Certainly this looks like a missed folding (not sure how often this odd BIT_AND_EXPR for sizes happen in Ada).