This is the mail archive of the
mailing list for the GCC project.
Re: Constrain valid arguments to BIT_FIELD_REF
- From: Diego Novillo <dnovillo at google dot com>
- To: Richard Guenther <rguenther at suse dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 04 Mar 2008 11:15:00 -0500
- Subject: Re: Constrain valid arguments to BIT_FIELD_REF
- References: <Pine.LNX.firstname.lastname@example.org>
On 3/4/08 10:55 AM, Richard Guenther wrote:
I suggest to make sure that bit position and size are constants, the
object referenced is of integral type (BIT_FIELD_REF should not be
used as a way to circumvent aliasing) and the result type is of the
same type as the operand zero type (and not a bitfield type of the
referenced size -- in which case the BIT_FIELD_REF_UNSIGNED would
be useless). The result would then be properly extended according
Is this how it was intended?
If it wasn't, I think the semantics you propose are fine. If this is
only generated by the ME, it should be easy to change.
fold currently optimizes a.b.c == 0 to BIT_FIELD_REF <a, 8, big-num> & 1
for bit field field-decls c. IMHO this is bad because it pessimizes
TBAA (needs to use a's alias set, not the underlying integral type
alias set) and it "breaks" type correctness as arbitrary structure
types appear as operand zero.
Agreed. Unless this was done to fix some target-specific problem, I
think it should disappear.