[Bug rtl-optimization/88652] sel-sched.c:1545:11: runtime error: index 2 out of bounds for type 'long unsigned int [2]'

2019-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88652

--- Comment #4 from Andrey Belevantsev  ---
(In reply to Richard Biener from comment #3)
> (In reply to Andrey Belevantsev from comment #2)
> > (In reply to Martin Liška from comment #1)
> > > Any progress on this please?
> > 
> > Maybe a stupid question, but how do I debug this
> > If I read that source line correctly, we're just assuming that for a
> > HARD_REG_SET set and a (regno, mode) pair we can always have enough space in
> > the set for regno, regno + 1, ..., regno + hard_regno_nregs (regno, mode) -
> > 1.  Is that not true anymore?
> 
> I suppose place in a gcc_assert (regno + i < FIRST_PSEUDO_REGISTER) and have
> it
> assert?

Looks like you're right :)  I'll fix that, then.

> 
> I don't see where the code checks that regno is a hard register.  With 
> the following I get
> 
> during RTL pass: sched1
> pr87759.c:39:1: internal compiler error: in verify_target_availability, at
> sel-sched.c:1545
>39 | }
>   | ^
> 0x110f7c3 verify_target_availability
> /space/rguenther/src/svn/trunk2/gcc/sel-sched.c:1545
> 0x110fc31 find_best_reg_for_expr
> /space/rguenther/src/svn/trunk2/gcc/sel-sched.c:1680
> 0x11147e9 fill_vec_av_set
> /space/rguenther/src/svn/trunk2/gcc/sel-sched.c:3800
> 0x1114fea fill_ready_list
> ...
> 
> Index: gcc/sel-sched.c
> ===
> --- gcc/sel-sched.c (revision 269832)
> +++ gcc/sel-sched.c (working copy)
> @@ -1542,6 +1542,7 @@ verify_target_availability (expr_t expr,
>  {
>if (bitmap_bit_p (used_regs, regno + i))
>  live_available = false;
> +  gcc_assert (regno + i < FIRST_PSEUDO_REGISTER);
>if (TEST_HARD_REG_BIT (reg_rename_p->unavailable_hard_regs, regno +
> i))
>  hard_available = false;
>  }
> 
> (gdb) p regno
> $1 = 158

[Bug rtl-optimization/88652] sel-sched.c:1545:11: runtime error: index 2 out of bounds for type 'long unsigned int [2]'

2019-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88652

Andrey Belevantsev  changed:

   What|Removed |Added

 CC||abel at gcc dot gnu.org

--- Comment #2 from Andrey Belevantsev  ---
(In reply to Martin Liška from comment #1)
> Any progress on this please?

Maybe a stupid question, but how do I debug this
If I read that source line correctly, we're just assuming that for a
HARD_REG_SET set and a (regno, mode) pair we can always have enough space in
the set for regno, regno + 1, ..., regno + hard_regno_nregs (regno, mode) - 1. 
Is that not true anymore?

[Bug rtl-optimization/85528] ICE in code_motion_process_successors, at sel-sched.c:6403

2019-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85528

Andrey Belevantsev  changed:

   What|Removed |Added

 CC||abel at gcc dot gnu.org

--- Comment #1 from Andrey Belevantsev  ---
Doesn't ICE for me at r259563 checkout -- anything else needed?

[Bug rtl-optimization/85412] [8/9 Regression] ICE in put_TImodes, at sel-sched.c:7191

2019-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85412

--- Comment #10 from Andrey Belevantsev  ---
(In reply to Arseny Solokha from comment #9)
> (In reply to Andrey Belevantsev from comment #8)
> > trunk doesn't
> > ICE for me.
> 
> I don't have a good testcase at hand (it's just a matter of time, though),
> but at least the following snippet makes the current trunk ICE:
> 
>   subroutine kc (IX, L4, PQ)
> 
>   integer VT, DK, L4, IX, F0
>   real PQ (L4, L4)
> 
>   F0 = VT
> 
>  0010 do VT = 1, 2
>   end do
> 
>   if (IX .eq. 0) go to 0020
> 
>   do VT = 1, L4
>   end do
> 
>   go to 0010
> 
>  0020 do VT = 1, L4
>  if (VT .ge. 0 .and. VT .le. F0) go to 0030
> 
>  do DK = VT, L4
> PQ (VT, DK) = 0.0
>  end do
>  0030 end do
> 
>   return
>   end
> 
> % powerpc-e300c3-linux-gnu-gfortran-9.0.0-alpha20190317 -m32 -mcpu=970 -O1
> -fschedule-insns2 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
> -fselective-scheduling2 -ftree-parallelize-loops=2 --param
> selsched-max-sched-times=3 -c eowqbvfn.f

Is it easy for you to check that the above patch fixes also your testcase?

[Bug rtl-optimization/85876] ICE in move_op_ascend, at sel-sched.c:6164

2019-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85876

--- Comment #1 from Andrey Belevantsev  ---
This is caused by the overeager fix of PR 48235.  We're unwinding the
first_insn variable (the border to which we step backwards in code motion) too
far so it gets beyond the original fence, which happens to be mid-block instead
of bb head.  Fixed as below.  Alexander, do you remember anything else about
that PR (e.g. I think there was a code to unwind the fence back to account for
the unscheduled instructions, but this is not it).

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 315f2c0c0ab..6116e43f998 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -6437,7 +6437,7 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops,
ilist_t path,
 {
   expr_t expr = NULL;
   basic_block bb = BLOCK_FOR_INSN (insn);
-  insn_t first_insn, bb_tail, before_first;
+  insn_t first_insn, original_insn, bb_tail, before_first;
   bool removed_last_insn = false;

   if (sched_verbose >= 6)
@@ -6521,7 +6521,7 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops,
ilist_t path,
   /* It is enough to place only heads and tails of visited basic blocks into
  the PATH.  */
   ilist_add (, insn);
-  first_insn = insn;
+  first_insn = original_insn = insn;
   bb_tail = sel_bb_end (bb);

   /* Descend the basic block in search of the original expr; this part
@@ -6628,6 +6628,8 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops,
ilist_t path,
 {
   insn = sel_bb_end (bb);
   first_insn = sel_bb_head (bb);
+ if (first_insn != original_insn)
+   first_insn = original_insn;
 }

   /* Remove bb tail from path.  */

[Bug rtl-optimization/85876] ICE in move_op_ascend, at sel-sched.c:6164

2019-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85876

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2019-03-21
 CC||abel at gcc dot gnu.org,
   ||amonakov at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org
 Ever confirmed|0   |1

[Bug rtl-optimization/85412] [8/9 Regression] ICE in put_TImodes, at sel-sched.c:7191

2019-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85412

--- Comment #8 from Andrey Belevantsev  ---
Sigh.  We set reset_sched_cycles_p to pipelining_p after the conditional, but
we have missed that in sel_sched_region_1 pipelining_p will be set to false. 
So that initial patch should have the following hunk instead:

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 315f2c0c0ab..29d9abd7200 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -7648,11 +7648,11 @@ sel_sched_region (int rgn)
   /* Schedule always selecting the next insn to make the correct data
 for bundling or other later passes.  */
   pipelining_p = false;
+  reset_sched_cycles_p = false;
   force_next_insn = 1;
   sel_sched_region_1 ();
   force_next_insn = 0;
 }
-  reset_sched_cycles_p = pipelining_p;
   sel_region_finish (reset_sched_cycles_p);
 }

I've checked that it fixes the ICE on the original revision, trunk doesn't ICE
for me.

[Bug rtl-optimization/86928] ICE in compute_live, at sel-sched.c:3097

2019-03-20 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86928

--- Comment #3 from Andrey Belevantsev  ---
(In reply to Andrey Belevantsev from comment #2)
> We're not somehow updating liveness information at all times when we change
> control flow.  E.g. we do update liveness in sel_split_edge, but not in
> sel_redirect_edge_and_branch{,force} hooks, when we're making a new jump and
> resetting liveness on the bb it ended up in.  This leaves us with the
> unknown lv set, and later breaks when we're computing liveness from the
> other region and come to this block, as we're assuming that other regions
> always have correct liveness.
> 
> Fixed with the below patch but I'm not completely sure it fully makes sense
> -- Alexander, thoughts?
> 
> diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
> index 85ff5bd3eb4..c399c1117a3 100644
> --- a/gcc/sel-sched-ir.c
> +++ b/gcc/sel-sched-ir.c
> @@ -5642,6 +5642,8 @@ sel_redirect_edge_and_branch_force (edge e,
> basic_block to)
>recompute_dominator (CDI_DOMINATORS, to));
>set_immediate_dominator (CDI_DOMINATORS, orig_dest,
>recompute_dominator (CDI_DOMINATORS, orig_dest));
> +  if (jump == sel_bb_head (BLOCK_FOR_INSN (jump)))
> +compute_live (jump);
>  }
> 
>  /* A wrapper for redirect_edge_and_branch.  Return TRUE if blocks connected
> by
> @@ -5702,6 +5704,8 @@ sel_redirect_edge_and_branch (edge e, basic_block to)
>set_immediate_dominator (CDI_DOMINATORS, orig_dest,
> recompute_dominator (CDI_DOMINATORS,
> orig_dest));
>  }
> +  if (jump == sel_bb_head (BLOCK_FOR_INSN (jump)))
> +compute_live (jump);
>return recompute_toporder_p;
>  }

It looks like the routine that creates recovery blocks also updates liveness,
so I'm now more confident with the patch, but I'd still like to hear
Alexander's opinion.  Of course, it should really be sel_bb_head_p (jump)
instead of that clumsy condition I've wrote.

[Bug rtl-optimization/86928] ICE in compute_live, at sel-sched.c:3097

2019-03-20 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86928

Andrey Belevantsev  changed:

   What|Removed |Added

 CC||abel at gcc dot gnu.org,
   ||amonakov at gcc dot gnu.org

--- Comment #2 from Andrey Belevantsev  ---
We're not somehow updating liveness information at all times when we change
control flow.  E.g. we do update liveness in sel_split_edge, but not in
sel_redirect_edge_and_branch{,force} hooks, when we're making a new jump and
resetting liveness on the bb it ended up in.  This leaves us with the unknown
lv set, and later breaks when we're computing liveness from the other region
and come to this block, as we're assuming that other regions always have
correct liveness.

Fixed with the below patch but I'm not completely sure it fully makes sense --
Alexander, thoughts?

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 85ff5bd3eb4..c399c1117a3 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -5642,6 +5642,8 @@ sel_redirect_edge_and_branch_force (edge e, basic_block
to)
   recompute_dominator (CDI_DOMINATORS, to));
   set_immediate_dominator (CDI_DOMINATORS, orig_dest,
   recompute_dominator (CDI_DOMINATORS, orig_dest));
+  if (jump == sel_bb_head (BLOCK_FOR_INSN (jump)))
+compute_live (jump);
 }

 /* A wrapper for redirect_edge_and_branch.  Return TRUE if blocks connected by
@@ -5702,6 +5704,8 @@ sel_redirect_edge_and_branch (edge e, basic_block to)
   set_immediate_dominator (CDI_DOMINATORS, orig_dest,
recompute_dominator (CDI_DOMINATORS,
orig_dest));
 }
+  if (jump == sel_bb_head (BLOCK_FOR_INSN (jump)))
+compute_live (jump);
   return recompute_toporder_p;
 }

[Bug rtl-optimization/84842] [7/8/9 Regression] ICE in verify_target_availability, at sel-sched.c:1569

2019-03-18 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84842

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #17 from Andrey Belevantsev  ---
Created attachment 45991
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45991=edit
tentative patch

This is a rather complex situation.  The assert checks that we have correctly
calculated the availability bit, which tells us that the original destination
insn register is free to use for the code motion.  In our case we have merged
several insns into one expression, and the resulting bit came from the variant
when it was really unavailable; however, during looking for the original insn
in the flow graph, we have been looking for really another variant, thus we
didn't get to the place with the first variant and initially unavailable stuff.

It can be fixed with the rather crude attached patch that somewhat relaxes the
assert.  While doing this, we need to mark the above situation has actually
occurred, but we don't know which of the move_op or find_best_regs we're doing
there -- Alexander, maybe you could come up with something better.

[Bug rtl-optimization/84206] ICE in get_all_loop_exits, at sel-sched-ir.h:1138

2019-03-18 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84206

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||abel at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #1 from Andrey Belevantsev  ---
The code that fails here tries to skip the inner loop's body to get to the next
blocks in the outer loop.  The failing assert is designed to check that, if
we've skipped an inner loop, and we have hit an empty block, then this block
could only be the preheader of the next inner loop, whose body we should also
skip.  In the testcase the block is definitely a preheader, but not for the
inner loop; it starts the very outer loop we're working with in the first
place.

Fixed by adding code to check that we're not going in the outer direction of
the loop hierarchy via checking depths like below.

diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h
index b5ec63cf94d..3943eee3468 100644
--- a/gcc/sel-sched-ir.h
+++ b/gcc/sel-sched-ir.h
@@ -1144,6 +1144,7 @@ get_all_loop_exits (basic_block bb)
   struct loop *this_loop;
   struct loop *pred_loop = NULL;
   int i;
+  unsigned this_depth;
   edge e;

   for (this_loop = bb->loop_father;
@@ -1155,11 +1156,14 @@ get_all_loop_exits (basic_block bb)
   gcc_assert (this_loop != NULL);

   exits = get_loop_exit_edges_unique_dests (this_loop);
+  this_depth = loop_depth (this_loop);

-  /* Traverse all loop headers.  */
+  /* Traverse all loop headers.  Be careful not to go back
+to the outer loop's header (see PR 84206).  */
   for (i = 0; exits.iterate (i, ); i++)
-   if (in_current_region_p (e->dest)
-   || inner_loop_header_p (e->dest))
+   if ((in_current_region_p (e->dest)
+|| (inner_loop_header_p (e->dest)))
+   && loop_depth (e->dest->loop_father) >= this_depth)
  {
vec next_exits = get_all_loop_exits (e->dest);

[Bug rtl-optimization/87273] [8/9 Regression] ICE in merge_fences, at sel-sched-ir.c:708

2019-03-18 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87273

--- Comment #5 from Andrey Belevantsev  ---
In this PR we're pipelining a loop with a conditional that has lots of code on
the left arm and just a few blocks on the right arm.  In this situation it is
natural for the right scheduling fence to end up fast below the conditional (on
its postdominating block), and for the left fences to get there much later.

When this happens, we merge the fences, and in that code there is an assert
that basically says (as far as I remember, this is the code that goes back to
the original sel-sched commit) that, if we're merging two fences and one came
from a fallthrough block, then another is supposed to come from the second
block.  But it is not the case here, because the left fence (the later one) has
already scheduled an insn from the code that was processed by the right fence
(the earlier one), and this insn therefore has moved from block 7 of the
earlier fence to block 6 of the later one.  So both fences are saying that
previously they have scheduled some code from the same block 6, and that fires
the assert.

As I said, the situation is completely normal and I don't see the point in
keeping the assert anymore.  So just removing it fixes the issue as with the
below patch.

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index e8e508ef692..a6583017c9d 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -703,11 +703,6 @@ merge_fences (fence_t f, insn_t insn,
   else
 if (candidate->src == BLOCK_FOR_INSN (last_scheduled_insn))
   {
-/* Would be weird if same insn is successor of several fallthrough
-   edges.  */
-gcc_assert (BLOCK_FOR_INSN (insn)->prev_bb
-!= BLOCK_FOR_INSN (last_scheduled_insn_old));
-
 state_free (FENCE_STATE (f));
 FENCE_STATE (f) = state;

[Bug rtl-optimization/89676] [7/8/9 Regression] Redundant moves for long long shift on 32bit x86

2019-03-18 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89676

--- Comment #3 from Andrey Belevantsev  ---
Author: abel
Date: Mon Mar 18 07:51:06 2019
New Revision: 269751

URL: https://gcc.gnu.org/viewcvs?rev=269751=gcc=rev
Log:
PR middle-end/89676
* sel-sched.c (compute_av_set_at_bb_end): When we have an ineligible
successor, use NULL as its av set.


Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched.c

[Bug middle-end/86979] [9 Regression] ICE: in maybe_record_trace_start, at dwarf2cfi.c:2348 with -m32 on darwin

2019-03-15 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86979

--- Comment #17 from Andrey Belevantsev  ---
(In reply to Martin Liška from comment #16)
> Andrey: Can you please send a patch for it into gcc-patches mailing list?

Sure, I've sent the patch.

[Bug middle-end/86979] [9 Regression] ICE: in maybe_record_trace_start, at dwarf2cfi.c:2348 with -m32 on darwin

2019-03-01 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86979

--- Comment #13 from Andrey Belevantsev  ---
So now I understand, finally. We move up an sp decrement and are supposed to
check that sp is available on the paths that are not touched by the move. There
are several successors of the move target block so the checking code is special
(and was the same there since day 1 of sel-sched).  The code checks, for each
successor block, the expressions that are present in the merged availability
set at the end of target block but are not present in the successor block set. 
Such expressions are marked as having unavailable target registers.

In this case for one successor block there happens to be another fence, and
that fence set has the copy of the sp decrement instruction. So it is not
detected as being unavailable. What _should_ have happened is that the
successor block with another fence should have been marked as ineligible
successor (we don't move along that path), so the av set against which we're
checking has to be NULL.  The fix is just to have that properly accounted for.

The patch is below, and I wouldn't be surprised if it fixes more PRs than this
one.

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 315f2c0c0ab..2053694b196 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -2820,10 +2820,12 @@ compute_av_set_at_bb_end (insn_t insn, ilist_t p, int
ws)
 FOR_EACH_VEC_ELT (sinfo->succs_ok, is, succ)
   {
 basic_block succ_bb = BLOCK_FOR_INSN (succ);
+   av_set_t av_succ = (is_ineligible_successor (succ, p)
+   ? NULL
+   : BB_AV_SET (succ_bb));

 gcc_assert (BB_LV_SET_VALID_P (succ_bb));
-mark_unavailable_targets (av1, BB_AV_SET (succ_bb),
-  BB_LV_SET (succ_bb));
+mark_unavailable_targets (av1, av_succ, BB_LV_SET (succ_bb));
   }

   /* Finally, check liveness restrictions on paths leaving the region.  */

[Bug middle-end/86979] [9 Regression] ICE: in maybe_record_trace_start, at dwarf2cfi.c:2348 with -m32 on darwin

2019-03-01 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86979

--- Comment #12 from Andrey Belevantsev  ---
(In reply to Jakub Jelinek from comment #11)
> Any progress on this?

I know what happens but am not fully sure as of why. The sp register should not
be available for the problematic move, so I'm figuring out why we got this
wrong.

[Bug rtl-optimization/88879] [9 Regression] ICE in sel_target_adjust_priority, at sel-sched.c:3332

2019-01-25 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88879

--- Comment #6 from Andrey Belevantsev  ---
(In reply to Alexander Monakov from comment #4)
> Thanks. This broke when the patch for PR 85458 was applied, and Andreas
> raised it on the gcc-patches thread:
> https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00128.html
> 
> Soon after that, the HP-PA adjust_priority target hook was removed, making
> the sel-sched change unnecessary. Therefore, my recommendation is to revert
> the sel-sched patch, or remove the new assert as Andreas has suggested.
> Andrey, which approach would you prefer?
> 
> It's also possible to implement Jeff's suggestion and clamp negative
> priorities to zero in create_speculation_check, but that may turn out to be
> insufficient if there is other code producing negative priority values.

I would try to avoid negative priorities if possible. It looks they could only
come from the adjust_priority hook or from create_speculation_check.  If the
former is now impossible then maybe just fix the latter?

[Bug middle-end/86979] [9 Regression] ICE: in maybe_record_trace_start, at dwarf2cfi.c:2348 with -m32 on darwin

2019-01-08 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86979

--- Comment #9 from Andrey Belevantsev  ---
Eric, thanks for pointing me out to the old PR.  From that and what I could
understand here from the sched logs, it's not clear to me how to correctly
clone REG_ARGS_SIZE insns, so the safest patch of forbidding that completely
works fine.  Alexander, if you have an idea of what can be checked in the
scheduler to relax that, please let me know, I'm happy to implement that.

The safe patch is just like this:

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index 85ff5bd3eb4..05d7eaa72c7 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -3024,6 +3024,10 @@ init_global_and_expr_for_insn (insn_t insn)
   else
 force_unique_p = false;

+/* Do not copy REG_ARGS_SIZE insns as we fail to adjust them properly
(PR86979).  */
+if (find_reg_note (insn, REG_ARGS_SIZE, NULL))
+  force_unique_p = true;
+
 if (targetm.sched.get_insn_spec_ds)
   {
spec_done_ds = targetm.sched.get_insn_spec_ds (insn);

[Bug rtl-optimization/87273] [8/9 Regression] ICE in merge_fences, at sel-sched-ir.c:708

2018-12-20 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87273

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #3 from Andrey Belevantsev  ---
Sure. I have somewhat free month now so I'm going over sel-sched bugs.

[Bug middle-end/86979] [9 Regression] ICE: in maybe_record_trace_start, at dwarf2cfi.c:2348 with -m32 on darwin

2018-12-11 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86979

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #7 from Andrey Belevantsev  ---
Looks like mine.

[Bug rtl-optimization/84842] [7/8 Regression] ICE in verify_target_availability, at sel-sched.c:1569

2018-04-24 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84842

--- Comment #12 from Andrey Belevantsev  ---
(In reply to Alexander Monakov from comment #11)
> Thanks, I managed to reproduce it. The unusual thing here is hardreg 63
> being considered call-clobbered in its reg_raw_mode=TImode but not narrower
> modes. We have
> 
> (insn 97 29 98 4 (set (reg:DI 63 31 [160])
> (unspec:DI [
> (reg:SI 29 29)
> ] UNSPEC_LFIWAX)) "pr84842.i":5 344 {lfiwax}
>  (expr_list:REG_DEAD (reg:SI 29 29)
> (nil)))
> 
> and sched-deps noting a REG_DEP_OUTPUT dependence on regno 63 against a
> preceding call insn according to rs6000_hard_regno_call_part_clobbered
> (regno=63, mode=E_TImode). I assume what the backend in conveying there is
> that only the low part of the register will be preserved by callees.
> 
> However, when we move up the instruction we don't have a dependence. The LHS
> is DImode, so that seems correct as well: sched-deps had a more conservative
> answer because its dependence lists are not separated per mode.
> 
> Andrey, does the above make sense? Can the assert be relaxed?

It does, but I'm not sure how to relax the assert -- it does check that we have
computed consistent data, as can be seen even from this PR.  Maybe we need to
do always more conservative check like sched-deps, or on the contrary, make it
less conservative there (for stage 1)?

[Bug rtl-optimization/85410] ICE in create_block_for_bookkeeping, at sel-sched.c:4563

2018-04-24 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85410

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-04-24
 CC||abel at gcc dot gnu.org,
   ||amonakov at gcc dot gnu.org,
   ||jakub at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Andrey Belevantsev  ---
Confirmed.  We hit an assert saying that the split block (which is supposed to
be empty) doesn't have any bb notes.  But it may have a NOTE_INSN_DELETED now
because there is the code emitting that when the bb only has debug insns.  It
is easy to relax the assert and properly merge bb notes list in this case.

So far so good, but then the df_verify assert hits late in IRA.  It is because
of the code that was added to rotate bb indexes to avoid debug/non-debug
differences around sel-sched.c:4585, there if (MAY_HAVE_DEBUG_INSNS) we do the
long list of sel-sched data structures exchanges but nobody takes care of df
structures.  There I can do a df_bb_refs_record for the changed bbs, but still
the reg_chain structures are bogus and we ICE in df_reg_chain_verify_unmarked. 
At this point I'm unclear what to do, thoughts?

[Bug rtl-optimization/85423] [8 Regression] ICE in code_motion_process_successors, at sel-sched.c:6403

2018-04-23 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85423

--- Comment #5 from Andrey Belevantsev  ---
Author: abel
Date: Mon Apr 23 15:19:06 2018
New Revision: 259563

URL: https://gcc.gnu.org/viewcvs?rev=259563=gcc=rev
Log:
PR rtl-optimization/85423

* sel-sched-ir.c (has_dependence_note_mem_dep): Only discard
dependencies to debug insns when the previous insn is non-debug.

* gcc.dg/pr85423.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr85423.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/85423] [8 Regression] ICE in code_motion_process_successors, at sel-sched.c:6403

2018-04-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85423

Andrey Belevantsev  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #4 from Andrey Belevantsev  ---
Sigh, I've put the condition that was too broad in the previous patch and also
allowed some legitimate dependencies between debug insns (so Alex was kind of
right when he expressed his concern).  I'm testing the following after checking
that all of the previous PRs and this one passes:

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index ee970522890..85ff5bd3eb4 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -3308,7 +3308,7 @@ has_dependence_note_dep (insn_t pro, ds_t ds
ATTRIBUTE_UNUSED)
  that a bookkeeping copy should be movable as the original insn.
  Detect that here and allow that movement if we allowed it before
  in the first place.  */
-  if (DEBUG_INSN_P (real_con)
+  if (DEBUG_INSN_P (real_con) && !DEBUG_INSN_P (real_pro)
   && INSN_UID (NEXT_INSN (pro)) == INSN_UID (real_con))
 return;

[Bug rtl-optimization/85409] [8 Regression] ICE in alloc_succs_info, at sel-sched-ir.c:4730

2018-04-16 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85409

--- Comment #3 from Andrey Belevantsev  ---
This one is cool.  We hit an assert saying we cannot hold of successor info
anymore.  The succs vector size is of max_ws (maximum lookahead) + 1, but guess
what, there's a lot of debug insns and these are not counted against windowsize
when computing the availability set because of:

2949   if (DEBUG_INSN_P (last_insn))
2950 continue;
2951
2952   if (end_ws > max_ws)
2953 {
2954   /* We can reach max lookahead size at bb_header, so clean av_set
2955  first.  */
2956   INSN_WS_LEVEL (last_insn) = global_level;
2957
2958   if (sched_verbose >= 6)
2959 sel_print ("Insn %d is beyond the software lookahead window
size\n",
2960INSN_UID (last_insn));
2961   break;
2962 }
2963
2964   end_ws++;

Thoughts?

[Bug rtl-optimization/85408] ICE in patch_jump_insn, at cfgrtl.c:1271

2018-04-16 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85408

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-04-16
 CC||abel at gcc dot gnu.org,
   ||amonakov at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Andrey Belevantsev  ---
We fail when trying to call cleanup_cfg.  The edge we're trying to redirect
looks like an indirect jump so I'm not sure why it's not a computed_jump_p
(tablejump?)

(gdb) p insn
$11 = (rtx_insn *) 0x7673c240
(gdb) pr
warning: Expression is not an assignment (and might have no effect)
(jump_insn/j 93 92 86 13 (set (pc)
(reg:SI 160)) 628 {*indirect_jumpsi}
 (expr_list:REG_DEAD (reg:SI 160)
(nil))
 -> 17)
(gdb) p computed_jump_p (insn)
$12 = 0

[Bug rtl-optimization/83852] [6/7/8 Regression] ICE in sel_redirect_edge_and_branch, at sel-sched-ir.c:5644 on 32-bit BE powerpc targets

2018-04-13 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83852

--- Comment #3 from Andrey Belevantsev  ---
Author: abel
Date: Fri Apr 13 10:24:02 2018
New Revision: 259373

URL: https://gcc.gnu.org/viewcvs?rev=259373=gcc=rev
Log:
PR rtl-optimization/83852
* gcc.dg/pr83852.c: New testcase.


Added:
trunk/gcc/testsuite/gcc.dg/pr83852.c
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/84842] ICE in verify_target_availability, at sel-sched.c:1569

2018-04-13 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84842

Andrey Belevantsev  changed:

   What|Removed |Added

 CC||abel at gcc dot gnu.org

--- Comment #1 from Andrey Belevantsev  ---
I can't reproduce it even with the same revision and rs6000.c:unavailable_cpu
set to 0 (to allow me choose power8).  Is there anything else I can do?

[Bug rtl-optimization/83852] [6/7/8 Regression] ICE in sel_redirect_edge_and_branch, at sel-sched-ir.c:5644 on 32-bit BE powerpc targets

2018-04-13 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83852

Andrey Belevantsev  changed:

   What|Removed |Added

 CC||abel at gcc dot gnu.org

--- Comment #2 from Andrey Belevantsev  ---
This is fixed by the patch for PR83962.  I will close this PR after adding the
testcase.

[Bug testsuite/85306] [8 regression] Test case g++.dg/pr80463.C fails in r259231

2018-04-10 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85306

--- Comment #1 from Andrey Belevantsev  ---
Jakub has added -w to the test options in r259249.  I'm sorry I have missed
this one when committing.  If this works for you now, I think you can close the
PR.

[Bug rtl-optimization/83972] ICE in code_motion_process_successors, at sel-sched.c:6398

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83972

Andrey Belevantsev  changed:

   What|Removed |Added

  Known to work||8.0
  Known to fail|8.0 |

--- Comment #5 from Andrey Belevantsev  ---
Fixed on trunk.

[Bug rtl-optimization/85099] [meta-bug] selective scheduling issues

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85099
Bug 85099 depends on bug 83480, which changed state.

Bug 83480 Summary: ICE in create_block_for_bookkeeping, at sel-sched.c:4557
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83480

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

[Bug debug/83480] ICE in create_block_for_bookkeeping, at sel-sched.c:4557

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83480

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #15 from Andrey Belevantsev  ---
Fixed on trunk.

[Bug rtl-optimization/83972] ICE in code_motion_process_successors, at sel-sched.c:6398

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83972

--- Comment #4 from Andrey Belevantsev  ---
Author: abel
Date: Mon Apr  9 10:19:50 2018
New Revision: 259231

URL: https://gcc.gnu.org/viewcvs?rev=259231=gcc=rev
Log:
   PR rtl-optimization/80463
   PR rtl-optimization/83972
   PR rtl-optimization/83480

   * sel-sched-ir.c (has_dependence_note_mem_dep): Take into account the
   correct producer for the insn.
   (tidy_control_flow): Fixup seqnos in case of debug insns.

   * gcc.dg/pr80463.c: New test.
   * g++.dg/pr80463.C: Likewise.
   * gcc.dg/pr83972.c: Likewise.


Added:
trunk/gcc/testsuite/g++.dg/pr80463.C
trunk/gcc/testsuite/gcc.dg/pr80463.c
trunk/gcc/testsuite/gcc.dg/pr83972.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug debug/83480] ICE in create_block_for_bookkeeping, at sel-sched.c:4557

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83480

--- Comment #14 from Andrey Belevantsev  ---
Author: abel
Date: Mon Apr  9 10:19:50 2018
New Revision: 259231

URL: https://gcc.gnu.org/viewcvs?rev=259231=gcc=rev
Log:
   PR rtl-optimization/80463
   PR rtl-optimization/83972
   PR rtl-optimization/83480

   * sel-sched-ir.c (has_dependence_note_mem_dep): Take into account the
   correct producer for the insn.
   (tidy_control_flow): Fixup seqnos in case of debug insns.

   * gcc.dg/pr80463.c: New test.
   * g++.dg/pr80463.C: Likewise.
   * gcc.dg/pr83972.c: Likewise.


Added:
trunk/gcc/testsuite/g++.dg/pr80463.C
trunk/gcc/testsuite/gcc.dg/pr80463.c
trunk/gcc/testsuite/gcc.dg/pr83972.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/80463] [6/7/8 Regression] ICE with -fselective-scheduling2 and -fvar-tracking-assignments

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80463

--- Comment #15 from Andrey Belevantsev  ---
Author: abel
Date: Mon Apr  9 10:19:50 2018
New Revision: 259231

URL: https://gcc.gnu.org/viewcvs?rev=259231=gcc=rev
Log:
   PR rtl-optimization/80463
   PR rtl-optimization/83972
   PR rtl-optimization/83480

   * sel-sched-ir.c (has_dependence_note_mem_dep): Take into account the
   correct producer for the insn.
   (tidy_control_flow): Fixup seqnos in case of debug insns.

   * gcc.dg/pr80463.c: New test.
   * g++.dg/pr80463.C: Likewise.
   * gcc.dg/pr83972.c: Likewise.


Added:
trunk/gcc/testsuite/g++.dg/pr80463.C
trunk/gcc/testsuite/gcc.dg/pr80463.c
trunk/gcc/testsuite/gcc.dg/pr83972.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/83913] [6/7/8 Regression] Compile time and memory hog w/ selective scheduling

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83913

--- Comment #4 from Andrey Belevantsev  ---
Author: abel
Date: Mon Apr  9 09:42:25 2018
New Revision: 259230

URL: https://gcc.gnu.org/viewcvs?rev=259230=gcc=rev
Log:
   PR rtl-optimization/83913

   * sel-sched-ir.c (merge_expr_data): Choose the middle between two
   different sched-times when merging exprs.

   * gcc.dg/pr83913.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr83913.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/83962] [6/7/8 Regression] ICE: verify_flow_info failed (too many outgoing branch edges from bb 8)

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83962

--- Comment #4 from Andrey Belevantsev  ---
Author: abel
Date: Mon Apr  9 09:16:34 2018
New Revision: 259229

URL: https://gcc.gnu.org/viewcvs?rev=259229=gcc=rev
Log:
   PR rtl-optimization/83962

   * sel-sched-ir.c (tidy_control_flow): Correct the order in which we call
   tidy_fallthru_edge and tidy_control_flow.

   * gcc.dg/pr83962.c: New test.

Added:
trunk/gcc/testsuite/gcc.dg/pr83962.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/83530] [7/8 Regression] ICE in reset_sched_cycles_in_current_ebb, at sel-sched.c:7150

2018-04-09 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83530

--- Comment #12 from Andrey Belevantsev  ---
Author: abel
Date: Mon Apr  9 09:08:28 2018
New Revision: 259228

URL: https://gcc.gnu.org/viewcvs?rev=259228=gcc=rev
Log:
   PR rtl-optimization/83530

   * sel-sched.c (force_next_insn): New global variable.
   (remove_insn_for_debug): When force_next_insn is true, also leave only
   next insn in the ready list.
   (sel_sched_region): When the region wasn't scheduled, make another pass
   over it with force_next_insn set to 1.

   * gcc.dg/pr83530.c: New test.


Added:
trunk/gcc/testsuite/gcc.dg/pr83530.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/84872] [8 Regression] ICE in create_preheader, at cfgloopmanip.c:1536

2018-04-06 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84872

--- Comment #2 from Andrey Belevantsev  ---
Nothing to do with sel-sched as is :)  We're just asking to make loop
preheaders that will be fallthrough blocks.  The loop has blocks 5 and 6 (6->5
is a loop latch), and the pred block is block 7 but there's block 4 between 7
and 5 like this:

(note 52 53 24 7 [bb 7] NOTE_INSN_BASIC_BLOCK)
<...>
(jump_insn/j 25 24 38 7 (set (pc)
(if_then_else (le (reg:CCNO 17 flags)
(const_int 0 [0]))
(label_ref:DI 18)
(pc))) "../prs/pr84872.c":13 682 {*jcc}
 (expr_list:REG_DEAD (reg:CCNO 17 flags)
(nil))
 -> 18)
(note 38 25 48 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(jump_insn 48 38 49 4 (set (pc)
(label_ref 22)) -1
 (nil)
 -> 22)
(barrier 49 48 18)
(code_label 18 49 16 5 3 (nil) [2 uses])
(note 16 18 17 5 [bb 5] NOTE_INSN_BASIC_BLOCK)
<...>

The create_preheader code asks to split the 7->5 edge and we happily make block
9:

(note 52 53 24 7 [bb 7] NOTE_INSN_BASIC_BLOCK)
<...>
(jump_insn/j 25 24 38 7 (set (pc)
(if_then_else (le (reg:CCNO 17 flags)
(const_int 0 [0]))
(label_ref:DI 18)
(pc))) "../prs/pr84872.c":13 682 {*jcc}
 (expr_list:REG_DEAD (reg:CCNO 17 flags)
(nil))
 -> 18)
(note 38 25 48 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(jump_insn 48 38 49 4 (set (pc)
(label_ref 22)) -1
 (nil)
 -> 22)
(barrier 49 48 60)
(note 60 49 18 9 [bb 9] NOTE_INSN_BASIC_BLOCK)
(code_label 18 60 16 5 3 (nil) [2 uses])
(note 16 18 17 5 [bb 5] NOTE_INSN_BASIC_BLOCK)

But then we hit the "can't allow a region crossing edge to be fallthrough"
conditional in rtl_split_edge, the edge is forced to be nonfallthru and the
create_preheader assert fires.

The below of course "fixes" it so we need to do something with the bb
partitioning rules or something.  Any pass that will ask for fallthrough
preheaders after bb reordering between partitions has been completed will blow
up.

diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index fd095ac59ed..ed6b0c11802 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -1901,7 +1901,7 @@ rtl_split_edge (edge edge_in)

   /* Can't allow a region crossing edge to be fallthrough.  */
   if (BB_PARTITION (bb) != BB_PARTITION (edge_in->dest)
-  && edge_in->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
+  && edge_in->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && false)
 {
   new_bb = force_nonfallthru (single_succ_edge (bb));
   gcc_assert (!new_bb);

[Bug rtl-optimization/83530] [7/8 Regression] ICE in reset_sched_cycles_in_current_ebb, at sel-sched.c:7150

2018-02-15 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83530

--- Comment #11 from Andrey Belevantsev  ---
I've made a deeper comparison with what the Haifa does.  We diverge because the
loop in reset_sched_cycles only models resource stalls and relies on the
information from the earlier scheduling pass for data stalls.  However, there
is no such information in this case as the loop was scheduled with the modulo
scheduler.

I need to think more on how this was supposed to work.  (Maybe the issue just
wasn't caught before just because we almost have no testing of modulo sched +
selective scheduler combination.  There is a single test of pr42388.)  If we
indeed do also need to model data stalls, it is easy to piggyback on the
sel-sched infrastructure in this case to make the scheduling but just to select
the next insn always for the BB_DISABLE_SCHEDULE blocks.  I've verified that
such a patch works.  Similarly, adding -freschedule-modulo-scheduled-blocks
makes the ICE disappear.

The initial patch that needs to be cleaned up (if the above is correct) is
like:

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 76092f9587a..fcdc2e7102e 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -5004,12 +5013,14 @@ remove_temp_moveop_nops (bool full_tidying)
distinguishing between bookkeeping copies and original insns.  */
 static int max_uid_before_move_op = 0;

+static int force_next_insn = 0;
+
 /* Remove from AV_VLIW_P all instructions but next when debug counter
tells us so.  Next instruction is fetched from BNDS.  */
 static void
 remove_insns_for_debug (blist_t bnds, av_set_t *av_vliw_p)
 {
-  if (! dbg_cnt (sel_sched_insn_cnt))
+  if (! dbg_cnt (sel_sched_insn_cnt) || force_next_insn)
 /* Leave only the next insn in av_vliw.  */
 {
   av_set_iterator av_it;
@@ -7642,7 +7653,13 @@ sel_sched_region (int rgn)
 sel_sched_region_1 ();
   else
 /* Force initialization of INSN_SCHED_CYCLEs for correct bundling.  */
-reset_sched_cycles_p = true;
+{
+  reset_sched_cycles_p = false;
+  pipelining_p = false;
+  force_next_insn = 1;
+  sel_sched_region_1 ();
+  force_next_insn = 0;
+}

   sel_region_finish (reset_sched_cycles_p);
 }

[Bug rtl-optimization/83530] [8 Regression] ICE in reset_sched_cycles_in_current_ebb, at sel-sched.c:7150

2018-02-07 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83530

--- Comment #8 from Andrey Belevantsev  ---
(In reply to Pat Haugen from comment #7)
> Assuming this is a latent selective scheduling bug since I can reproduce
> with r243865 by adding -fsched-pressure --param sched-pressure-algorithm=2.
> Looking...

I will take a look.  The ICE is within the code that models the scheduling loop
in order to get the proper insn ticks and everything for later MD processing
(it is equivalent to always scheduling the next insn).  Either there is an
issue in that loop that wasn't uncovered anywhere but powerpc or there is some
subtlety in the powerpc cpu model that is triggered there.  It is not very
pleasant to find out and fix usually so it will take time.

[Bug rtl-optimization/83962] [6/7/8 Regression] ICE: verify_flow_info failed (too many outgoing branch edges from bb 8)

2018-02-06 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83962

--- Comment #3 from Andrey Belevantsev  ---
Here we're trying remove a jump to the next block but fail to adjust the
barrier.  This is something that tidy_fallthru_edge would do for us, but we
don't get to the point we can call it, before that the empty block gets merged
to the previous block, so the edge to tidy disappears.  I've made a patch to do
these actions in a more correct order, i.e. fixup the edge from the empty block
first and then dispatch to the code that will do more cleanups.

[Bug debug/83480] [8 Regression] ICE in create_block_for_bookkeeping, at sel-sched.c:4557

2018-01-30 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83480

--- Comment #12 from Andrey Belevantsev  ---
(In reply to Jakub Jelinek from comment #11)
> Not fully fixed yet, the testcase still ICEs with:
> -O2 -g -gstatement-frontiers -fselective-scheduling2 -fsel-sched-pipelining
> -fgcse-sm -floop-parallelize-all -fno-tree-loop-im

I couldn't make testcase from #c2 to ICE with those, so I've checked out the
reported rev. 255766 and reproduced the ICE from that comment.  That one is
fixed with the same patch as for PR 80463 #c3 and PR 83972.

[Bug rtl-optimization/83972] ICE in code_motion_process_successors, at sel-sched.c:6398

2018-01-30 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83972

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2018-01-30
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #3 from Andrey Belevantsev  ---
Thank you for the test.  This is another variant of PR80463 c#3.  I have a
hackish patch that demonstrates the analysis is correct, but I'll need to think
how to fix that cleaner.

[Bug rtl-optimization/83913] [6/7/8 Regression] Compile time and memory hog w/ selective scheduling

2018-01-23 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83913

Andrey Belevantsev  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #3 from Andrey Belevantsev  ---
We've discussed with Alexander about this one.  The simpler fix will be never
pipelining anything of priority 0, as this wouldn't give any benefit.  The
better fix is to make bookkeeping copies within the pipelined region inherit
sched_times -- the number of times this insn was scheduled.  It will not work
for regular scheduling as those new insns have to be scheduled at some point,
but for pipelined regions we're rescheduling blocks with new insns anyways.  So
something like below works, but for that kind of patch I will need testing on
ia64 and it takes time.

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index 76092f9587a..58f4ca4016f 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4773,7 +4773,16 @@ emit_bookkeeping_insn (insn_t place_to_insert, expr_t
c_expr, int new_seqno)
   insn_t new_insn = emit_insn_from_expr_after (c_expr, new_vinsn, new_seqno,
   place_to_insert);

-  INSN_SCHED_TIMES (new_insn) = 0;
+  if (pipelining_p && !sel_is_loop_preheader_p (BLOCK_FOR_INSN
(place_to_insert)))
+{
+  int sched_times = EXPR_SCHED_TIMES (c_expr);
+  if (sched_times < 0)
+   sched_times = 0;
+  INSN_SCHED_TIMES (new_insn) = sched_times;
+}
+  else
+INSN_SCHED_TIMES (new_insn) = 0;
+
   bitmap_set_bit (current_copies, INSN_UID (new_insn));

   return new_insn;

[Bug rtl-optimization/80463] [6/7/8 Regression] ICE with -fselective-scheduling2 and -fvar-tracking-assignments

2018-01-22 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80463

--- Comment #13 from Andrey Belevantsev  ---
(In reply to Andrey Belevantsev from comment #12)
> (In reply to Arseny Solokha from comment #11)
> > How about this one? It makes only trunk gcc ICE, though.
> > 
> > short int t2;
> > int cd, aa, ft;
> > 
> > void
> > dh (void)
> > {
> >   int qs = 0;
> > 
> >   if (t2 < 1)
> > {
> >   int bq = 0;
> > 
> >   while (bq < 1)
> > {
> > }
> > 
> >   while (t2 < 1)
> > {
> >   if (t2 == 0)
> > {
> >   bq = 0;
> >   cd = !!cd;
> > }
> >   else
> > {
> >   bq = 1;
> >   cd = bq > qs;
> > }
> > 
> >   t2 += cd;
> >   bq = (t2 / qs) == bq;
> > 
> >   if (aa != ft)
> > {
> >   qs %= 0;
> >   while (bq != 0)
> > {
> >  ro:
> >   ;
> > }
> > }
> > 
> >   ++t2;
> > }
> > 
> >  ia:
> >   goto ro;
> > }
> > 
> >   goto ia;
> > }
> > 
> > % gcc-8.0.0-alpha20180114 -O2 -fvar-tracking-assignments
> > -fselective-scheduling2 -ftree-loop-vectorize -fnon-call-exceptions
> > -fno-tree-vrp -fno-gcse-lm -fno-tree-loop-im
> > -fno-reorder-blocks-and-partition -fno-reorder-blocks
> > -fno-move-loop-invariants -w -c rsd2aiem.c
> > during RTL pass: sched2
> > rsd2aiem.c: In function 'dh':
> > rsd2aiem.c:51:1: internal compiler error: in
> > av_set_could_be_blocked_by_bookkeeping_p, at sel-sched.c:3622
> >  }
> >  ^
> > 0x64ad85 av_set_could_be_blocked_by_bookkeeping_p
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:3622
> > 0x64ad85 code_motion_process_successors
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:6395
> > 0x64ad85 code_motion_path_driver
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:6617
> > 0xc59886 code_motion_process_successors
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:6351
> > 0xc59886 code_motion_path_driver
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:6617
> > 0xc59886 code_motion_process_successors
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:6351
> > 0xc59886 code_motion_path_driver
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:6617
> > 0xc5aa5a find_used_regs
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:3283
> > 0xc5aa5a collect_unavailable_regs_from_bnds
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:1598
> > 0xc5aa5a find_best_reg_for_expr
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:1661
> > 0xc5aa5a fill_vec_av_set
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:3797
> > 0xc5da87 fill_ready_list
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:4027
> > 0xc5da87 find_best_expr
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:4387
> > 0xc5da87 fill_insns
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:5544
> > 0xc5da87 schedule_on_fences
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:7361
> > 0xc5da87 sel_sched_region_2
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:7499
> > 0xc61737 sel_sched_region_1
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:7541
> > 0xc61737 sel_sched_region(int)
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:7642
> > 0xc627a8 run_selective_scheduling()
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sel-sched.c:7718
> > 0xc42625 rest_of_handle_sched2
> > 
> > /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> > sched-rgn.c:3729
> > 
> > (as of r256677)
> 
> Give me a few more days for unrelated stuff and I'll have enough time to
> look at this.  If that turns to be the same dependence issue, we can check
> in a patch without waiting for hot/cold bbs issue to be sorted out.

So this one is unrelated to the original testcase.  What happens is we have a
usual if then else control flow like this: bb 4 --> bb 5, bb 6; bb 5 --> bb 7;
bb 6 --> bb 7.  There is a debug stmt in bb 6 sayng bq 

[Bug rtl-optimization/80463] [6/7/8 Regression] ICE with -fselective-scheduling2 and -fvar-tracking-assignments

2018-01-15 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80463

--- Comment #12 from Andrey Belevantsev  ---
(In reply to Arseny Solokha from comment #11)
> How about this one? It makes only trunk gcc ICE, though.
> 
> short int t2;
> int cd, aa, ft;
> 
> void
> dh (void)
> {
>   int qs = 0;
> 
>   if (t2 < 1)
> {
>   int bq = 0;
> 
>   while (bq < 1)
> {
> }
> 
>   while (t2 < 1)
> {
>   if (t2 == 0)
> {
>   bq = 0;
>   cd = !!cd;
> }
>   else
> {
>   bq = 1;
>   cd = bq > qs;
> }
> 
>   t2 += cd;
>   bq = (t2 / qs) == bq;
> 
>   if (aa != ft)
> {
>   qs %= 0;
>   while (bq != 0)
> {
>  ro:
>   ;
> }
> }
> 
>   ++t2;
> }
> 
>  ia:
>   goto ro;
> }
> 
>   goto ia;
> }
> 
> % gcc-8.0.0-alpha20180114 -O2 -fvar-tracking-assignments
> -fselective-scheduling2 -ftree-loop-vectorize -fnon-call-exceptions
> -fno-tree-vrp -fno-gcse-lm -fno-tree-loop-im
> -fno-reorder-blocks-and-partition -fno-reorder-blocks
> -fno-move-loop-invariants -w -c rsd2aiem.c
> during RTL pass: sched2
> rsd2aiem.c: In function 'dh':
> rsd2aiem.c:51:1: internal compiler error: in
> av_set_could_be_blocked_by_bookkeeping_p, at sel-sched.c:3622
>  }
>  ^
> 0x64ad85 av_set_could_be_blocked_by_bookkeeping_p
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:3622
> 0x64ad85 code_motion_process_successors
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:6395
> 0x64ad85 code_motion_path_driver
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:6617
> 0xc59886 code_motion_process_successors
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:6351
> 0xc59886 code_motion_path_driver
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:6617
> 0xc59886 code_motion_process_successors
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:6351
> 0xc59886 code_motion_path_driver
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:6617
> 0xc5aa5a find_used_regs
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:3283
> 0xc5aa5a collect_unavailable_regs_from_bnds
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:1598
> 0xc5aa5a find_best_reg_for_expr
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:1661
> 0xc5aa5a fill_vec_av_set
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:3797
> 0xc5da87 fill_ready_list
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:4027
> 0xc5da87 find_best_expr
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:4387
> 0xc5da87 fill_insns
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:5544
> 0xc5da87 schedule_on_fences
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:7361
> 0xc5da87 sel_sched_region_2
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:7499
> 0xc61737 sel_sched_region_1
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:7541
> 0xc61737 sel_sched_region(int)
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:7642
> 0xc627a8 run_selective_scheduling()
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sel-sched.c:7718
> 0xc42625 rest_of_handle_sched2
>   
> /var/tmp/portage/sys-devel/gcc-8.0.0_alpha20180114/work/gcc-8-20180114/gcc/
> sched-rgn.c:3729
> 
> (as of r256677)

Give me a few more days for unrelated stuff and I'll have enough time to look
at this.  If that turns to be the same dependence issue, we can check in a
patch without waiting for hot/cold bbs issue to be sorted out.

[Bug rtl-optimization/83513] [8 Regression] ICE: qsort checking failed (error: qsort comparator non-negative on sorted output: 3) in fill_vec_av_set in selective scheduler

2017-12-22 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83513

--- Comment #4 from Andrey Belevantsev  ---
(In reply to Alexander Monakov from comment #2)
> Thanks. So the fix for PR 82398 was incomplete. Here we have insns:
> 
> i1: uid: 43  prio: 0  usefulness: 100%
> i2: uid: 20  prio: 3  usefulness: 0%
> i3: uid: 46  prio: 5  usefulness: 0%
> 
> and sel_rank_for_schedule says i2 < i3 by priority difference, but i1 < i2
> && i3 < i1 by uid difference (btw it appears that either the comment or the
> sense of the last tiebreaker is inverted). Now priority comparison code
> doesn't account for the possibility of priority being 0.
> 
> I think we should either
>  - simplify priority comparison to always compare by (prio + prio_adj) * use
> (in which case comparison i2i3 will fall down to uid comparison), or
>  - slightly expand it to always sort zero-usefulness exprs after non-zero
> ones (even when they have priority 0 like i1 in the example).
> 
> Andrey, do you have a preference?

I think the second choice is better as then we do not fall down to uids for
different priorities.  I was hoping we would not get a zero usefulness in real
life with REG_BR_PROB_BASE equal to 1... sigh.

[Bug rtl-optimization/82398] [8 Regression] error: qsort comparator non-negative on sorted output: 2 in fill_vec_av_set at gcc/sel-sched.c:3725

2017-12-11 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82398

--- Comment #4 from Andrey Belevantsev  ---
(In reply to Jakub Jelinek from comment #3)
> Andrey, any progress on this?

Sorry, I have somehow missed this PR.  The second hunk of Alexander's patch
looks fine.  In the first I would rather rewrite the condition to use
SCHED_GROUP_P's instead of adding an assert.  We'll talk this over today and
send a patch.

[Bug rtl-optimization/80463] [6/7/8 Regression] ICE with -fselective-scheduling2 and -fvar-tracking-assignments

2017-12-01 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80463

--- Comment #6 from Andrey Belevantsev  ---
(In reply to Jakub Jelinek from comment #5)
> Any progress with this?

I can make a patch for the dependency problem.  I'm not sure what happened to
the hot/cold block partitioning verification code -- I've heard Honza was going
to remove it (or I have misinterpreted what Alex told me).  It is unrelated to
the dependence issue but is serious enough -- it's didn't allow me to test with
sel-sched enabled at the time.

[Bug rtl-optimization/80463] [5/6/7/8 Regression] ICE with -fselective-scheduling2 and -fvar-tracking-assignments

2017-09-06 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80463

Andrey Belevantsev  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #3 from Andrey Belevantsev  ---
I've debugged this one a bit on a revision with an ICE.  We fail to move up a
bookkeeping copy of a debug insn because of a piece of code in sched-deps.c:

3094   /* Quite often, a debug insn will refer to stuff in the
3095  previous instruction, but the reason we want this
3096  dependency here is to make sure the scheduler doesn't
3097  gratuitously move a debug insn ahead.  This could dirty
3098  DF flags and cause additional analysis that wouldn't have
3099  occurred in compilation without debug insns, and such
3100  additional analysis can modify the generated code.  */
3101   prev = PREV_INSN (insn);
3102
3103   if (prev && NONDEBUG_INSN_P (prev)
3104 add_dependence (insn, prev, REG_DEP_ANTI);

The initial insn didn't have this dependence because it was the first in block.
We could either switch off this conditional completely for selective scheduling
or pass there the insn through which we try to move our debug insn to be used
as prev instead of completely bogus prev insn.  The former is much simple
because var-tracking doesn't play well with sel-sched anyways.

However, while experimenting with these I have found an issue with the
scheduler creating bookkeeping blocks such that the hot/cold partitioning
breaks. This one should be fixed first hopefully after some discussions with
Honza at the cauldron.

[Bug rtl-optimization/79985] ICE in code_motion_path_driver, at sel-sched.c:6580

2017-03-13 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79985

--- Comment #5 from Andrey Belevantsev  ---
Well, we can special case this in sel-sched either along the lines of
df-scan.c, or even easier, just forbid any asm reordering given the DF hunk.

Generally speaking, we've been bitten a couple of times by this in the past
(i.e. by the difference between the DF code and the sched-deps view of the
dependencies between a pair of insns).  It's just a consequence of the
situation when we lack in the RTL the single authoritative place about the insn
DF information.

[Bug target/79570] [5/6 Regression] ICE in sel-sched-ir.c:4534 in pr69956.c

2017-02-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79570

--- Comment #11 from Andrey Belevantsev  ---
(In reply to Jakub Jelinek from comment #10)
> Fixed on the trunk so far.

FWIW I stared at the code for some time but couldn't devise anything better
than your patch.  The hunk itself is somewhat suspicious as Alex said, and he
wanted to experiment with removing it altogether and looking at how it
influenced the -fcompare-debug.  But I doubt it would make any difference.

[Bug target/64411] ICE: in verify_target_availability, at sel-sched.c:1577 with -Os -mcmodel=medium -fPIC -fschedule-insns -fselective-scheduling

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64411

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Andrey Belevantsev  ---
Fixed on trunk and gcc-5-branch, I'm not going to backport to 4.9.

[Bug rtl-optimization/69307] [4.9/5 Regression] wrong code with -O2 -fselective-scheduling @ armv7a

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69307

--- Comment #10 from Andrey Belevantsev  ---
Author: abel
Date: Thu Mar 31 14:50:57 2016
New Revision: 234629

URL: https://gcc.gnu.org/viewcvs?rev=234629=gcc=rev
Log:
Backport from mainline
2016-03-12  Andrey Belevantsev  

gcc/
PR rtl-optimization/69307
* sel-sched.c (choose_best_pseudo_reg): Properly check for hard
registers in modes that span more than one register.

testsuite/
PR rtl-optimization/69307
* gcc.dg/pr69307.c: New test.


Added:
branches/gcc-5-branch/gcc/testsuite/gcc.dg/pr69307.c
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/sel-sched.c

[Bug rtl-optimization/69032] [5 Regression] ICE: in cfg_preds_1, at sel-sched-ir.c:4809 with -fsched-pressure -fsel-sched-pipelining -fselective-scheduling

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69032

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Andrey Belevantsev  ---
Fixed on gcc-5-branch.

[Bug target/70292] ICE in verify_target_availability, at sel-sched.c:1584 with -fno-inline -fno-dce -fschedule-insns -fselective-scheduling -fno-tree-dce -O1

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70292

--- Comment #2 from Andrey Belevantsev  ---
Author: abel
Date: Thu Mar 31 14:37:08 2016
New Revision: 234627

URL: https://gcc.gnu.org/viewcvs?rev=234627=gcc=rev
Log:
PR target/70292
* gcc.c-torture/pr70292.c: New test.


Added:
trunk/gcc/testsuite/gcc.dg/pr70292.c
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug target/70292] ICE in verify_target_availability, at sel-sched.c:1584 with -fno-inline -fno-dce -fschedule-insns -fselective-scheduling -fno-tree-dce -O1

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70292

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #3 from Andrey Belevantsev  ---
Test committed on trunk.

*** This bug has been marked as a duplicate of bug 64411 ***

[Bug target/64411] ICE: in verify_target_availability, at sel-sched.c:1577 with -Os -mcmodel=medium -fPIC -fschedule-insns -fselective-scheduling

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64411

Andrey Belevantsev  changed:

   What|Removed |Added

 CC||tarasevich at cs dot 
uni-saarland.
   ||de

--- Comment #5 from Andrey Belevantsev  ---
*** Bug 70292 has been marked as a duplicate of this bug. ***

[Bug rtl-optimization/69102] [4.9/5 Regression] ICE: in move_op_ascend, at sel-sched.c:6138 with -fselective-scheduling2

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69102

--- Comment #7 from Andrey Belevantsev  ---
Author: abel
Date: Thu Mar 31 14:16:18 2016
New Revision: 234625

URL: https://gcc.gnu.org/viewcvs?rev=234625=gcc=rev
Log:
Backport from mainline
2016-03-21  Andrey Belevantsev  

gcc/
PR rtl-optimization/69102
* sched-deps.c (sched_analyze_insn): Do not set last_args_size field
when we have a readonly dependency context.

testsuite/
PR rtl-optimization/69102
* gcc.c-torture/compile/pr69102.c: New test.

Added:
branches/gcc-5-branch/gcc/testsuite/gcc.c-torture/compile/pr69102.c
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/sched-deps.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog

[Bug rtl-optimization/69032] [5 Regression] ICE: in cfg_preds_1, at sel-sched-ir.c:4809 with -fsched-pressure -fsel-sched-pipelining -fselective-scheduling

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69032

--- Comment #4 from Andrey Belevantsev  ---
Author: abel
Date: Thu Mar 31 14:01:22 2016
New Revision: 234624

URL: https://gcc.gnu.org/viewcvs?rev=234624=gcc=rev
Log:
Backport from mainline
2016-03-15  Andrey Belevantsev  

gcc/
PR rtl-optimization/69032
* sel-sched-ir.c (get_seqno_by_preds): Include both insn and head when
looping backwards over basic block insns.

testsuite/
PR rtl-optimization/69032
* gcc.dg/pr69032.c: New test.


Added:
branches/gcc-5-branch/gcc/testsuite/gcc.dg/pr69032.c
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/sel-sched-ir.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog

[Bug target/66660] [ia64] Speculative load not checked before use, leading to a NaT Consumption Vector interruption

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=0

--- Comment #11 from Andrey Belevantsev  ---
Author: abel
Date: Thu Mar 31 13:55:36 2016
New Revision: 234622

URL: https://gcc.gnu.org/viewcvs?rev=234622=gcc=rev
Log:

Backport from mainline
2016-03-15  Andrey Belevantsev  

PR target/0
* sel-sched-ir.c (merge_expr): Avoid changing the speculative pattern
to non-speculative when propagating trap bits.


Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/sel-sched-ir.c

[Bug target/64411] ICE: in verify_target_availability, at sel-sched.c:1577 with -Os -mcmodel=medium -fPIC -fschedule-insns -fselective-scheduling

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64411

--- Comment #4 from Andrey Belevantsev  ---
Author: abel
Date: Thu Mar 31 13:50:15 2016
New Revision: 234620

URL: https://gcc.gnu.org/viewcvs?rev=234620=gcc=rev
Log:
Backport from mainline
2016-03-15  Andrey Belevantsev  

gcc/
PR target/64411
* sched-deps.c (get_implicit_reg_pending_clobbers): New function,
factored out from ...
(sched_analyze_insn): ... here.
* sched-int.h (get_implicit_reg_pending_clobbers): Declare it.
* sel-sched-ir.c (setup_id_implicit_regs): New function, use
get_implicit_reg_pending_clobbers in it.
(setup_id_reg_sets): Use setup_id_implicit_regs.
(deps_init_id): Ditto.

testsuite/
PR target/64411
* gcc.target/i386/pr64411.C: New test.


Added:
branches/gcc-5-branch/gcc/testsuite/gcc.target/i386/pr64411.C
Modified:
branches/gcc-5-branch/gcc/ChangeLog
branches/gcc-5-branch/gcc/sched-deps.c
branches/gcc-5-branch/gcc/sched-int.h
branches/gcc-5-branch/gcc/sel-sched-ir.c
branches/gcc-5-branch/gcc/testsuite/ChangeLog

[Bug target/70292] ICE in verify_target_availability, at sel-sched.c:1584 with -fno-inline -fno-dce -fschedule-insns -fselective-scheduling -fno-tree-dce -O1

2016-03-31 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70292

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2016-03-31
 CC||abel at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Andrey Belevantsev  ---
(In reply to Andrey Tarasevich from comment #0)
> Created attachment 38016 [details]
> test case with ICE
> 
> This might be a duplicate of bug 64411
> 

It is, I have verified that the patch for 64411 fixes this as well.  However,
the patch is applied to trunk only for now.  I wasn't going to backport it to
gcc-5 because 64411 doesn't have any mentions of the compiler that works.  But
for this test my system opensuse gcc works.  Thus it can be classified as a
regression, and I would backport it to gcc-5 branch and add also this test case
to trunk and gcc 5.

[Bug rtl-optimization/69307] [4.9/5 Regression] wrong code with -O2 -fselective-scheduling @ armv7a

2016-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69307

--- Comment #9 from Andrey Belevantsev  ---
Author: abel
Date: Mon Mar 21 07:54:36 2016
New Revision: 234360

URL: https://gcc.gnu.org/viewcvs?rev=234360=gcc=rev
Log:
PR rtl-optimization/69307
* gcc.target/arm/pr69307.c: New test.


Added:
trunk/gcc/testsuite/gcc.target/arm/pr69307.c
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/69102] [4.9/5/6 Regression] ICE: in move_op_ascend, at sel-sched.c:6138 with -fselective-scheduling2

2016-03-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69102

--- Comment #6 from Andrey Belevantsev  ---
Author: abel
Date: Mon Mar 21 07:52:05 2016
New Revision: 234359

URL: https://gcc.gnu.org/viewcvs?rev=234359=gcc=rev
Log:
gcc/
PR rtl-optimization/69102
* sched-deps.c (sched_analyze_insn): Do not set last_args_size field
when we have a readonly dependency context.

testsuite/

PR rtl-optimization/69102
* gcc.c-torture/compile/pr69102.c: New test.

Added:
trunk/gcc/testsuite/gcc.c-torture/compile/pr69102.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sched-deps.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/69032] [5/6 Regression] ICE: in cfg_preds_1, at sel-sched-ir.c:4809 with -fsched-pressure -fsel-sched-pipelining -fselective-scheduling

2016-03-15 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69032

--- Comment #3 from Andrey Belevantsev  ---
Author: abel
Date: Tue Mar 15 15:42:07 2016
New Revision: 234219

URL: https://gcc.gnu.org/viewcvs?rev=234219=gcc=rev
Log:
gcc/

PR rtl-optimization/69032
* sel-sched-ir.c (get_seqno_by_preds): Include both insn and head when
looping backwards over basic block insns.

testsuite/

PR rtl-optimization/69032
* gcc.dg/pr69032.c: New test.


Added:
trunk/gcc/testsuite/gcc.dg/pr69032.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug target/66660] [ia64] Speculative load not checked before use, leading to a NaT Consumption Vector interruption

2016-03-15 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=0

--- Comment #9 from Andrey Belevantsev  ---
Author: abel
Date: Tue Mar 15 15:36:44 2016
New Revision: 234218

URL: https://gcc.gnu.org/viewcvs?rev=234218=gcc=rev
Log:
PR target/0
* sel-sched-ir.c (merge_expr): Avoid changing the speculative pattern
to non-speculative when propagating trap bits.


Modified:
trunk/gcc/sel-sched-ir.c

[Bug rtl-optimization/63384] scheduler loops on endless fence list with -fselective-scheduling2 on x86

2016-03-15 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63384

--- Comment #6 from Andrey Belevantsev  ---
Author: abel
Date: Tue Mar 15 15:25:41 2016
New Revision: 234217

URL: https://gcc.gnu.org/viewcvs?rev=234217=gcc=rev
Log:
gcc/

PR rtl-optimization/63384
* sel-sched.c (invoke_aftermath_hooks): Do not decrease issue_more
on DEBUG_INSN_P insns.

testsuite/

PR rtl-optimization/63384
* g++.dg/pr63384.C: New test. 

Added:
trunk/gcc/testsuite/g++.dg/pr63384.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched.c
trunk/gcc/testsuite/ChangeLog

[Bug target/64411] ICE: in verify_target_availability, at sel-sched.c:1577 with -Os -mcmodel=medium -fPIC -fschedule-insns -fselective-scheduling

2016-03-15 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64411

--- Comment #3 from Andrey Belevantsev  ---
Author: abel
Date: Tue Mar 15 15:13:29 2016
New Revision: 234216

URL: https://gcc.gnu.org/viewcvs?rev=234216=gcc=rev
Log:
gcc/

PR target/64411
* sched-deps.c (get_implicit_reg_pending_clobbers): New function,
factored out from ...
(sched_analyze_insn): ... here.
* sched-int.h (get_implicit_reg_pending_clobbers): Declare it.
* sel-sched-ir.c (setup_id_implicit_regs): New function, use
get_implicit_reg_pending_clobbers in it.
(setup_id_reg_sets): Use setup_id_implicit_regs.
(deps_init_id): Ditto.

testsuite/

PR target/64411
* gcc.target/i386/pr64411.C: New test.

Added:
trunk/gcc/testsuite/gcc.target/i386/pr64411.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sched-deps.c
trunk/gcc/sched-int.h
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog

[Bug rtl-optimization/69307] [4.9/5/6 Regression] wrong code with -O2 -fselective-scheduling @ armv7a

2016-02-02 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69307

--- Comment #6 from Andrey Belevantsev  ---
Created attachment 37551
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37551=edit
proposed patch

Here before reload we're trying to rename a hard register.  At the very final
point of choosing the new register we forget to properly check hard_regno_nregs
when checking liveness restrictions (though we did all the way to that point). 
Then we incorrectly choose the original register as it seems to be good enough.
 Fixed by looping over all registers specified in hard_regno_nregs at that
place, too.

[Bug rtl-optimization/69102] [4.9/5/6 Regression] ICE: in move_op_ascend, at sel-sched.c:6138 with -fselective-scheduling2

2016-02-01 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69102

--- Comment #4 from Andrey Belevantsev  ---
Created attachment 37550
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37550=edit
proposed patch

The problem here is readonly dependence contexts in selective scheduler.  We're
trying to cache the effect of initializing a dependence context with
remembering that context and setting a readonly bit on it.  When first moving
the insn 43 with REG_ARGS_SIZE note through the insn 3 (a simple eax set) we
also set the last_args_size field of the context.  Later, when we make a copy
of insn 43 and try to move it again through insn 3, we take the cached
dependency context and notice the (fake) dep with last_args_size insn, which is
the old insn 43.  Then the assert saying that we should be able to lift the
bookkeeping copy up the same way as we did with the original insn breaks.

Fixed by the attached patch that makes us notice only deps with the current
producer insn.  I'd need to test it more thoroughly on several arches though.

Richard, is it safe to make copies of REG_ARGS_SIZE insns? I've read the
original ML thread of the sched-deps REG_ARGS_SIZE patch and couldn't quite
figure it out -- with the current deps setting nothing prevents us from moving
the first REG_ARGS_SIZE insn up and creating bookkeeping copies on the paths
where it is inaccessible.

[Bug rtl-optimization/69032] [5/6 Regression] ICE: in cfg_preds_1, at sel-sched-ir.c:4809 with -fsched-pressure -fsel-sched-pipelining -fselective-scheduling

2016-01-27 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69032

--- Comment #2 from Andrey Belevantsev  ---
Created attachment 37490
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37490=edit
proposed patch

We fail to find the proper seqno for the fresh bookkeeping copy here.  The
problem is that in get_seqno_by_preds we are iterating over bb from the given
insn backwards up to the first bb insn.  We skip the initial insn when
iterating over bb, yet we should take seqno from it.  The code in question
originally didn't include bb head when iterating, and was patched to do so in
2011.  The patch was wrong and instead of including bb head managed to exclude
the original insn itself.  By reading the original and patched code I've
convinced myself that the right fix will be to do what the patch intended and
include both the initial insn and the bb head in the iteration.  The patch
fixes the reported testcase but I will have to test it more thoroughly before
submitting.

[Bug target/66660] [ia64] Speculative load not checked before use, leading to a NaT Consumption Vector interruption

2016-01-25 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=0

--- Comment #6 from Andrey Belevantsev  ---
I've debugged it on gcc-5.1.0 since the picture on trunk is different.  Thanks
Jakub for great explanations, it was not easy to get to the root problem.

We speculate an insn (the load in your listing) but we do not make a check for
it though we should.  The thing that broke this was the fix for PR 45472.  In
that pr, we have moved a volatile insn too far up because we failed to merge
the bits describing its volatility when we have processed a control flow split.
 The code to propagate the insn pattern with the insn merging was added when
the volatility of the two insns from the both split branches differ.  However,
the volatility of the speculated insn and its original differ: the original
insn may trap while the speculated version may not.  Thus, we replace a
speculative pattern with the original one per the PR 45472 fix for no reason.

The attached patch for this problem just limits the original fix for pr 45472
to apply for non-speculative insns only.  Jakub, can you check it on your code?
 The patch should apply to both gcc 5 and gcc 6, so you can use whichever is
more convenient for you.

[Bug target/66660] [ia64] Speculative load not checked before use, leading to a NaT Consumption Vector interruption

2016-01-25 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=0

--- Comment #5 from Andrey Belevantsev  ---
Created attachment 37464
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37464=edit
patch for gcc trunk (applies to gcc-5 too)

[Bug target/64411] ICE: in verify_target_availability, at sel-sched.c:1577 with -Os -mcmodel=medium -fPIC -fschedule-insns -fselective-scheduling

2016-01-22 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64411

--- Comment #2 from Andrey Belevantsev  ---
Created attachment 37432
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37432=edit
patch

In this case, we get an inconsistency between the sched-deps interface, saying
we can't move an insn writing si register through a vector insn, and the
liveness analysis, saying we can.  The latter doesn't take into account
implicit_reg_pending_clobbers set calculated in sched-deps before register
allocation.  The solution is to reflect this set in our insn data
(sets/uses/clobbers).  An interesting thing would be to check what happens with
the register allocator if we'd actually moved one insn past the other.

[Bug rtl-optimization/63384] scheduler loops on endless fence list with -fselective-scheduling2 on x86

2016-01-22 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63384

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2016-01-22
 Ever confirmed|0   |1

--- Comment #5 from Andrey Belevantsev  ---
We're looping because we decrease the counter of the insns we still can issue
(can_issue_more) on a DEBUG_INSN.  The following helps us to get away with it
but frankly I have no idea why it was not surfaced before -- no such insns with
usual debug info?

diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c
index c798935..893a3e5 100644
--- a/gcc/sel-sched.c
+++ b/gcc/sel-sched.c
@@ -4249,7 +4249,8 @@ invoke_aftermath_hooks (fence_t fence, rtx_insn
*best_insn, int issue_more)
   issue_more);
   memcpy (FENCE_STATE (fence), curr_state, dfa_state_size);
 }
-  else if (GET_CODE (PATTERN (best_insn)) != USE
+  else if (! DEBUG_INSN_P (best_insn)
+  && GET_CODE (PATTERN (best_insn)) != USE
&& GET_CODE (PATTERN (best_insn)) != CLOBBER)
 issue_more--;

[Bug rtl-optimization/69307] [4.9/5/6 Regression] wrong code with -O2 -fselective-scheduling @ armv7a

2016-01-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69307

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

[Bug rtl-optimization/54472] ICE (spill_failure): unable to find a register to spill in class 'AREG' with -O -fschedule-insns -fselective-scheduling

2016-01-21 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54472

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from Andrey Belevantsev  ---
4.7 is not maintained anymore.

[Bug target/65161] ICE: in vec<_haifa_insn_data, va_heap, vl_embed>::operator[], at vec.h:736 with -O3 -fselective-scheduling2 -mtune=slm

2016-01-19 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65161

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||abel at gcc dot gnu.org
 Resolution|--- |FIXED

--- Comment #5 from Andrey Belevantsev  ---
Fixed since 5.0 and works for 4.9 (no offending code there).

[Bug rtl-optimization/52203] ICE: in reset_sched_cycles_in_current_ebb, at sel-sched.c:7136 with -fsel-sched-pipelining -fselective-scheduling2 and other custom flags

2016-01-19 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52203

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #13 from Andrey Belevantsev  ---
Works since 4.8, 4.7 is not maintained.

[Bug target/64411] ICE: in verify_target_availability, at sel-sched.c:1577 with -Os -mcmodel=medium -fPIC -fschedule-insns -fselective-scheduling

2016-01-14 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64411

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||abel at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

[Bug rtl-optimization/69032] [5/6 Regression] ICE: in cfg_preds_1, at sel-sched-ir.c:4809 with -fsched-pressure -fsel-sched-pipelining -fselective-scheduling

2016-01-14 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69032

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

[Bug rtl-optimization/69102] [4.9/5/6 Regression] ICE: in move_op_ascend, at sel-sched.c:6138 with -fselective-scheduling2

2016-01-14 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69102

Andrey Belevantsev  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||abel at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

[Bug target/66660] [ia64] Speculative load not checked before use, leading to a NaT Consumption Vector interruption

2015-10-28 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=0

--- Comment #3 from Andrey Belevantsev  ---
Sorry, I've got swamped by work and never got around to this.  I will try
harder now :)


[Bug target/66660] [ia64] Speculative load not checked before use, leading to a NaT Consumption Vector interruption

2015-06-25 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=0

Andrey Belevantsev abel at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2015-06-25
 CC||abel at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Andrey Belevantsev abel at gcc dot gnu.org ---
I will take a look in a week or so when I'll be back in office.


[Bug rtl-optimization/60901] [4.8/4.9 Regression] ICE: SIGSEGV in add_to_deps_list with -fsel-sched-pipelining-outer-loops

2014-06-03 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901

--- Comment #9 from Andrey Belevantsev abel at gcc dot gnu.org ---
Author: abel
Date: Tue Jun  3 09:20:36 2014
New Revision: 211164

URL: http://gcc.gnu.org/viewcvs?rev=211164root=gccview=rev
Log:
Backport from mainline

2014-05-14  Andrey Belevantsev  a...@ispras.ru
PR rtl-optimization/60901

* config/i386/i386.c (ix86_dependencies_evaluation_hook): Check that
bb predecessor belongs to the same scheduling region.  Adjust comment.

* gcc.target/i386/pr60901.c: New test.


Added:
branches/gcc-4_8-branch/gcc/testsuite/gcc.target/i386/pr60901.c
Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/config/i386/i386.c
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


[Bug rtl-optimization/60866] [4.7/4.8/4.9 Regression] ICE: in get_seqno_for_a_jump, at sel-sched-ir.c:4068 with -fselective-scheduling -fno-if-conversion

2014-06-03 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60866

--- Comment #7 from Andrey Belevantsev abel at gcc dot gnu.org ---
Author: abel
Date: Tue Jun  3 09:25:39 2014
New Revision: 211165

URL: http://gcc.gnu.org/viewcvs?rev=211165root=gccview=rev
Log:
Backport from mainline
2014-05-14  Andrey Belevantsev  a...@ispras.ru

PR rtl-optimization/60866
* sel-sched-ir (sel_init_new_insn): New parameter old_seqno.
Default it to -1.  Pass it down to init_simplejump_data.
(init_simplejump_data): New parameter old_seqno.  Pass it down
to get_seqno_for_a_jump.
(get_seqno_for_a_jump): New parameter old_seqno.  Use it for
initializing new jump seqno as a last resort.  Add comment.
(sel_redirect_edge_and_branch): Save old seqno of the conditional
jump and pass it down to sel_init_new_insn.
(sel_redirect_edge_and_branch_force): Likewise.

* gcc.dg/pr60866.c: New test.


Added:
branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/pr60866.c
Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/sel-sched-ir.c
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog


[Bug rtl-optimization/60901] [4.8/4.9 Regression] ICE: SIGSEGV in add_to_deps_list with -fsel-sched-pipelining-outer-loops

2014-06-03 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901

--- Comment #10 from Andrey Belevantsev abel at gcc dot gnu.org ---
Author: abel
Date: Tue Jun  3 10:06:39 2014
New Revision: 211168

URL: http://gcc.gnu.org/viewcvs?rev=211168root=gccview=rev
Log:
Backport from mainline

2014-05-14  Andrey Belevantsev  a...@ispras.ru
PR rtl-optimization/60901

* config/i386/i386.c (ix86_dependencies_evaluation_hook): Check that
bb predecessor belongs to the same scheduling region.  Adjust comment.

* gcc.target/i386/pr60901.c: New test.

Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/pr60901.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/config/i386/i386.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


[Bug rtl-optimization/60901] [4.8/4.9 Regression] ICE: SIGSEGV in add_to_deps_list with -fsel-sched-pipelining-outer-loops

2014-06-03 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901

Andrey Belevantsev abel at gcc dot gnu.org changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #11 from Andrey Belevantsev abel at gcc dot gnu.org ---
Fixed on branches.


[Bug rtl-optimization/60866] [4.7/4.8/4.9 Regression] ICE: in get_seqno_for_a_jump, at sel-sched-ir.c:4068 with -fselective-scheduling -fno-if-conversion

2014-06-03 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60866

--- Comment #8 from Andrey Belevantsev abel at gcc dot gnu.org ---
Author: abel
Date: Tue Jun  3 10:08:58 2014
New Revision: 211169

URL: http://gcc.gnu.org/viewcvs?rev=211169root=gccview=rev
Log:
Backport from mainline
2014-05-14  Andrey Belevantsev  a...@ispras.ru

PR rtl-optimization/60866
* sel-sched-ir (sel_init_new_insn): New parameter old_seqno.
Default it to -1.  Pass it down to init_simplejump_data.
(init_simplejump_data): New parameter old_seqno.  Pass it down
to get_seqno_for_a_jump.
(get_seqno_for_a_jump): New parameter old_seqno.  Use it for
initializing new jump seqno as a last resort.  Add comment.
(sel_redirect_edge_and_branch): Save old seqno of the conditional
jump and pass it down to sel_init_new_insn.
(sel_redirect_edge_and_branch_force): Likewise.

* gcc.dg/pr60866.c: New test.

Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr60866.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/sel-sched-ir.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog


[Bug rtl-optimization/60866] [4.7/4.8/4.9 Regression] ICE: in get_seqno_for_a_jump, at sel-sched-ir.c:4068 with -fselective-scheduling -fno-if-conversion

2014-06-03 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60866

Andrey Belevantsev abel at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #9 from Andrey Belevantsev abel at gcc dot gnu.org ---
Also fixed on branches.


[Bug rtl-optimization/60901] [4.8/4.9 Regression] ICE: SIGSEGV in add_to_deps_list with -fsel-sched-pipelining-outer-loops

2014-05-26 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901

--- Comment #8 from Andrey Belevantsev abel at gcc dot gnu.org ---
Sorry, Uros asked me to wait a bit while the patch is on trunk and at the time
the 4.8 branch got freezed, so I've postponed backporting.  I will take care of
it.


[Bug rtl-optimization/60901] [4.8/4.9/4.10 Regression] ICE: SIGSEGV in add_to_deps_list with -fsel-sched-pipelining-outer-loops

2014-05-14 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901

--- Comment #4 from Andrey Belevantsev abel at gcc dot gnu.org ---
Author: abel
Date: Wed May 14 09:46:26 2014
New Revision: 210414

URL: http://gcc.gnu.org/viewcvs?rev=210414root=gccview=rev
Log:
PR rtl-optimization/60901
* config/i386/i386.c (ix86_dependencies_evaluation_hook): Check that
bb predecessor belongs to the same scheduling region.  Adjust comment.

* gcc.target/i386/pr60901.c: New test.


Added:
trunk/gcc/testsuite/gcc.target/i386/pr60901.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/i386/i386.c
trunk/gcc/testsuite/ChangeLog


[Bug rtl-optimization/60901] [4.8/4.9/4.10 Regression] ICE: SIGSEGV in add_to_deps_list with -fsel-sched-pipelining-outer-loops

2014-05-14 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901

Andrey Belevantsev abel at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Andrey Belevantsev abel at gcc dot gnu.org ---
Fixed on trunk.


[Bug rtl-optimization/60866] [4.7/4.8/4.9/4.10 Regression] ICE: in get_seqno_for_a_jump, at sel-sched-ir.c:4068 with -fselective-scheduling -fno-if-conversion

2014-05-14 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60866

--- Comment #4 from Andrey Belevantsev abel at gcc dot gnu.org ---
Author: abel
Date: Wed May 14 12:09:02 2014
New Revision: 210420

URL: http://gcc.gnu.org/viewcvs?rev=210420root=gccview=rev
Log:
PR rtl-optimization/60866
* sel-sched-ir (sel_init_new_insn): New parameter old_seqno.
Default it to -1.  Pass it down to init_simplejump_data.
(init_simplejump_data): New parameter old_seqno.  Pass it down
to get_seqno_for_a_jump.
(get_seqno_for_a_jump): New parameter old_seqno.  Use it for
initializing new jump seqno as a last resort.  Add comment.
(sel_redirect_edge_and_branch): Save old seqno of the conditional
jump and pass it down to sel_init_new_insn.
(sel_redirect_edge_and_branch_force): Likewise.

* gcc.dg/pr60866.c: New test. 

Added:
trunk/gcc/testsuite/gcc.dg/pr60866.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/sel-sched-ir.c
trunk/gcc/testsuite/ChangeLog


[Bug rtl-optimization/60866] [4.7/4.8/4.9/4.10 Regression] ICE: in get_seqno_for_a_jump, at sel-sched-ir.c:4068 with -fselective-scheduling -fno-if-conversion

2014-05-14 Thread abel at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60866

Andrey Belevantsev abel at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
  Known to work||4.10.0
 Resolution|--- |FIXED
  Known to fail|4.10.0  |

--- Comment #5 from Andrey Belevantsev abel at gcc dot gnu.org ---
Fixed on trunk.


[Bug rtl-optimization/60901] [4.8/4.9/4.10 Regression] ICE: SIGSEGV in add_to_deps_list with -fsel-sched-pipelining-outer-loops

2014-04-29 Thread abel at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60901

Andrey Belevantsev abel at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #3 from Andrey Belevantsev abel at gcc dot gnu.org ---
The ix86_dependencies_evaluation_hook has the following code:

26230 /* Assume that region is SCC, i.e. all immediate
predecessors
26231of non-head block are in the same region.  */
26232 FOR_EACH_EDGE (e, ei, bb-preds)
26233   {

The comment is wrong for selective scheduling with pipelining of outer loops
enabled, as the regions then are formed started from the innermost loops and
going up to the outer loops.  So there could be a hole in the outer loop
region.

Fixed easily below like this, the comment has also to be adjusted of course.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 895ebbb..3f572fc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -26233,7 +26233,8 @@ ix86_dependencies_evaluation_hook (rtx head, rtx tail)
  {
/* Avoid creating of loop-carried dependencies through
   using topological odering in region.  */
-   if (BLOCK_TO_BB (bb-index)  BLOCK_TO_BB (e-src-index))
+   if (rgn == CONTAINING_RGN (e-src-index)
+BLOCK_TO_BB (bb-index)  BLOCK_TO_BB
(e-src-index))
  add_dependee_for_func_arg (first_arg, e-src);
  }
  }


[Bug rtl-optimization/60866] [4.7/4.8/4.9/4.10 Regression] ICE: in get_seqno_for_a_jump, at sel-sched-ir.c:4068 with -fselective-scheduling -fno-if-conversion

2014-04-28 Thread abel at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60866

Andrey Belevantsev abel at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |abel at gcc dot gnu.org

--- Comment #3 from Andrey Belevantsev abel at gcc dot gnu.org ---
Created attachment 32692
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=32692action=edit
draft patch

An interesting case so I'd leave more detailed notes.  We are scheduling a
region that has a diamond like this:
  bb 3 --
|\
  bb 4\
 /\ \
   bb 5   bb 6  /
 \//
   bb 7  --

After scheduling bb 3 we proceed to bb 4 and bb 7 simultaneously.  Bbs 5 and 6
have identical insns.  While having a fence at the end of bb 4, we unify these
insns to one and get empty bbs 5 and 6 at once.  While simplifying this, we end
up with a conditional jump ending bb 4 turning into an unconditional one
leading to bb 7 (via redirect_edge_and_branch).  This jump is the new insn so
should be initialized.  We try to get a seqno for this jump from surrounding
unscheduled code (via get_seqno_for_a_jump), but both bbs 4 and 7 are already
completely scheduled.  Thus we ICE.

The only unscheduled insn in this region is the old conditional jump.  But it
is no longer with us while we're trying to init the new jump it turned into.  

The easy solution is to remove the assert and to change it into something like
seqno = 42;.  This fixes the test but we will never be able to catch bugs in
this function again.  The preferred solution will be to pass down the old jump
seqno to the initializing function so it would take it as the new jump seqno
only in this particular case.  That means changing a number of
sel_init_new_insn callers.  But, if we are now allowed to have default
parameters (do we?), this simplifies things.

Attached is the draft patch (the function comments is not yet updated, C++
default parameters are used).


  1   2   3   4   >