This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/52134] New: Does not fold (x * 4) & -4
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 06 Feb 2012 10:50:20 +0000
- Subject: [Bug middle-end/52134] New: Does not fold (x * 4) & -4
- Auto-submitted: auto-generated
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 <R1b, 0> + 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 <R1b, 0> + 2) * 4) & -4) - (ssizetype)
((sizetype) MAX_EXPR <R1b, 0> * 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).