public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Optimize fix for PR48172
Date: Fri, 13 May 2011 09:51:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1105131028180.810@zhemvz.fhfr.qr> (raw)


The following avoids the multiplication by niters when the step
is equal.

Boostrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-05-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/48172
	* tree-vect-loop-manip.c (vect_vfa_segment_size): Avoid
	multiplying by number of iterations for equal step.
	(vect_create_cond_for_alias_checks): Likewise.

Index: gcc/tree-vect-loop-manip.c
===================================================================
*** gcc/tree-vect-loop-manip.c	(revision 173704)
--- gcc/tree-vect-loop-manip.c	(working copy)
*************** vect_create_cond_for_align_checks (loop_
*** 2353,2375 ****
  
     Input:
       DR: The data reference.
!      VECT_FACTOR: vectorization factor.
!      SCALAR_LOOP_NITERS: number of iterations.
  
     Return an expression whose value is the size of segment which will be
     accessed by DR.  */
  
  static tree
! vect_vfa_segment_size (struct data_reference *dr, int vect_factor,
! 		       tree scalar_loop_niters)
  {
    tree segment_length;
    segment_length = size_binop (MULT_EXPR,
  			       fold_convert (sizetype, DR_STEP (dr)),
! 			       size_int (vect_factor));
!   segment_length = size_binop (MULT_EXPR,
! 			       segment_length,
! 			       fold_convert (sizetype, scalar_loop_niters));
    if (vect_supportable_dr_alignment (dr, false)
          == dr_explicit_realign_optimized)
      {
--- 2353,2370 ----
  
     Input:
       DR: The data reference.
!      LENGTH_FACTOR: segment length to consider.
  
     Return an expression whose value is the size of segment which will be
     accessed by DR.  */
  
  static tree
! vect_vfa_segment_size (struct data_reference *dr, tree length_factor)
  {
    tree segment_length;
    segment_length = size_binop (MULT_EXPR,
  			       fold_convert (sizetype, DR_STEP (dr)),
! 			       fold_convert (sizetype, length_factor));
    if (vect_supportable_dr_alignment (dr, false)
          == dr_explicit_realign_optimized)
      {
*************** vect_create_cond_for_alias_checks (loop_
*** 2417,2423 ****
  
    ddr_p ddr;
    unsigned int i;
!   tree part_cond_expr;
  
    /* Create expression
       ((store_ptr_0 + store_segment_length_0) < load_ptr_0)
--- 2412,2418 ----
  
    ddr_p ddr;
    unsigned int i;
!   tree part_cond_expr, length_factor;
  
    /* Create expression
       ((store_ptr_0 + store_segment_length_0) < load_ptr_0)
*************** vect_create_cond_for_alias_checks (loop_
*** 2465,2474 ****
          vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list,
  					      NULL_TREE, loop);
  
!       segment_length_a = vect_vfa_segment_size (dr_a, vect_factor,
! 						scalar_loop_iters);
!       segment_length_b = vect_vfa_segment_size (dr_b, vect_factor,
! 						scalar_loop_iters);
  
        if (vect_print_dump_info (REPORT_DR_DETAILS))
  	{
--- 2460,2471 ----
          vect_create_addr_base_for_vector_ref (stmt_b, cond_expr_stmt_list,
  					      NULL_TREE, loop);
  
!       if (!operand_equal_p (DR_STEP (dr_a), DR_STEP (dr_b), 0))
! 	length_factor = scalar_loop_iters;
!       else
! 	length_factor = size_int (vect_factor);
!       segment_length_a = vect_vfa_segment_size (dr_a, length_factor);
!       segment_length_b = vect_vfa_segment_size (dr_b, length_factor);
  
        if (vect_print_dump_info (REPORT_DR_DETAILS))
  	{

                 reply	other threads:[~2011-05-13  8:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=alpine.LNX.2.00.1105131028180.810@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /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).