This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Remove useless null pointer checks
- From: law at redhat dot com
- To: Jason Merrill <jason at redhat dot com>
- Cc: Jeff Sturm <jsturm at one-point dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 05 Aug 2003 11:45:55 -0600
- Subject: Re: [tree-ssa] Remove useless null pointer checks
- Reply-to: law at redhat dot com
In message <wvloez4vwvo.fsf@prospero.boston.redhat.com>, Jason Merrill writes:
>> If the main variant of TYPE and RHS is the same, then enter LHS = RHS into
>> the const_and_copies table.
>>
>> If TYPE and RHS's type are both pointers and one is a void *, then enter
>> LHS = RHS into the const_and_copies table.
>
>You should also handle casts between pointer and reference type; they are
>equivalent outside the front end.
OK. I'll poke and see what I can do with reference types as well.
>> For integral types, we can safely call STRIP_SIGN_NOPS to remove any
>> casts which do not change the underlying mode or sign.
>>
>> There may be other "rules" we could use for typecasts which are safe to
>> ignore in the gimplifier and tree-ssa optimizers.
>>
>> Thoughts?
>
>Could we go all the way and allow any cast which doesn't change mode or
>sign?
Well, I'm doing that for integral types right now. I ran into problems
with doing it on pointer types though since we ended up changing a
(int *) to an (unsigned int *) or something like that -- which in turn
caused indigestion for some of the argument checking code for builtins
(IIRC). For a pointers I think you need to apply the rule on the underlying
type (s).
Jeff