public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH GCC]Correct cand_chain and stmt_cand_map for copy/cast
@ 2019-05-15  5:54 bin.cheng
  2019-05-15 11:09 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: bin.cheng @ 2019-05-15  5:54 UTC (permalink / raw)
  To: GCC Patches

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

Hi,
I noticed that cand_chain (first_interp/next_interp) is not maintained correctly
in slsr_process_copy/slsr_process_cast (now slsr_process_copycast).  This one
fixes the issue, as well as records the "first" cand in stmt_cand_map.

Hi Bill, is this correct or I misunderstood the code? Bootstrap and test on x86_64.

Thanks,
bin

2019-05-15  Bin Cheng  <bin.cheng@linux.alibaba.com>

        * gimple-ssa-strength-reduction.c (slsr_process_copycast): Record
        information about next_interp and the first cand.

[-- Attachment #2: 0003-Correct-cand_chain-and-cand_stmt_map-for-copy-cast.patch --]
[-- Type: application/octet-stream, Size: 1280 bytes --]

diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index c30793a91bd..0483058d78d 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -1680,7 +1680,7 @@ slsr_process_copycast (gimple *gs, tree rhs1, bool speed)
 
   if (base_cand && base_cand->kind != CAND_PHI)
     {
-      slsr_cand_t first_cand = NULL;
+      slsr_cand_t last_cand = NULL;
 
       while (base_cand)
 	{
@@ -1693,17 +1693,19 @@ slsr_process_copycast (gimple *gs, tree rhs1, bool speed)
 	     In case of cast, the type is not propagated because it comes
 	     from the cast, and the base candidate's cast, which is no
 	     longer applicable.  */
-	  c = alloc_cand_and_find_basis (base_cand->kind, gs,
+	  c2 = alloc_cand_and_find_basis (base_cand->kind, gs,
 					 base_cand->base_expr,
 					 base_cand->index, base_cand->stride,
 					 ctype, base_cand->stride_type,
 					 savings);
-	  if (!first_cand)
-	    first_cand = c;
-
-	  if (first_cand != c)
-	    c->first_interp = first_cand->cand_num;
-
+	  if (!c)
+	    c = c2;
+	  else
+	    {
+	      c2->first_interp = c->cand_num;
+	      last_cand->next_interp = c2->cand_num;
+	    }
+	  last_cand = c2;
 	  base_cand = lookup_cand (base_cand->next_interp);
 	}
     }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH GCC]Correct cand_chain and stmt_cand_map for copy/cast
  2019-05-15  5:54 [PATCH GCC]Correct cand_chain and stmt_cand_map for copy/cast bin.cheng
@ 2019-05-15 11:09 ` Richard Biener
  2019-05-21 16:38   ` Bill Schmidt
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2019-05-15 11:09 UTC (permalink / raw)
  To: bin.cheng, Bill Schmidt; +Cc: GCC Patches

On Wed, May 15, 2019 at 7:54 AM bin.cheng <bin.cheng@linux.alibaba.com> wrote:
>
> Hi,
> I noticed that cand_chain (first_interp/next_interp) is not maintained correctly
> in slsr_process_copy/slsr_process_cast (now slsr_process_copycast).  This one
> fixes the issue, as well as records the "first" cand in stmt_cand_map.
>
> Hi Bill, is this correct or I misunderstood the code? Bootstrap and test on x86_64.

Looks good to me, still waiting for Bills feedback (now CCed).

Richard.

> Thanks,
> bin
>
> 2019-05-15  Bin Cheng  <bin.cheng@linux.alibaba.com>
>
>         * gimple-ssa-strength-reduction.c (slsr_process_copycast): Record
>         information about next_interp and the first cand.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH GCC]Correct cand_chain and stmt_cand_map for copy/cast
  2019-05-15 11:09 ` Richard Biener
@ 2019-05-21 16:38   ` Bill Schmidt
  0 siblings, 0 replies; 3+ messages in thread
From: Bill Schmidt @ 2019-05-21 16:38 UTC (permalink / raw)
  To: Richard Biener, bin.cheng; +Cc: GCC Patches

On 5/15/19 6:09 AM, Richard Biener wrote:
> On Wed, May 15, 2019 at 7:54 AM bin.cheng <bin.cheng@linux.alibaba.com> wrote:
>> Hi,
>> I noticed that cand_chain (first_interp/next_interp) is not maintained correctly
>> in slsr_process_copy/slsr_process_cast (now slsr_process_copycast).  This one
>> fixes the issue, as well as records the "first" cand in stmt_cand_map.
>>
>> Hi Bill, is this correct or I misunderstood the code? Bootstrap and test on x86_64.
> Looks good to me, still waiting for Bills feedback (now CCed).

Good catch, thanks for fixing!  Okay for trunk.

My mail server seems to have eaten the patch that introduces slsr_process_copycast.
This is okay for trunk also, with one grammatical nit.  Please change the comment
before alloc_cand_and_fine_basis to read:

"In case of a cast, the type is not propagated because it comes from the cast;
nor is the base candidate's cast, which is no longer applicable."

I'm very sorry for the delay due to vacation.

Thanks!
Bill

>
> Richard.
>
>> Thanks,
>> bin
>>
>> 2019-05-15  Bin Cheng  <bin.cheng@linux.alibaba.com>
>>
>>         * gimple-ssa-strength-reduction.c (slsr_process_copycast): Record
>>         information about next_interp and the first cand.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-21 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-15  5:54 [PATCH GCC]Correct cand_chain and stmt_cand_map for copy/cast bin.cheng
2019-05-15 11:09 ` Richard Biener
2019-05-21 16:38   ` Bill Schmidt

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).