* Do not drop the loop bounds when copying it
@ 2012-10-16 15:50 Jan Hubicka
2012-10-17 10:13 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2012-10-16 15:50 UTC (permalink / raw)
To: gcc-patches, rguenther
Hi,
while looking into cases where loop-iv.c still deduce useful bounds that are not
recorded by tree level I noticed that we do not duplicate the bounds when copying
the loop.
Fixed thus.
Bootstrapped/regtested x86_64-linux, OK?
Honza
* cfgloopmanip.c (copy_loop_info): New function.
(duplicate_loop): Use it.
(loop_version): Use it.
* loop-unswitch.c (unswitch_loop): Use it.
* cfgloop.h (copy_loop_info): Declare.
Index: cfgloopmanip.c
===================================================================
--- cfgloopmanip.c (revision 192483)
+++ cfgloopmanip.c (working copy)
@@ -971,6 +970,20 @@ fix_loop_placements (struct loop *loop,
}
}
+/* Duplicate loop bounds and other information we store about
+ the loop into its duplicate. */
+
+void
+copy_loop_info (struct loop *loop, struct loop *target)
+{
+ gcc_checking_assert (!target->any_upper_bound && !target->any_estimate);
+ target->any_upper_bound = loop->any_upper_bound;
+ target->nb_iterations_upper_bound = loop->nb_iterations_upper_bound;
+ target->any_estimate = loop->any_estimate;
+ target->nb_iterations_estimate = loop->nb_iterations_estimate;
+ target->estimate_state = loop->estimate_state;
+}
+
/* Copies copy of LOOP as subloop of TARGET loop, placing newly
created loop into loops structure. */
struct loop *
@@ -979,6 +992,8 @@ duplicate_loop (struct loop *loop, struc
struct loop *cloop;
cloop = alloc_loop ();
place_new_loop (cloop);
+
+ copy_loop_info (loop, cloop);
/* Mark the new loop as copy of LOOP. */
set_loop_copy (loop, cloop);
@@ -1687,6 +1702,8 @@ loop_version (struct loop *loop,
false /* Do not redirect all edges. */,
then_scale, else_scale);
+ copy_loop_info (loop, nloop);
+
/* loopify redirected latch_edge. Update its PENDING_STMTS. */
lv_flush_pending_stmts (latch_edge);
Index: loop-unswitch.c
===================================================================
--- loop-unswitch.c (revision 192483)
+++ loop-unswitch.c (working copy)
@@ -454,6 +454,7 @@ unswitch_loop (struct loop *loop, basic_
BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true,
prob, REG_BR_PROB_BASE - prob);
+ copy_loop_info (loop, nloop);
/* Remove branches that are now unreachable in new loops. */
remove_path (true_edge);
remove_path (false_edge);
Index: cfgloop.h
===================================================================
--- cfgloop.h (revision 192483)
+++ cfgloop.h (working copy)
@@ -310,6 +310,7 @@ extern edge create_empty_if_region_on_ed
extern struct loop *create_empty_loop_on_edge (edge, tree, tree, tree, tree,
tree *, tree *, struct loop *);
extern struct loop * duplicate_loop (struct loop *, struct loop *);
+extern void copy_loop_info (struct loop *loop, struct loop *target);
extern void duplicate_subloops (struct loop *, struct loop *);
extern bool duplicate_loop_to_header_edge (struct loop *, edge,
unsigned, sbitmap, edge,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Do not drop the loop bounds when copying it
2012-10-16 15:50 Do not drop the loop bounds when copying it Jan Hubicka
@ 2012-10-17 10:13 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2012-10-17 10:13 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
On Tue, 16 Oct 2012, Jan Hubicka wrote:
> Hi,
> while looking into cases where loop-iv.c still deduce useful bounds that are not
> recorded by tree level I noticed that we do not duplicate the bounds when copying
> the loop.
> Fixed thus.
> Bootstrapped/regtested x86_64-linux, OK?
Ok.
Thanks,
Richard.
> Honza
>
> * cfgloopmanip.c (copy_loop_info): New function.
> (duplicate_loop): Use it.
> (loop_version): Use it.
> * loop-unswitch.c (unswitch_loop): Use it.
> * cfgloop.h (copy_loop_info): Declare.
> Index: cfgloopmanip.c
> ===================================================================
> --- cfgloopmanip.c (revision 192483)
> +++ cfgloopmanip.c (working copy)
> @@ -971,6 +970,20 @@ fix_loop_placements (struct loop *loop,
> }
> }
>
> +/* Duplicate loop bounds and other information we store about
> + the loop into its duplicate. */
> +
> +void
> +copy_loop_info (struct loop *loop, struct loop *target)
> +{
> + gcc_checking_assert (!target->any_upper_bound && !target->any_estimate);
> + target->any_upper_bound = loop->any_upper_bound;
> + target->nb_iterations_upper_bound = loop->nb_iterations_upper_bound;
> + target->any_estimate = loop->any_estimate;
> + target->nb_iterations_estimate = loop->nb_iterations_estimate;
> + target->estimate_state = loop->estimate_state;
> +}
> +
> /* Copies copy of LOOP as subloop of TARGET loop, placing newly
> created loop into loops structure. */
> struct loop *
> @@ -979,6 +992,8 @@ duplicate_loop (struct loop *loop, struc
> struct loop *cloop;
> cloop = alloc_loop ();
> place_new_loop (cloop);
> +
> + copy_loop_info (loop, cloop);
>
> /* Mark the new loop as copy of LOOP. */
> set_loop_copy (loop, cloop);
> @@ -1687,6 +1702,8 @@ loop_version (struct loop *loop,
> false /* Do not redirect all edges. */,
> then_scale, else_scale);
>
> + copy_loop_info (loop, nloop);
> +
> /* loopify redirected latch_edge. Update its PENDING_STMTS. */
> lv_flush_pending_stmts (latch_edge);
>
> Index: loop-unswitch.c
> ===================================================================
> --- loop-unswitch.c (revision 192483)
> +++ loop-unswitch.c (working copy)
> @@ -454,6 +454,7 @@ unswitch_loop (struct loop *loop, basic_
> BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true,
> prob, REG_BR_PROB_BASE - prob);
>
> + copy_loop_info (loop, nloop);
> /* Remove branches that are now unreachable in new loops. */
> remove_path (true_edge);
> remove_path (false_edge);
> Index: cfgloop.h
> ===================================================================
> --- cfgloop.h (revision 192483)
> +++ cfgloop.h (working copy)
> @@ -310,6 +310,7 @@ extern edge create_empty_if_region_on_ed
> extern struct loop *create_empty_loop_on_edge (edge, tree, tree, tree, tree,
> tree *, tree *, struct loop *);
> extern struct loop * duplicate_loop (struct loop *, struct loop *);
> +extern void copy_loop_info (struct loop *loop, struct loop *target);
> extern void duplicate_subloops (struct loop *, struct loop *);
> extern bool duplicate_loop_to_header_edge (struct loop *, edge,
> unsigned, sbitmap, edge,
>
>
--
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-17 10:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-16 15:50 Do not drop the loop bounds when copying it Jan Hubicka
2012-10-17 10:13 ` 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).