[cond-optab, trunk] fold &f != 0 better
Andrew Thomas Pinski
pinskia@gmail.com
Thu Apr 9 15:07:00 GMT 2009
Sent from my iPhone
On Apr 9, 2009, at 4:36 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
>
>>> Index: gcc/fold-const.c
>>> ===================================================================
>>> --- gcc/fold-const.c (branch cond-optab)
>>> +++ gcc/fold-const.c (working copy)
>>> @@ -15011,8 +15011,8 @@ tree_single_nonzero_warnv_p (tree t, boo
>>> return false;
>>>
>>> /* Weak declarations may link to NULL. */
>>> - if (VAR_OR_FUNCTION_DECL_P (base))
>>> - return !DECL_WEAK (base);
>>> + if (DECL_P (base))
>>> + return !VAR_OR_FUNCTION_DECL_P (base) || !DECL_WEAK
>>> (base);
>>
>> Hmm, I think this misses && flag_delete_null_pointer_checks,
>> otherwise
>> a VAR_DECL may be at address zero. I'm not sure if that would apply
>> for PARM_DECLs, LABEL_DECLs, etc.
>>
>> Thus, the patch is ok if you add && flag_delete_null_pointer_checks
>> to
>> the VAR_OR_FUNCTION_DECL_P case.
>
> Good catch. I'll make the condition "if (DECL_P (base) &&
> !flag_delete_null_pointer_checks" just to be safe. If a function
> can be
> at address zero (a interrupt handler can be there on the Z80, I don't
> have any more modern example...), a label can be there too.
The interrupt handler for spu is located at address 0.
>
>
> Paolo
More information about the Gcc-patches
mailing list