diff mbox

Don't bypass blocks with multiple latch edges (PR middle-end/54838)

Message ID 20121128182457.GB26585@redhat.com
State New
Headers show

Commit Message

Marek Polacek Nov. 28, 2012, 6:24 p.m. UTC
On Wed, Nov 28, 2012 at 10:52:17AM +0100, Eric Botcazou wrote:
> No, I don't think that's the problem.  The above messages are admittedly a bit 
> terse, they should say:
> 
> JUMP-BYPASS: Proved reg 59 in jump_insn 15 equals constant (const_int 3 [0x3])
>              when BB 4 is entered from BB 9.  Redirect edge 9->4 to 5.
> 
> so you can have different constants for BB 3 and BB 9.  The patch to tweak the 
> dump messages along these lines is pre-approved.

Ouch.  Okay, I'll post a separate patch for improving the message.

> The ICE in merge_latch_edges means that the loop structure and the CFG aren't 
> in sync anymore.  Does the cprop pass modify the former without declaring it?

I admit I'm not sure what to look at, maybe cprop should have in
properties_destroyed PROP_loops?  Well, then we need to remove one
assert in loop-init.c.  So something like:

This quashes the ICE.  I've regtested it, it caused one
regression though:
FAIL: gcc.dg/unroll_5.c scan-rtl-dump-times loop2_unroll "realistic
bound: 2999999" 1

But there probably is something else.

Thanks for the review,

	Marek

Comments

Richard Biener Nov. 29, 2012, 8:34 a.m. UTC | #1
On Wed, Nov 28, 2012 at 7:24 PM, Marek Polacek <polacek@redhat.com> wrote:
> On Wed, Nov 28, 2012 at 10:52:17AM +0100, Eric Botcazou wrote:
>> No, I don't think that's the problem.  The above messages are admittedly a bit
>> terse, they should say:
>>
>> JUMP-BYPASS: Proved reg 59 in jump_insn 15 equals constant (const_int 3 [0x3])
>>              when BB 4 is entered from BB 9.  Redirect edge 9->4 to 5.
>>
>> so you can have different constants for BB 3 and BB 9.  The patch to tweak the
>> dump messages along these lines is pre-approved.
>
> Ouch.  Okay, I'll post a separate patch for improving the message.
>
>> The ICE in merge_latch_edges means that the loop structure and the CFG aren't
>> in sync anymore.  Does the cprop pass modify the former without declaring it?
>
> I admit I'm not sure what to look at, maybe cprop should have in
> properties_destroyed PROP_loops?  Well, then we need to remove one
> assert in loop-init.c.  So something like:

Definitely not - that means to not preserve loops until after cprop.  The goal
is to preserve loops everywhere!

Richard.

> --- gcc/cprop.c.mp      2012-11-28 16:55:03.520375191 +0100
> +++ gcc/cprop.c 2012-11-28 16:55:35.992246623 +0100
> @@ -1927,7 +1927,7 @@ struct rtl_opt_pass pass_rtl_cprop =
>    TV_CPROP,                             /* tv_id */
>    PROP_cfglayout,                       /* properties_required */
>    0,                                    /* properties_provided */
> -  0,                                    /* properties_destroyed */
> +  PROP_loops,                           /* properties_destroyed */
>    0,                                    /* todo_flags_start */
>    TODO_df_finish | TODO_verify_rtl_sharing |
>    TODO_verify_flow | TODO_ggc_collect   /* todo_flags_finish */
> --- gcc/loop-init.c.mp  2012-11-28 16:55:08.924398879 +0100
> +++ gcc/loop-init.c     2012-11-28 16:55:17.684437276 +0100
> @@ -54,8 +54,6 @@ loop_optimizer_init (unsigned flags)
>      }
>    else
>      {
> -      gcc_assert (cfun->curr_properties & PROP_loops);
> -
>        /* Ensure that the dominators are computed, like flow_loops_find does.  */
>        calculate_dominance_info (CDI_DOMINATORS);
>
> This quashes the ICE.  I've regtested it, it caused one
> regression though:
> FAIL: gcc.dg/unroll_5.c scan-rtl-dump-times loop2_unroll "realistic
> bound: 2999999" 1
>
> But there probably is something else.
>
> Thanks for the review,
>
>         Marek
Steven Bosscher Nov. 29, 2012, 8:56 a.m. UTC | #2
On Thu, Nov 29, 2012 at 9:34 AM, Richard Biener wrote:
> On Wed, Nov 28, 2012 at 7:24 PM, Marek Polacek wrote:
>> I admit I'm not sure what to look at, maybe cprop should have in
>> properties_destroyed PROP_loops?  Well, then we need to remove one
>> assert in loop-init.c.  So something like:
>
> Definitely not - that means to not preserve loops until after cprop.  The goal
> is to preserve loops everywhere!

It'd be nice if this was documented somewhere...

Ciao!
Steven
Richard Biener Nov. 29, 2012, 9:35 a.m. UTC | #3
On Thu, Nov 29, 2012 at 9:56 AM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> On Thu, Nov 29, 2012 at 9:34 AM, Richard Biener wrote:
>> On Wed, Nov 28, 2012 at 7:24 PM, Marek Polacek wrote:
>>> I admit I'm not sure what to look at, maybe cprop should have in
>>> properties_destroyed PROP_loops?  Well, then we need to remove one
>>> assert in loop-init.c.  So something like:
>>
>> Definitely not - that means to not preserve loops until after cprop.  The goal
>> is to preserve loops everywhere!
>
> It'd be nice if this was documented somewhere...

On my TODO list for stage3 ;)

Richard.

> Ciao!
> Steven
diff mbox

Patch

--- gcc/cprop.c.mp	2012-11-28 16:55:03.520375191 +0100
+++ gcc/cprop.c	2012-11-28 16:55:35.992246623 +0100
@@ -1927,7 +1927,7 @@  struct rtl_opt_pass pass_rtl_cprop =
   TV_CPROP,                             /* tv_id */
   PROP_cfglayout,                       /* properties_required */
   0,                                    /* properties_provided */
-  0,                                    /* properties_destroyed */
+  PROP_loops,                           /* properties_destroyed */
   0,                                    /* todo_flags_start */
   TODO_df_finish | TODO_verify_rtl_sharing |
   TODO_verify_flow | TODO_ggc_collect   /* todo_flags_finish */
--- gcc/loop-init.c.mp	2012-11-28 16:55:08.924398879 +0100
+++ gcc/loop-init.c	2012-11-28 16:55:17.684437276 +0100
@@ -54,8 +54,6 @@  loop_optimizer_init (unsigned flags)
     }
   else
     {
-      gcc_assert (cfun->curr_properties & PROP_loops);
-
       /* Ensure that the dominators are computed, like flow_loops_find does.  */
       calculate_dominance_info (CDI_DOMINATORS);