public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Dorit Nuzman <DORIT@il.ibm.com>
To: Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [patch] vectorizer cleanups (and prep for outer-loop vectorization) -  part 4/5
Date: Wed, 11 Apr 2007 11:51:00 -0000	[thread overview]
Message-ID: <OF8F7CA9C7.4B1C6C2D-ONC22572B9.0071801D-C22572BA.00414D56@il.ibm.com> (raw)
In-Reply-To: <20070402094812.GA12138@atrey.karlin.mff.cuni.cz>

[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]

Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> wrote on 02/04/2007
12:48:12:

> Hello,
>
> I will look at the patch.  However, would it be possible to split it
> into smaller parts?  The changes seem to be quite independent,
>
> Zdenek
>
> > This is exactly the same patch as was committed to autovect last week:
> > http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01904.html
> > (but relative to mainline, and after testig on mainline).
> >
> > These are a few cleanups (really technical things, no new
functionality),
> > some of which will be also useful for outer-loop vectorization:
> >
...
> >
> > o A bunch of other cleanups (that are not necessarily inspired by
> > outer-loop vectorization): ... Remove the '#ifdef
> > ADJUST_IN_EPILOG' and the code path that was disabled by it (which
removes
> > unused code and simplifies the function); ...
> >

Tested on the vectorizer testcases
Bootstrapped and passed full testing on powerpc-linux together with the
other parts of this patch.

thanks,
dorit

ChangeLog:

       * tree-vect-transform.c (get_initial_def_for_reduction): Clean away
       the unused code for reduction without adjust-in-epilog to simplify
the
       function.

(See attached file: vect_cleanups.4.no_adjust.txt)

[-- Attachment #2: vect_cleanups.4.no_adjust.txt --]
[-- Type: text/plain, Size: 6271 bytes --]

*** tree-vect-transform.c.2	2007-04-10 21:54:08.000000000 +0300
--- tree-vect-transform.c.4	2007-04-10 22:27:49.000000000 +0300
*************** vect_finish_stmt_generation (tree stmt, 
*** 944,951 ****
  }
  
  
- #define ADJUST_IN_EPILOG 1
- 
  /* Function get_initial_def_for_reduction
  
     Input:
--- 944,949 ----
*************** vect_finish_stmt_generation (tree stmt, 
*** 953,970 ****
     INIT_VAL - the initial value of the reduction variable
  
     Output:
!    SCALAR_DEF - a tree that holds a value to be added to the final result
! 	of the reduction (used for "ADJUST_IN_EPILOG" - see below).
     Return a vector variable, initialized according to the operation that STMT
! 	performs. This vector will be used as the initial value of the
! 	vector of partial results.
  
!    Option1 ("ADJUST_IN_EPILOG"): Initialize the vector as follows:
       add:         [0,0,...,0,0]
       mult:        [1,1,...,1,1]
       min/max:     [init_val,init_val,..,init_val,init_val]
       bit and/or:  [init_val,init_val,..,init_val,init_val]
!    and when necessary (e.g. add/mult case) let the caller know 
     that it needs to adjust the result by init_val.
  
     Option2: Initialize the vector as follows:
--- 951,968 ----
     INIT_VAL - the initial value of the reduction variable
  
     Output:
!    ADJUSTMENT_DEF - a tree that holds a value to be added to the final result
!         of the reduction (used for adjusting the epilog - see below).
     Return a vector variable, initialized according to the operation that STMT
!         performs. This vector will be used as the initial value of the
!         vector of partial results.
  
!    Option1 (adjust in epilog): Initialize the vector as follows:
       add:         [0,0,...,0,0]
       mult:        [1,1,...,1,1]
       min/max:     [init_val,init_val,..,init_val,init_val]
       bit and/or:  [init_val,init_val,..,init_val,init_val]
!    and when necessary (e.g. add/mult case) let the caller know
     that it needs to adjust the result by init_val.
  
     Option2: Initialize the vector as follows:
*************** vect_finish_stmt_generation (tree stmt, 
*** 985,1068 ****
     or [0,0,0,0] and let the caller know that it needs to adjust
     the result at the end by 'init_val'.
  
!    FORNOW: We use the "ADJUST_IN_EPILOG" scheme.
!    TODO: Use some cost-model to estimate which scheme is more profitable.
! */
  
  static tree
! get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def)
  {
    stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
    tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
    int nunits =  TYPE_VECTOR_SUBPARTS (vectype);
-   int nelements;
    enum tree_code code = TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1));
    tree type = TREE_TYPE (init_val);
!   tree def;
!   tree vec, t = NULL_TREE;
!   bool need_epilog_adjust;
    int i;
    tree vector_type;
  
    gcc_assert (INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type));
  
    switch (code)
    {
    case WIDEN_SUM_EXPR:
    case DOT_PROD_EXPR:
    case PLUS_EXPR:
      if (INTEGRAL_TYPE_P (type))
!       def = build_int_cst (type, 0);
      else
!       def = build_real (type, dconst0);
! 
! #ifdef ADJUST_IN_EPILOG
!     /* All the 'nunits' elements are set to 0. The final result will be
!        adjusted by 'init_val' at the loop epilog.  */
!     nelements = nunits;
!     need_epilog_adjust = true;
! #else
!     /* 'nunits - 1' elements are set to 0; The last element is set to 
!         'init_val'.  No further adjustments at the epilog are needed.  */
!     nelements = nunits - 1;
!     need_epilog_adjust = false;
! #endif
      break;
  
    case MIN_EXPR:
    case MAX_EXPR:
!     def = init_val;
!     nelements = nunits;
!     need_epilog_adjust = false;
      break;
  
    default:
      gcc_unreachable ();
    }
  
!   for (i = nelements - 1; i >= 0; --i)
!     t = tree_cons (NULL_TREE, def, t);
! 
!   if (nelements == nunits - 1)
!     {
!       /* Set the last element of the vector.  */
!       t = tree_cons (NULL_TREE, init_val, t);
!       nelements += 1;
!     }
!   gcc_assert (nelements == nunits);
! 
!   vector_type = get_vectype_for_scalar_type (TREE_TYPE (def));
!   if (TREE_CODE (init_val) == INTEGER_CST || TREE_CODE (init_val) == REAL_CST)
!     vec = build_vector (vector_type, t);
!   else
!     vec = build_constructor_from_list (vector_type, t);
!     
!   if (!need_epilog_adjust)
!     *scalar_def = NULL_TREE;
!   else
!     *scalar_def = init_val;
! 
!   return vect_init_vector (stmt, vec, vector_type);
  }
  
  
--- 983,1038 ----
     or [0,0,0,0] and let the caller know that it needs to adjust
     the result at the end by 'init_val'.
  
!    FORNOW, we are using the 'adjust in epilog' scheme, because this way the
!    initialization vector is simpler (same element in all entries).
!    A cost model should help decide between these two schemes.  */
  
  static tree
! get_initial_def_for_reduction (tree stmt, tree init_val, tree *adjustment_def)
  {
    stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
    tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
    int nunits =  TYPE_VECTOR_SUBPARTS (vectype);
    enum tree_code code = TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 1));
    tree type = TREE_TYPE (init_val);
!   tree vecdef;
!   tree def_for_init;
!   tree init_def;
!   tree t = NULL_TREE;
    int i;
    tree vector_type;
  
    gcc_assert (INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type));
+   vecdef = vect_get_vec_def_for_operand (init_val, stmt, NULL);
  
    switch (code)
    {
    case WIDEN_SUM_EXPR:
    case DOT_PROD_EXPR:
    case PLUS_EXPR:
+     *adjustment_def = init_val;
+     /* Create a vector of zeros for init_def.  */
      if (INTEGRAL_TYPE_P (type))
!       def_for_init = build_int_cst (type, 0);
      else
!       def_for_init = build_real (type, dconst0);
!       for (i = nunits - 1; i >= 0; --i)
!     t = tree_cons (NULL_TREE, def_for_init, t);
!     vector_type = get_vectype_for_scalar_type (TREE_TYPE (def_for_init));
!     init_def = build_vector (vector_type, t);
      break;
  
    case MIN_EXPR:
    case MAX_EXPR:
!     *adjustment_def = NULL_TREE;
!     init_def = vecdef;
      break;
  
    default:
      gcc_unreachable ();
    }
  
!   return init_def;
  }
  
  

  parent reply	other threads:[~2007-04-11 11:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-02  8:43 [patch] vectorizer cleanups (and prep for outer-loop vectorization) Dorit Nuzman
2007-04-02  9:48 ` Zdenek Dvorak
2007-04-02  9:55   ` Zdenek Dvorak
2007-04-11 11:51   ` [patch] vectorizer cleanups (and prep for outer-loop vectorization) - part 2/5 Dorit Nuzman
2007-04-11 23:53     ` Zdenek Dvorak
2007-04-14 18:29       ` Dorit Nuzman
2007-04-14 18:56         ` Zdenek Dvorak
2007-04-11 11:51   ` [patch] vectorizer cleanups (and prep for outer-loop vectorization) - part 3/5 Dorit Nuzman
2007-04-12 12:11     ` Zdenek Dvorak
2007-04-14 18:54       ` Dorit Nuzman
2007-04-14 19:32         ` Zdenek Dvorak
2007-04-11 11:51   ` Dorit Nuzman [this message]
2007-04-12 12:17     ` [patch] vectorizer cleanups (and prep for outer-loop vectorization) - part 4/5 Zdenek Dvorak
2007-04-11 11:51   ` [patch] vectorizer cleanups (and prep for outer-loop vectorization) - part 1/5 Dorit Nuzman
2007-04-11 11:51   ` [patch] vectorizer cleanups (and prep for outer-loop vectorization) Dorit Nuzman
2007-04-11 11:51   ` [patch] vectorizer cleanups (and prep for outer-loop vectorization) - part 5/5 Dorit Nuzman
2007-04-12 12:22     ` Zdenek Dvorak
2007-04-12 14:23       ` Daniel Berlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OF8F7CA9C7.4B1C6C2D-ONC22572B9.0071801D-C22572BA.00414D56@il.ibm.com \
    --to=dorit@il.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rakdver@atrey.karlin.mff.cuni.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).