public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Kewen.Lin" <linkw@linux.ibm.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Bill Schmidt <wschmidt@linux.ibm.com>,
	Segher Boessenkool <segher@kernel.crashing.org>
Subject: Re: [PATCH] Fix PR94401 by considering reverse overrun
Date: Thu, 2 Apr 2020 18:07:55 +0800	[thread overview]
Message-ID: <5e92fc81-bd24-d866-26ee-48a251e69b82@linux.ibm.com> (raw)
In-Reply-To: <20200402082834.GO2212@tucnak>

Hi,

on 2020/4/2 下午4:28, Jakub Jelinek wrote:
> Hi!
> 
> On Thu, Apr 02, 2020 at 03:15:42PM +0800, Kewen.Lin via Gcc-patches wrote:
> 
> Just formatting nits, not commenting on what the actual patch does.
> 
>> --- a/gcc/tree-vect-stmts.c
>> +++ b/gcc/tree-vect-stmts.c
>> @@ -9590,11 +9590,20 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
>>  			    if (new_vtype != NULL_TREE)
>>  			      ltype = half_vtype;
>>  			  }
>> +			tree offset = dataref_offset
>> +					? dataref_offset
>> +					: build_int_cst (ref_type, 0);
> 
> The above is misformatted.  The ? and : shouldn't be indented further than
> the dataref_offset, but usually e.g. for the sake of emacs we add ()s around
> the expression in this case.  So:
> 			tree offset = (dataref_offset
> 				       ? dataref_offset
> 				       : build_int_cst (ref_type, 0));
> or
> 			tree offset
> 			  = (dataref_offset
> 			     ? dataref_offset : build_int_cst (ref_type, 0));
> 

Thanks Jakub!  I'll follow this by add () for ternary expression.
With manual added "()", clang-format can get below:

			tree offset
			  = (dataref_offset ? dataref_offset
					    : build_int_cst (ref_type, 0));

contrib/check_GNU_style.sh didn't complain this, I'm not sure whether
it's possible to add this kind of convention into contrib/clang-format.

>> +			if (ltype != vectype
>> +			    && memory_access_type == VMAT_CONTIGUOUS_REVERSE)
>> +			  offset = size_binop (
>> +			    PLUS_EXPR,
>> +			    build_int_cst (ref_type,
>> +					   DR_GROUP_GAP (first_stmt_info)
>> +					     * tree_to_uhwi (
>> +					       TYPE_SIZE_UNIT (elem_type))),
>> +			    offset);
> 
> Again, no reason to indent * by 2 columns from DR_GROUP_GAP.  But also all
> the (s at the end of line and randomly indented arguments look ugly.
> I'd recommend temporaries, e.g. like (perhaps with different names of
> temporaries, so that they don't shadow anything):
> 
> 			  {
> 			    unsigned HOST_WIDE_INT gap
> 			      = DR_GROUP_GAP (first_stmt_info);
> 			    gap *= tree_to_uhwi (TYPE_SIZE_UNIT (elem_type));
> 			    tree gapcst = build_int_cst (ref_type, gap);
> 			    offset = size_binop (PLUS_EXPR, offset, gapcst);
> 			  }
> 

Good suggestion, will update it.

BR,
Kewen


  reply	other threads:[~2020-04-02 10:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02  7:15 Kewen.Lin
2020-04-02  8:28 ` Jakub Jelinek
2020-04-02 10:07   ` Kewen.Lin [this message]
2020-04-02 10:39     ` Jakub Jelinek
2020-04-02 12:05   ` Segher Boessenkool
2020-04-02  9:21 ` Richard Biener
2020-04-02 10:33   ` Kewen.Lin

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=5e92fc81-bd24-d866-26ee-48a251e69b82@linux.ibm.com \
    --to=linkw@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=segher@kernel.crashing.org \
    --cc=wschmidt@linux.ibm.com \
    /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).