[PATCH] Fix PR optimization/11210

Eric Botcazou ebotcazou@libertysurf.fr
Sat Jun 28 13:20:00 GMT 2003


> > decode_field_reference() throws away surrounding NOPs in the expression
> > it is passed. Now it sets 'punsignedp' to the signedness of the field,
> > so I think it must strip only NOPs that don't affect the sign.
>
> OK.

While the idea is correct, the implementation is far from being blameless :-(

I got caught by expr.c:get_inner_reference(), which is advertised as handling 
NOP_EXPR and the likes, but doesn't return the value you would have expected 
for NOP_EXPRs wrapping up bitfields. Not sure if this is a bug or a feature, 
but this is certainly not what we want in decode_field_reference(). It's 
amazing that neither IA-32 nor PPC caught the problem.

So I ended up patching decode_field_reference() itself and came up with the 
following (admittedly a bit ad hoc) patch.

Bootstrapped/regtested on i586-redhat-linux-gnu (except Ada), bootstrapped on 
sparc64-sun-solaris2.9 (except Ada).

-- 
Eric Botcazou


2003-06-28  Eric Botcazou  <ebotcazou@libertysurf.fr>

        PR optimization/11210
	* expr.c (handled_component_p) [NOP_EXPR]: Add ??? note
	about the behaviour with regard to bitfields.
        * fold-const (decode_field_reference): Record outermost type in
	case the expression is a NOP. Strip all NOPs. Set the signedness
	to that of the outermost type (if any) when the bitsize is equal to the
	size of the type.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr11210-2.diff
Type: text/x-diff
Size: 2310 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20030628/12ce393c/attachment.bin>


More information about the Gcc-patches mailing list