public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix nb_iterations calculation in tree-vect-loop-manip.c
@ 2016-11-15 12:45 Richard Sandiford
  2016-11-15 15:20 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2016-11-15 12:45 UTC (permalink / raw)
  To: gcc-patches

We previously stored the number of loop iterations rather
than the number of latch iterations.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Thanks,
Richard


[ This patch is part of the SVE series posted here:
  https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]

gcc/
2016-11-15  Richard Sandiford  <richard.sandiford@arm.com>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

	* tree-vect-loop-manip.c (slpeel_make_loop_iterate_ntimes): Set
	nb_iterations to the number of latch iterations rather than the
	number of loop iterations.

diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 6bfd332..4c6b8c7 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -285,7 +285,10 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop, tree niters)
 		     LOCATION_LINE (loop_loc));
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, cond_stmt, 0);
     }
-  loop->nb_iterations = niters;
+
+  /* Record the number of latch iterations.  */
+  loop->nb_iterations = fold_build2 (MINUS_EXPR, TREE_TYPE (niters), niters,
+				     build_int_cst (TREE_TYPE (niters), 1));
 }
 
 /* Helper routine of slpeel_tree_duplicate_loop_to_edge_cfg.

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

* Re: Fix nb_iterations calculation in tree-vect-loop-manip.c
  2016-11-15 12:45 Fix nb_iterations calculation in tree-vect-loop-manip.c Richard Sandiford
@ 2016-11-15 15:20 ` Richard Biener
  2016-11-15 15:55   ` Richard Sandiford
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2016-11-15 15:20 UTC (permalink / raw)
  To: GCC Patches, richard.sandiford

On Tue, Nov 15, 2016 at 1:44 PM, Richard Sandiford
<richard.sandiford@arm.com> wrote:
> We previously stored the number of loop iterations rather
> than the number of latch iterations.

So ->nb_iterations was unused without SVE?  Otherwise can you please
add a testcase?

Thanks,
Richard.

> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> [ This patch is part of the SVE series posted here:
>   https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]
>
> gcc/
> 2016-11-15  Richard Sandiford  <richard.sandiford@arm.com>
>             Alan Hayward  <alan.hayward@arm.com>
>             David Sherwood  <david.sherwood@arm.com>
>
>         * tree-vect-loop-manip.c (slpeel_make_loop_iterate_ntimes): Set
>         nb_iterations to the number of latch iterations rather than the
>         number of loop iterations.
>
> diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
> index 6bfd332..4c6b8c7 100644
> --- a/gcc/tree-vect-loop-manip.c
> +++ b/gcc/tree-vect-loop-manip.c
> @@ -285,7 +285,10 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop, tree niters)
>                      LOCATION_LINE (loop_loc));
>        dump_gimple_stmt (MSG_NOTE, TDF_SLIM, cond_stmt, 0);
>      }
> -  loop->nb_iterations = niters;
> +
> +  /* Record the number of latch iterations.  */
> +  loop->nb_iterations = fold_build2 (MINUS_EXPR, TREE_TYPE (niters), niters,
> +                                    build_int_cst (TREE_TYPE (niters), 1));
>  }
>
>  /* Helper routine of slpeel_tree_duplicate_loop_to_edge_cfg.
>

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

* Re: Fix nb_iterations calculation in tree-vect-loop-manip.c
  2016-11-15 15:20 ` Richard Biener
@ 2016-11-15 15:55   ` Richard Sandiford
  2016-11-16 13:02     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2016-11-15 15:55 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

Richard Biener <richard.guenther@gmail.com> writes:
> On Tue, Nov 15, 2016 at 1:44 PM, Richard Sandiford
> <richard.sandiford@arm.com> wrote:
>> We previously stored the number of loop iterations rather
>> than the number of latch iterations.
>
> So ->nb_iterations was unused without SVE?  Otherwise can you please
> add a testcase?

TBH I can't remember whether we noticed this by inspection or whether
it did manifest in the output somehow.  If it did, it would have been
an extra unnecessary iteration after complete unrolling, but usually
a later patch would remove the iteration as dead.

Thanks,
Richard

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

* Re: Fix nb_iterations calculation in tree-vect-loop-manip.c
  2016-11-15 15:55   ` Richard Sandiford
@ 2016-11-16 13:02     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2016-11-16 13:02 UTC (permalink / raw)
  To: Richard Biener, GCC Patches, richard.sandiford

On Tue, Nov 15, 2016 at 4:54 PM, Richard Sandiford
<richard.sandiford@arm.com> wrote:
> Richard Biener <richard.guenther@gmail.com> writes:
>> On Tue, Nov 15, 2016 at 1:44 PM, Richard Sandiford
>> <richard.sandiford@arm.com> wrote:
>>> We previously stored the number of loop iterations rather
>>> than the number of latch iterations.
>>
>> So ->nb_iterations was unused without SVE?  Otherwise can you please
>> add a testcase?
>
> TBH I can't remember whether we noticed this by inspection or whether
> it did manifest in the output somehow.  If it did, it would have been
> an extra unnecessary iteration after complete unrolling, but usually
> a later patch would remove the iteration as dead.

Ok then.

Thanks,
Richard.

> Thanks,
> Richard

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

end of thread, other threads:[~2016-11-16 13:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15 12:45 Fix nb_iterations calculation in tree-vect-loop-manip.c Richard Sandiford
2016-11-15 15:20 ` Richard Biener
2016-11-15 15:55   ` Richard Sandiford
2016-11-16 13:02     ` 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).