[PATCH 3/5] The IPA-SRA itself.

Richard Guenther rguenther@suse.de
Fri Aug 7 09:50:00 GMT 2009


On Wed, 5 Aug 2009, Martin Jambor wrote:

> Hi,
> 
> this patch  contains the implementation  of IPA-SRA which is  built on
> top of the new intraprocedural SRA.
> 
> This is a re-submission in  which I incorporated most of the feedback.
> Disqualification of  addressable types and  direct uses are  done when
> selecting candidates  in the initial  phase.  The check whether  it is
> legal  to move  dereferences to  the caller  has been  re-written from
> scratch.  It now does not utilize dominators but rather propagates the
> dereference  information across the  control flow  graph in  a fashion
> similar  to the simplest  constant-propagation algorithms.   In short,
> for each  BB and pointer  candidate I note down  in local_dereferences
> whether (and  how much of it)  it was dereferenced  there.  Then, when
> actually  checking   the  dereference   info,  I  propagate   this  in
> global_dereferences to other basic blocks if all of their predecessors
> also   are   marked   as   having  dereferenced   the   parameter   in
> global_dereferences.  I propagate this information until it stabilizes
> and  then check  it for  BBs which  can abort  the progressing  of the
> functions  (returns, calls of  non-pure functions,  potential infinite
> loops, external exceptions).

I'm still confused about all this complexity and why you need to consider
offsets at all.

For simplicity I would simply check dereferencing in 
ptr_parm_has_direct_uses where you already walk all direct uses:

> +ptr_parm_has_direct_uses (tree parm)
> +{
> +  imm_use_iterator ui;
> +  gimple stmt;
> +  tree name = gimple_default_def (cfun, parm);
> +  bool ret = false;
> +
> +  FOR_EACH_IMM_USE_STMT (stmt, ui, name)
> +    {
> +      if (gimple_assign_single_p (stmt))
> +	{
> +	  tree rhs = gimple_assign_rhs1 (stmt);
> +	  if (rhs == name)
> +	    ret = true;
> +	  else if (TREE_CODE (rhs) == ADDR_EXPR)
> +	    {
> +	      do
> +		{
> +		  rhs = TREE_OPERAND (rhs, 0);
> +		}
> +	      while (handled_component_p (rhs));
> +	      if (INDIRECT_REF_P (rhs) && TREE_OPERAND (rhs, 0) == name)
> +		ret = true;
> +	    }

        lhs = gimple_assign_lhs (stmt);
        if (TREE_CODE (lhs) != SSA_NAME)
          {
            while (handled_component_p (lhs))
             lhs = TREE_OPERAND (lhs, 0);
            if (INDIRECT_REF_P (lhs) && TREE_OPERAND (lhs, 0) == name
                && (gimple_bb (stmt) == single_succ 
(ENTRY_BLOCK_PTR)
                    || dominated_by_p (CDI_POST_DOMINATORS,
				   single_succ (ENTRY_BLOCK_PTR),
                                   gimple_bb (stmt))))
              {
                note parm can be dereferenced in the caller
              }
          }

        same for the rhs (and maybe call lhs and call args, but that
        probably doesn't make too much of a difference).

Why doesn't that work for you?

Richard.



More information about the Gcc-patches mailing list