aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-12-06 09:16:44 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-12-06 09:16:44 +0100
commit650a8fcf8cabb103e1e1cbd40711f1decbb09d5e (patch)
treee6f46fca2559d08d344baa43f3aaad19950030fc /gcc
parentc3ad2f62354003fe63994d96255f807492d857e6 (diff)
downloadgcc-650a8fcf8cabb103e1e1cbd40711f1decbb09d5e.zip
gcc-650a8fcf8cabb103e1e1cbd40711f1decbb09d5e.tar.gz
gcc-650a8fcf8cabb103e1e1cbd40711f1decbb09d5e.tar.bz2
re PR tree-optimization/81945 (ICE in operator[], at vec.h:749)
PR tree-optimization/81945 * cfgloop.h (FOR_EACH_LOOP_FN): Use FN instead of hardcoding fn. * tree-cfg.c (move_sese_region_to_fn): If any of the loops moved to dest_cfun has orig_loop_num set, either remap it to the new loop number if the loop got moved too, or clear it. * gcc.dg/graphite/pr81945.c: New test. From-SVN: r255438
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/cfgloop.h2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/graphite/pr81945.c21
-rw-r--r--gcc/tree-cfg.c16
5 files changed, 51 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 603f7f0..b3f5784 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2017-12-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/81945
+ * cfgloop.h (FOR_EACH_LOOP_FN): Use FN instead of hardcoding fn.
+ * tree-cfg.c (move_sese_region_to_fn): If any of the loops moved
+ to dest_cfun has orig_loop_num set, either remap it to the new
+ loop number if the loop got moved too, or clear it.
+
2017-12-05 Steve Ellcey <sellcey@cavium.com>
* config/aarch64/thunderx2-t99.md (thunderx2t99_branch): Add trap
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index dce01bd..687cdb5 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -766,7 +766,7 @@ loop_iterator::~loop_iterator ()
(LOOP) = li.next ())
#define FOR_EACH_LOOP_FN(FN, LOOP, FLAGS) \
- for (loop_iterator li(fn, &(LOOP), FLAGS); \
+ for (loop_iterator li(FN, &(LOOP), FLAGS); \
(LOOP); \
(LOOP) = li.next ())
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 983bcd8..1ec2e94 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/81945
+ * gcc.dg/graphite/pr81945.c: New test.
+
2017-12-05 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
* gcc.c-torture/unsorted/dump-noaddr.x: Generate dump files in
diff --git a/gcc/testsuite/gcc.dg/graphite/pr81945.c b/gcc/testsuite/gcc.dg/graphite/pr81945.c
new file mode 100644
index 0000000..0dc6619
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr81945.c
@@ -0,0 +1,21 @@
+/* PR tree-optimization/81945 */
+/* { dg-do compile { target pthread } } */
+/* { dg-options "-O3 -ftree-parallelize-loops=2 -floop-nest-optimize" } */
+
+unsigned long int v;
+
+void
+foo (int x, int y, long int *a)
+{
+ do
+ {
+ int **b;
+
+ while (y != 0)
+ ;
+ v *= 2;
+ **b = *a;
+ ++x;
+ }
+ while (x < 1);
+}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 2501a9c..e313df9 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -7468,6 +7468,8 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES;
set_loops_for_fn (dest_cfun, loops);
+ vec<loop_p, va_gc> *larray = get_loops (saved_cfun)->copy ();
+
/* Move the outlined loop tree part. */
num_nodes = bbs.length ();
FOR_EACH_VEC_ELT (bbs, i, bb)
@@ -7514,6 +7516,20 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
loop->aux = current_loops->tree_root;
loop0->aux = current_loops->tree_root;
+ /* Fix up orig_loop_num. If the block referenced in it has been moved
+ to dest_cfun, update orig_loop_num field, otherwise clear it. */
+ struct loop *dloop;
+ FOR_EACH_LOOP_FN (dest_cfun, dloop, 0)
+ if (dloop->orig_loop_num)
+ {
+ if ((*larray)[dloop->orig_loop_num] != NULL
+ && get_loop (saved_cfun, dloop->orig_loop_num) == NULL)
+ dloop->orig_loop_num = (*larray)[dloop->orig_loop_num]->num;
+ else
+ dloop->orig_loop_num = 0;
+ }
+ ggc_free (larray);
+
pop_cfun ();
/* Move blocks from BBS into DEST_CFUN. */