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] Improve lim for pulling loads from global variable out of loops





Thanks to this patch, vect-78.c now gets vectorized on targets that support
misalignment ('off.1_12 = off' was taken out of the loop). So we currently
get an XPASS on ppc-darwin. I'll go ahead and commit the following obvious
patch.

dorit

Changelog:

      * gcc.dg/vect/vect-78.c: Now vectorized on powerpc*.


Index: vect-78.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/vect/vect-78.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 vect-78.c
*** vect-78.c   13 Nov 2004 13:42:45 -0000      1.4
--- vect-78.c   14 Nov 2004 20:47:45 -0000
*************** int main (void)
*** 46,50 ****
  }


! /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" {
xfail *-*-* } } } */

--- 46,50 ----
  }


! /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" {
xfail i?86-*-* x86_64-*-* sparc*-*-* } } } */




|---------+---------------------------------->
|         |           Zdenek Dvorak          |
|         |           <rakdver@atrey.karlin.m|
|         |           ff.cuni.cz>            |
|         |           Sent by:               |
|         |           gcc-patches-owner@gcc.g|
|         |           nu.org                 |
|         |                                  |
|         |                                  |
|         |           13/11/2004 11:43       |
|---------+---------------------------------->
  >------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                        |
  |       To:       Diego Novillo <dnovillo@redhat.com>                                                                    |
  |       cc:       Andrew Pinski <pinskia@physics.uc.edu>, "gcc-patches@gcc.gnu.org Patches" <gcc-patches@gcc.gnu.org>    |
  |       Subject:  Re: [PATCH] Improve lim for pulling loads from global variable out of loops                            |
  >------------------------------------------------------------------------------------------------------------------------|




Hello,

> > > > if (!is_gimple_reg (rhs))
> > > >    cost += 20;
> > >
> > > This would cause us to count any operation except for simple reg =
reg
> > > copy as expensive, which definitely is not what is wanted.
> > >
> > Huh?  Absolutely not.  Read the predicate again.  If the RHS is a
> > register, we don't increase the cost.
> >
> Never mind.  I mis-read your paragraph, sorry.
>
> Yes, this would make reg = CST, expensive.  So, if you only want to make
> memory stores and loads expensive, you can ask it directly with:
>
>   if (NUM_VUSES (VUSE_OPS (ann)) > 0
>       || NUM_V_MAY_DEFS (V_MAY_DEF_OPS (ann)) > 0
>       || NUM_V_MUST_DEFS (V_MUST_DEF_OPS (ann)) > 0))
>     cost += 20;
>
> (this whole expression should probably be implemented into a predicate).

here is the patch, bootstrapped & regtested on ppc and i686.

Zdenek

             PR tree-optimization/18431
             * tree-flow.h (stmt_reads_memory_p): Declare.
             * tree-ssa-loop-im.c (stmt_cost): Use stmt_reads_memory_p.
             * tree-ssa.c (stmt_reads_memory_p): New function.

Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.61
diff -c -3 -p -r2.61 tree-flow.h
*** tree-flow.h          9 Nov 2004 14:59:49 -0000           2.61
--- tree-flow.h          12 Nov 2004 19:43:57 -0000
*************** extern void delete_tree_ssa (void);
*** 583,588 ****
--- 583,589 ----
  extern void register_new_def (tree, varray_type *);
  extern void walk_use_def_chains (tree, walk_use_def_chains_fn, void *,
bool);
  extern void kill_redundant_phi_nodes (void);
+ extern bool stmt_reads_memory_p (tree);

  /* In tree-into-ssa.c  */
  extern void rewrite_into_ssa (bool);
Index: tree-ssa-loop-im.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-im.c,v
retrieving revision 2.21
diff -c -3 -p -r2.21 tree-ssa-loop-im.c
*** tree-ssa-loop-im.c         8 Nov 2004 13:54:39 -0000           2.21
--- tree-ssa-loop-im.c         12 Nov 2004 19:43:57 -0000
*************** stmt_cost (tree stmt)
*** 365,373 ****
    rhs = TREE_OPERAND (stmt, 1);

    /* Hoisting memory references out should almost surely be a win.  */
!   if (!is_gimple_variable (lhs))
!     cost += 20;
!   if (is_gimple_addressable (rhs) && !is_gimple_variable (rhs))
      cost += 20;

    switch (TREE_CODE (rhs))
--- 365,371 ----
    rhs = TREE_OPERAND (stmt, 1);

    /* Hoisting memory references out should almost surely be a win.  */
!   if (stmt_reads_memory_p (stmt))
      cost += 20;

    switch (TREE_CODE (rhs))
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.57
diff -c -3 -p -r2.57 tree-ssa.c
*** tree-ssa.c           12 Nov 2004 00:08:40 -0000          2.57
--- tree-ssa.c           12 Nov 2004 19:43:57 -0000
*************** tree_ssa_useless_type_conversion (tree e
*** 902,907 ****
--- 902,921 ----
    return false;
  }

+ /* Returns true if statement STMT may read memory.  */
+
+ bool
+ stmt_reads_memory_p (tree stmt)
+ {
+   stmt_ann_t ann;
+
+   get_stmt_operands (stmt);
+   ann = stmt_ann (stmt);
+
+   return (NUM_VUSES (VUSE_OPS (ann)) > 0
+              || NUM_V_MAY_DEFS (V_MAY_DEF_OPS (ann)) > 0
+              || NUM_V_MUST_DEFS (V_MUST_DEF_OPS (ann)) > 0);
+ }

  /* Internal helper for walk_use_def_chains.  VAR, FN and DATA are as
     described in walk_use_def_chains.



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