Little infrastructure for IP constant propagation
Richard Guenther
richard.guenther@gmail.com
Sat Aug 23 21:11:00 GMT 2008
On Sat, Aug 23, 2008 at 9:52 PM, Jan Hubicka <jh@suse.cz> wrote:
>> On Sat, Aug 23, 2008 at 9:33 PM, Jan Hubicka <jh@suse.cz> wrote:
>> > Hi,
>> > at the moment IPCP is propagating just selected FUNCTION_DECLs constants etc.
>> > This patch adds is_gimple_ip_invariant check that is equivalent to is_gimple_min_invariant
>> > but verify that value is invariant at interprocedural level; in particular that no addresses
>> > of local variables are involved.
>> >
>> > Bootstrapped/regtested with IP-CP using this predicate. OK?
>>
>>
>> > + /* Return whether OP is a DECL whose address is interprocedural-invariant. */
>> > +
>> > + bool
>> > + decl_address_ip_invariant_p (const_tree op)
>> > + {
>> > + /* The conditions below are slightly less strict than the one in
>> > + staticp. */
>> > +
>> > + switch (TREE_CODE (op))
>> > + {
>> > + case LABEL_DECL:
>> > + case FUNCTION_DECL:
>> > + case STRING_CST:
>> > + return true;
>> > +
>> > + case VAR_DECL:
>> > + if (((TREE_STATIC (op) || DECL_EXTERNAL (op))
>> > + && !DECL_DLLIMPORT_P (op))
>> > + || DECL_THREAD_LOCAL_P (op))
>> > + return true;
>> > + break;
>>
>> Any reason you allow DECL_THREAD_LOCAL_P in general here?
>
> I copied it from decl_address_invariant_p...
> Hmm, I am not sure if it is safe in both cases... i.e clone() calls
> change addresses of all DECL_THREAD_LOCAL_P variables, right?
Yes. staticp does
case VAR_DECL:
return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
&& ! DECL_THREAD_LOCAL_P (arg)
&& ! DECL_DLLIMPORT_P (arg)
? arg : NULL);
which rejects even static/external thread locals. IMHO you should do the same.
Richard.
More information about the Gcc-patches
mailing list