This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Little infrastructure for IP constant propagation


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]