public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH GCC]Don't clobber cbase when computing iv_use cost.
@ 2016-04-29 15:56 Bin Cheng
  2016-05-02  9:03 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Bin Cheng @ 2016-04-29 15:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd

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

Hi,
This fixes a latent bug I introduced.  Variable "cbase" shouldn't be modified since it will be used afterwards.  Bootstrap and test on x86_64.  I think it's an obvious change, is it OK?

Thanks,
bin

2016-04-28  Bin Cheng  <bin.cheng@arm.com>

	* tree-ssa-loop-ivopts.c (get_computation_cost_at): Don't clobber
	cbase.

[-- Attachment #2: dont-clobber-cbase-20160428.txt --]
[-- Type: text/plain, Size: 1109 bytes --]

diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 7be4f16..acafaff 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -4927,17 +4927,19 @@ get_computation_cost_at (struct ivopts_data *data,
 		(ratio, mem_mode,
 			TYPE_ADDR_SPACE (TREE_TYPE (utype))))
     {
+      tree real_cbase = cbase;
+
       if (cstepi == 0 && stmt_is_after_inc)
 	{
 	  if (POINTER_TYPE_P (ctype))
-	    cbase = fold_build2 (POINTER_PLUS_EXPR, ctype, cbase, cstep);
+	    real_cbase = fold_build2 (POINTER_PLUS_EXPR, ctype, cbase, cstep);
 	  else
-	    cbase = fold_build2 (PLUS_EXPR, ctype, cbase, cstep);
+	    real_cbase = fold_build2 (PLUS_EXPR, ctype, cbase, cstep);
 	}
-      cbase
-	= fold_build2 (MULT_EXPR, ctype, cbase, build_int_cst (ctype, ratio));
+      real_cbase = fold_build2 (MULT_EXPR, ctype, real_cbase,
+				build_int_cst (ctype, ratio));
       cost = difference_cost (data,
-			      ubase, cbase,
+			      ubase, real_cbase,
 			      &symbol_present, &var_present, &offset,
 			      depends_on);
       cost.cost /= avg_loop_niter (data->current_loop);

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

* Re: [PATCH GCC]Don't clobber cbase when computing iv_use cost.
  2016-04-29 15:56 [PATCH GCC]Don't clobber cbase when computing iv_use cost Bin Cheng
@ 2016-05-02  9:03 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-05-02  9:03 UTC (permalink / raw)
  To: Bin Cheng; +Cc: gcc-patches, nd

On Fri, Apr 29, 2016 at 5:55 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This fixes a latent bug I introduced.  Variable "cbase" shouldn't be modified since it will be used afterwards.  Bootstrap and test on x86_64.  I think it's an obvious change, is it OK?

Ok.

Richard.

> Thanks,
> bin
>
> 2016-04-28  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-ssa-loop-ivopts.c (get_computation_cost_at): Don't clobber
>         cbase.

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

end of thread, other threads:[~2016-05-02  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 15:56 [PATCH GCC]Don't clobber cbase when computing iv_use cost Bin Cheng
2016-05-02  9:03 ` Richard Biener

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