public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/45352]  New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
@ 2010-08-20 11:14 zsojka at seznam dot cz
  2010-08-20 11:15 ` [Bug rtl-optimization/45352] " zsojka at seznam dot cz
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2010-08-20 11:14 UTC (permalink / raw)
  To: gcc-bugs

Command line:
$ gcc -O1 -frerun-cse-after-loop -ftree-vectorize -fschedule-insns
-fschedule-insns2 -fselective-scheduling2 -fsel-sched-pipelining -funroll-loops
-fprefetch-loop-arrays testcase.c
or
$ gcc -O3 -fschedule-insns -fschedule-insns2 -fselective-scheduling2
-fsel-sched-pipelining -funroll-loops -fprefetch-loop-arrays testcase.c

I came to this problem in several testcases, but the set of options could never
be reduced more.

Compiler output:
$ gcc -O1 -frerun-cse-after-loop -ftree-vectorize -fschedule-insns
-fschedule-insns2 -fselective-scheduling2 -fsel-sched-pipelining -funroll-loops
-fprefetch-loop-arrays testcase.c
testcase.c: In function 'main1':
testcase.c:10:1: internal compiler error: in reset_sched_cycles_in_current_ebb,
at sel-sched.c:7058
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r163371 - crash


-- 
           Summary: ICE: in reset_sched_cycles_in_current_ebb, at sel-
                    sched.c:7058
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zsojka at seznam dot cz
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352


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

* [Bug rtl-optimization/45352] ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
  2010-08-20 11:14 [Bug rtl-optimization/45352] New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058 zsojka at seznam dot cz
@ 2010-08-20 11:15 ` zsojka at seznam dot cz
  2010-08-22 17:15 ` zsojka at seznam dot cz
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2010-08-20 11:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from zsojka at seznam dot cz  2010-08-20 11:15 -------
Created an attachment (id=21528)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21528&action=view)
reduced testcase (from gcc.dg/vect/no-vfa-vect-43.c)

The first loop is not needed to reproduce the problem, it just makes values
initialized.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352


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

* [Bug rtl-optimization/45352] ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
  2010-08-20 11:14 [Bug rtl-optimization/45352] New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058 zsojka at seznam dot cz
  2010-08-20 11:15 ` [Bug rtl-optimization/45352] " zsojka at seznam dot cz
@ 2010-08-22 17:15 ` zsojka at seznam dot cz
  2010-09-20 18:00 ` zsojka at seznam dot cz
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2010-08-22 17:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from zsojka at seznam dot cz  2010-08-22 17:15 -------
Created an attachment (id=21544)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21544&action=view)
different testcase

This one crashes with:
$ gcc -Os -fselective-scheduling2 -fsel-sched-pipelining -fprofile-generate
pr45352-2.c     
pr45352-2.c: In function 'df_md_alloc':
pr45352-2.c:21:1: internal compiler error: in
reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

This set of flags might be more useful.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352


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

* [Bug rtl-optimization/45352] ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
  2010-08-20 11:14 [Bug rtl-optimization/45352] New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058 zsojka at seznam dot cz
  2010-08-20 11:15 ` [Bug rtl-optimization/45352] " zsojka at seznam dot cz
  2010-08-22 17:15 ` zsojka at seznam dot cz
@ 2010-09-20 18:00 ` zsojka at seznam dot cz
  2010-09-22 14:29 ` abel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2010-09-20 18:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from zsojka at seznam dot cz  2010-09-20 18:00 -------
Created an attachment (id=21849)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21849&action=view)
another testcase that doesn't need many flags to reproduce

$ gcc -fselective-scheduling2 -fsel-sched-pipelining -funroll-all-loops
-march=amdfam10 -O3 pr45352-5.c 
pr45352-5.c: In function 'foo':
pr45352-5.c:22:1: internal compiler error: in
reset_sched_cycles_in_current_ebb, at sel-sched.c:7077
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The failing assert is:
          gcc_assert (cost < 0);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352


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

* [Bug rtl-optimization/45352] ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
  2010-08-20 11:14 [Bug rtl-optimization/45352] New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058 zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2010-09-20 18:00 ` zsojka at seznam dot cz
@ 2010-09-22 14:29 ` abel at gcc dot gnu dot org
  2010-09-22 15:34 ` abel at gcc dot gnu dot org
  2010-09-22 21:54 ` zsojka at seznam dot cz
  5 siblings, 0 replies; 7+ messages in thread
From: abel at gcc dot gnu dot org @ 2010-09-22 14:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from abel at gcc dot gnu dot org  2010-09-22 14:29 -------
Confirmed.

All testcases except the first with the -O3 flags are fixed by the below patch.
 The bug that the patch "fixes" is actually PR37360 all over again but in
sel-sched instead of haifa.  We have the process of resetting sched-cycles for
insns (that may be wrong because of pipelining) for the targets that may use
them in their sched_finish hook.  (E.g. ia64 does bundling in this hook.)  The
process is just scheduling insns in the same order as they are already, calling
all the necessary hooks and massaging DFA so we get the correct cycles from it.
 The assert triggered means that the selective scheduling and this resetting
process got out of sync.  And this happened guess why, because (for the last
test I had actually analyzed) the target claims issue_rate of 3 while issuing 4
insns on the same cycle!  I'm actually surprised that the GCC target lying to
the backend may still surprise me, but I guess ten more years of GCC work would
do the trick.

I will be looking at the remaining failure shortly.

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 041c471..aff7eae 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4402,7 +4402,8 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
     {
       can_issue_more = invoke_aftermath_hooks (fence, EXPR_INSN_RTX (best),
                                                can_issue_more);
-      if (can_issue_more == 0)
+      if (targetm.sched.variable_issue
+         && can_issue_more == 0)
         *pneed_stall = 1;
     }


-- 

abel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |abel at gcc dot gnu dot org
         AssignedTo|unassigned at gcc dot gnu   |abel at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-09-22 14:29:22
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352


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

* [Bug rtl-optimization/45352] ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
  2010-08-20 11:14 [Bug rtl-optimization/45352] New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058 zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2010-09-22 14:29 ` abel at gcc dot gnu dot org
@ 2010-09-22 15:34 ` abel at gcc dot gnu dot org
  2010-09-22 21:54 ` zsojka at seznam dot cz
  5 siblings, 0 replies; 7+ messages in thread
From: abel at gcc dot gnu dot org @ 2010-09-22 15:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from abel at gcc dot gnu dot org  2010-09-22 15:34 -------
The remaining problem is another case where we don't try to issue more insns
because we believe from issue_rate that this is impossible.  Full patch that
fixes all the tests with all the flags for me is below.  What it does is to fix
the situation when we don't try to issue an insn not because some target hook
said so, but because we believe that issue_rate is achieved already.  In this
case, we still try.  There is some related debug dump improvements in the
patch.

The patch will need a round of testing on a number of arches to check that I
didn't broke the honest targets and a big comment explaining why we do this
before I will submit to gcc-patches.  

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 041c471..aee298a 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4051,10 +4051,11 @@ sel_dfa_new_cycle (insn_t insn, fence_t fence)
 /* Invoke reorder* target hooks on the ready list.  Return the number of insns
    we can issue.  FENCE is the current fence.  */
 static int
-invoke_reorder_hooks (fence_t fence)
+invoke_reorder_hooks (fence_t fence, bool *pran_hook)
 {
   int issue_more;
-  bool ran_hook = false;
+
+  *pran_hook = false;

   /* Call the reorder hook at the beginning of the cycle, and call
      the reorder2 hook in the middle of the cycle.  */
@@ -4077,7 +4078,7 @@ invoke_reorder_hooks (fence_t fence)
           if (pipelining_p)
             ++ready.n_ready;

-          ran_hook = true;
+          *pran_hook = true;
         }
       else
         /* Initialize can_issue_more for variable_issue.  */
@@ -4106,14 +4107,14 @@ invoke_reorder_hooks (fence_t fence)
             ++ready.n_ready;
         }

-      ran_hook = true;
+      *pran_hook = true;
     }
   else
     issue_more = FENCE_ISSUE_MORE (fence);

   /* Ensure that ready list and vec_av_set are in line with each other,
      i.e. vec_av_set[i] == ready_element (&ready, i).  */
-  if (issue_more && ran_hook)
+  if (issue_more && *pran_hook)
     {
       int i, j, n;
       rtx *arr = ready.vec;
@@ -4313,7 +4314,7 @@ get_expr_cost (expr_t expr, fence_t fence)
 /* Find the best insn for scheduling, either via max_issue or just take
    the most prioritized available.  */
 static int
-choose_best_insn (fence_t fence, int privileged_n, int *index)
+choose_best_insn (fence_t fence, int privileged_n, bool ran_hook, int *index)
 {
   int can_issue = 0;

@@ -4338,6 +4339,8 @@ choose_best_insn (fence_t fence, int privileged_n, int
*index)
          if (get_expr_cost (expr, fence) < 1)
            {
              can_issue = can_issue_more;
+             if (!ran_hook && !can_issue)
+               can_issue = 1;
              *index = i;

              if (sched_verbose >= 2)
@@ -4366,6 +4369,7 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
                 int *pneed_stall)
 {
   expr_t best;
+  bool ran_hook;

   /* Choose the best insn for scheduling via:
      1) sorting the ready list based on priority;
@@ -4376,8 +4380,8 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
     {
       int privileged_n, index;

-      can_issue_more = invoke_reorder_hooks (fence);
-      if (can_issue_more > 0)
+      can_issue_more = invoke_reorder_hooks (fence, &ran_hook);
+      if (can_issue_more > 0 || !ran_hook)
         {
           /* Try choosing the best insn until we find one that is could be
              scheduled due to liveness restrictions on its destination
register.
@@ -4385,7 +4389,7 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
              in the order of their priority.  */
           invoke_dfa_lookahead_guard ();
           privileged_n = calculate_privileged_insns ();
-          can_issue_more = choose_best_insn (fence, privileged_n, &index);
+          can_issue_more = choose_best_insn (fence, privileged_n, ran_hook,
&index);
           if (can_issue_more)
             best = find_expr_for_ready (index, true);
         }
@@ -4402,7 +4406,8 @@ find_best_expr (av_set_t *av_vliw_ptr, blist_t bnds,
fence_t fence,
     {
       can_issue_more = invoke_aftermath_hooks (fence, EXPR_INSN_RTX (best),
                                                can_issue_more);
-      if (can_issue_more == 0)
+      if (targetm.sched.variable_issue
+         && can_issue_more == 0)
         *pneed_stall = 1;
     }

@@ -7046,6 +7051,8 @@ reset_sched_cycles_in_current_ebb (void)
            }

          haifa_clock += i;
+          if (sched_verbose >= 2)
+            sel_print ("haifa clock: %d\n", haifa_clock);
        }
       else
        gcc_assert (haifa_cost == 0);
@@ -7064,6 +7071,7 @@ reset_sched_cycles_in_current_ebb (void)
               {
                 sel_print ("advance_state (dfa_new_cycle)\n");
                 debug_state (curr_state);
+               sel_print ("haifa clock: %d\n", haifa_clock + 1);
               }
           }

@@ -7072,8 +7080,11 @@ reset_sched_cycles_in_current_ebb (void)
          cost = state_transition (curr_state, insn);

           if (sched_verbose >= 2)
-            debug_state (curr_state);
-
+           {
+             sel_print ("scheduled insn %d, clock %d\n", INSN_UID (insn),
+                        haifa_clock + 1);
+              debug_state (curr_state);
+           }
          gcc_assert (cost < 0);
        }



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352


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

* [Bug rtl-optimization/45352] ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058
  2010-08-20 11:14 [Bug rtl-optimization/45352] New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058 zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2010-09-22 15:34 ` abel at gcc dot gnu dot org
@ 2010-09-22 21:54 ` zsojka at seznam dot cz
  5 siblings, 0 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2010-09-22 21:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from zsojka at seznam dot cz  2010-09-22 21:54 -------
Created an attachment (id=21867)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21867&action=view)
another testcase

Thank you for having a look!

I tried your patch, it bootstrapped fine. It fixed uploaded testcases, but some
still ICE:
(r164527 + patch from comment #5, x86_64-linux):

$ gcc -mtune=amdfam10 -O3 -fpeel-loops -fselective-scheduling2
-fsel-sched-pipelining -fPIC pr45352-7.c 
pr45352-7.c: In function 'V_Pass_Avrg_16_C_ref':
pr45352-7.c:16:1: internal compiler error: in
reset_sched_cycles_in_current_ebb, at sel-sched.c:7088
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.gentoo.org/> for instructions.

I don't know how much, if at all, is this related.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45352


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

end of thread, other threads:[~2010-09-22 21:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-20 11:14 [Bug rtl-optimization/45352] New: ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7058 zsojka at seznam dot cz
2010-08-20 11:15 ` [Bug rtl-optimization/45352] " zsojka at seznam dot cz
2010-08-22 17:15 ` zsojka at seznam dot cz
2010-09-20 18:00 ` zsojka at seznam dot cz
2010-09-22 14:29 ` abel at gcc dot gnu dot org
2010-09-22 15:34 ` abel at gcc dot gnu dot org
2010-09-22 21:54 ` zsojka at seznam dot cz

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