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: [patch] Minor TARGET_MEM_REF cleanup


On Sat, Sep 29, 2012 at 1:17 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> for simple loops like:
>
> extern int a[];
> extern int b[];
>
> void foo (int l)
> {
>   int i;
>
>   for (i = 0; i < l; i++)
>     a[i] = b [i];
> }
>
> you get in the .lim3 dump:
>
> Unanalyzed memory reference 0: _5 = MEM[symbol: b, index: ivtmp.3_1, step: 4,
> offset: 0B];
> Memory reference 1: MEM[symbol: a, index: ivtmp.3_1, step: 4, offset: 0B]
>
> so the pass analyzes the store but not the load, which seems an oversight.
> The patch also folds copy_mem_ref_info into its only user and removes it.
>
> Tested on x86_64-suse-linux, OK for mainline?

Please take the opportunity to clean up simple_mem_ref_in_stmt some more.
Both loads and stores in assigns require gimple_assign_single_p, thus do

 if (!gimple_assign_single_p (stmt))
  return NULL;

before deciding on store/load.  To decide that the stmt is a load then do

  if (TREE_CODE (*lhs) == SSA_NAME
      && gimple_vuse (stmt))

it is a store if

   gimple_vdef (stmt)
   && (TREE_CODE (*rhs) == SSA_NAME
          || is_gimple_min_invariant (*rhs))

else it may still be an aggregate copy but LIM doesn't handle those
(though they may still be interesting for disambiguation ...)

The tree-ssa-address parts are ok as-is.

Thanks,
Richard.


>
> 2012-09-29  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * tree.h (copy_mem_ref_info): Delete.
>         * tree-ssa-address.c (copy_mem_ref_info): Likewise.
>         (maybe_fold_tmr): Copy flags manually.
>         * tree-ssa-loop-im.c (simple_mem_ref_in_stmt): Accept TARGET_MEM_REF
>         on the RHS as well.
>
>
> --
> Eric Botcazou


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