[Bug tree-optimization/64284] [5 Regression] ICE: Segmentation fault

2015-03-05 Thread yroux at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64284

--- Comment #6 from Yvan Roux yroux at gcc dot gnu.org ---
Author: yroux
Date: Thu Mar  5 14:28:05 2015
New Revision: 221216

URL: https://gcc.gnu.org/viewcvs?rev=221216root=gccview=rev
Log:
gcc/
2015-03-05  Yvan Roux  yvan.r...@linaro.org

Backport from trunk r212011, r214942, r214957, r215012, r215016, r218115,
r218733, r218746, r220491.
2015-02-06  Sebastian Pop  s@samsung.com
Brian Rzycki  b.rzy...@samsung.com

PR tree-optimization/64878
* tree-ssa-threadedge.c: Include tree-ssa-loop.h.
(fsm_find_control_statement_thread_paths): Add parameter seen_loop_phi.
Stop recursion at loop phi nodes after having visited a loop phi node.

2014-12-15  Richard Biener  rguent...@suse.de

PR middle-end/64246
* cfgloop.c (mark_loop_for_removal): Make safe against multiple
invocations on the same loop.

2014-12-15  Richard Biener  rguent...@suse.de

PR tree-optimization/64284
* tree-ssa-threadupdate.c (duplicate_seme_region): Mark
the loop for removal if we copied the loop header.

2014-11-27  Richard Biener  rguent...@suse.de

PR tree-optimization/64083
* tree-ssa-threadupdate.c (thread_through_all_blocks): Do not
forcibly mark loop for removal the wrong way.

2014-09-08  Richard Biener  rguent...@suse.de

PR ipa/63196
* tree-inline.c (copy_loops): The source loop header should
always be non-NULL.
(tree_function_versioning): If loops need fixup after removing
unreachable blocks fix them.
* omp-low.c (simd_clone_adjust): Do not add incr block to
loop under construction.

2014-09-08  Richard Biener  rguent...@suse.de

PR bootstrap/63204
* cfgloop.c (mark_loop_for_removal): Track former header
unconditionally.
* cfgloop.h (struct loop): Add former_header member unconditionally.
* loop-init.c (fix_loop_structure): Enable bogus loop removal
diagnostic unconditionally.

2014-09-05  Richard Biener  rguent...@suse.de

* cfgloop.c (mark_loop_for_removal): Record former header
when ENABLE_CHECKING.
* cfgloop.h (strut loop): Add former_header member when
ENABLE_CHECKING.
* loop-init.c (fix_loop_structure): Sanity check loops
marked for removal if they re-appeared.

2014-09-05  Richard Biener  rguent...@suse.de

* cfgloop.c (mark_loop_for_removal): New function.
* cfgloop.h (mark_loop_for_removal): Declare.
* cfghooks.c (delete_basic_block): Use mark_loop_for_removal.
(merge_blocks): Likewise.
(duplicate_block): Likewise.
* except.c (sjlj_emit_dispatch_table): Likewise.
* tree-eh.c (cleanup_empty_eh_merge_phis): Likewise.
* tree-ssa-threadupdate.c (ssa_redirect_edges): Likewise.
(thread_through_loop_header): Likewise.

2014-06-26  Richard Biener  rguent...@suse.de

PR tree-optimization/61607
* tree-ssa-threadupdate.c (ssa_redirect_edges): Cancel the
loop if we redirected its latch edge.
(thread_block_1): Do not cancel loops prematurely.

gcc/testsuite/
2015-03-05  Yvan Roux  yvan.r...@linaro.org

Backport from trunk r218115, r218733, r218746, r220491.
2015-02-06  Sebastian Pop  s@samsung.com
Brian Rzycki  b.rzy...@samsung.com

PR tree-optimization/64878
* testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c: New.

2014-12-15  Richard Biener  rguent...@suse.de

PR middle-end/64246
* gnat.dg/opt46.adb: New testcase.
* gnat.dg/opt46.ads: Likewise.
* gnat.dg/opt46_pkg.adb: Likewise.
* gnat.dg/opt46_pkg.ads: Likewise.

2014-12-15  Richard Biener  rguent...@suse.de

PR tree-optimization/64284
* gcc.dg/torture/pr64284.c: New testcase.

2014-11-27  Richard Biener  rguent...@suse.de

PR tree-optimization/64083
* gcc.dg/torture/pr64083.c: New testcase.


Added:
branches/linaro/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr64083.c
branches/linaro/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr64284.c
   
branches/linaro/gcc-4_9-branch/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c
branches/linaro/gcc-4_9-branch/gcc/testsuite/gnat.dg/opt46.adb
branches/linaro/gcc-4_9-branch/gcc/testsuite/gnat.dg/opt46.ads
branches/linaro/gcc-4_9-branch/gcc/testsuite/gnat.dg/opt46_pkg.adb
branches/linaro/gcc-4_9-branch/gcc/testsuite/gnat.dg/opt46_pkg.ads
Modified:
branches/linaro/gcc-4_9-branch/gcc/ChangeLog.linaro
branches/linaro/gcc-4_9-branch/gcc/cfghooks.c
branches/linaro/gcc-4_9-branch/gcc/cfgloop.c
branches/linaro/gcc-4_9-branch/gcc/cfgloop.h
branches/linaro/gcc-4_9-branch/gcc/except.c
branches/linaro/gcc-4_9-branch/gcc/loop-init.c
branches/linaro/gcc-4_9-branch/gcc/omp-low.c
branches/linaro/gcc-4_9-branch/gcc/testsuite/ChangeLog.linaro
branches/linaro/gcc-4_9-branch/gcc/tree-eh.c
branches/linaro/gcc-4_9-branch/gcc/tree-inline.c
branches/linaro/gcc-4_9-branch/gcc/tree-ssa-threadedge.c

[Bug tree-optimization/64284] [5 Regression] ICE: Segmentation fault

2014-12-15 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64284

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

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

--- Comment #4 from Richard Biener rguenth at gcc dot gnu.org ---
Fixed.


[Bug tree-optimization/64284] [5 Regression] ICE: Segmentation fault

2014-12-15 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64284

--- Comment #5 from Richard Biener rguenth at gcc dot gnu.org ---
Author: rguenth
Date: Mon Dec 15 08:19:55 2014
New Revision: 218733

URL: https://gcc.gnu.org/viewcvs?rev=218733root=gccview=rev
Log:
2014-12-15  Richard Biener  rguent...@suse.de

PR tree-optimization/64284
* tree-ssa-threadupdate.c (duplicate_seme_region): Mark
the loop for removal if we copied the loop header.

* gcc.dg/torture/pr64284.c: New testcase.

Added:
trunk/gcc/testsuite/gcc.dg/torture/pr64284.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-threadupdate.c


[Bug tree-optimization/64284] [5 Regression] ICE: Segmentation fault

2014-12-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64284

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|--- |5.0


[Bug tree-optimization/64284] [5 Regression] ICE: Segmentation fault

2014-12-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64284

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2014-12-12
 CC||spop at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener rguenth at gcc dot gnu.org ---
  Registering jump thread: (4, 5) incoming edge;  (5, 55) joiner;  (55, 63)
normal;
  Registering FSM jump thread: (94, 5) incoming edge;  (6, 20) nocopy;
  Registering jump thread: (61, 6) incoming edge;  (6, 20) normal;
  Registering jump thread: (77, 6) incoming edge;  (6, 20) normal;
  Registering jump thread: (69, 6) incoming edge;  (6, 20) normal;
  Registering FSM jump thread: (94, 5) incoming edge;  (55, 56) nocopy;
...
  Threaded jump 69 -- 6 to 109
  Threaded jump 77 -- 6 to 109
  Threaded jump 61 -- 6 to 109

and then we end up with an invalid loop.  FSM threads the latch edge but
doesn't update the loop structure accordingly so later asking for the
loop latch edge fails (because the loop isn't anymore it seems - or
header and latch are no longer valid).

Let me have a look.


[Bug tree-optimization/64284] [5 Regression] ICE: Segmentation fault

2014-12-12 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64284

--- Comment #2 from Markus Trippelsdorf trippels at gcc dot gnu.org ---
trippels@gcc20 ~ % cat scp.i
int *a;
int b;
int
fn1() {
  enum { QSTRING } c = 0;
  while (1) {
switch (*a) {
case '\'':
  c = 0;
default:
  switch (c)
  case 0:
  if (b)
return 0;
  c = 1;
}
a++;
  }
}


[Bug tree-optimization/64284] [5 Regression] ICE: Segmentation fault

2014-12-12 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64284

--- Comment #3 from Richard Biener rguenth at gcc dot gnu.org ---
Sth like

Index: tree-ssa-threadupdate.c
===
--- tree-ssa-threadupdate.c (revision 218621)
+++ tree-ssa-threadupdate.c (working copy)
@@ -2364,7 +2364,7 @@ duplicate_seme_region (edge entry, edge
   basic_block *region_copy)
 {
   unsigned i;
-  bool free_region_copy = false, copying_header = false;
+  bool free_region_copy = false;
   struct loop *loop = entry-dest-loop_father;
   edge exit_copy;
   edge redirected;
@@ -2388,10 +2388,7 @@ duplicate_seme_region (edge entry, edge

   initialize_original_copy_tables ();

-  if (copying_header)
-set_loop_copy (loop, loop_outer (loop));
-  else
-set_loop_copy (loop, loop);
+  set_loop_copy (loop, loop);

   if (!region_copy)
 {
@@ -2453,6 +2450,8 @@ duplicate_seme_region (edge entry, edge
   }

   /* Redirect the entry and add the phi node arguments.  */
+  if (entry-dest == loop-header)
+mark_loop_for_removal (loop);
   redirected = redirect_edge_and_branch (entry, get_bb_copy (entry-dest));
   gcc_assert (redirected != NULL);
   flush_pending_stmts (entry);

works but results in the less than optimal

fix_loop_structure: fixing up loops for function
fix_loop_structure: removing loop 1
flow_loops_find: discovered new loop 2 with header 5

in the testcase the loop header will be entry-src it seems - not sure
how reliably that is in the full generality of duplicate_seme_region.
We know that all blocks are contained in the same loop, so it must be
possible to compute where the header goes.

Ideally we'd simply set loop-header and loop-latch to the correct values,
marking loops for fixup (to recompute BB ownership - or do even that
ourselves).
The testcase has two latches later, thus loop-latch would be NULL, but
both VRP and DOM init loops without LOOPS_MAY_HAVE_MULTIPLE_LATCHES so we'd
have to disambiguate the loops.

That said - the above patch works.