diff mbox

[gomp4,committed,PR66716] Fix compilation libgomp.oacc-c-c++-common/kernels-loop.c -g

Message ID 5594111C.50904@mentor.com
State New
Headers show

Commit Message

Tom de Vries July 1, 2015, 4:11 p.m. UTC
Hi,

when compiling libgomp.oacc-c-c++-common/kernels-loop at -O2 -g, we run 
into:
...
FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c 
-DACC_DEVICE_TYPE_host=1 -DACC_MEM_SHARED=1 (internal compiler error)
...

The ICE in more detail:
...
src/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c: 
In function ‘main’:
src/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c:41:1: 
error: definition in block 10 does not dominate use in block 19
for SSA_NAME: ii_69 in statement:
# DEBUG ii => ii_69
src/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c:41:1: 
internal compiler error: verify_ssa failed
0x1123966 verify_ssa(bool, bool)
	src/gcc/tree-ssa.c:1068
0xd1a9d8 execute_function_todo
	src/gcc/passes.c:1953
0xd19abf do_per_function
	src/gcc/passes.c:1638
0xd1ab76 execute_todo
	src/gcc/passes.c:2003
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions
...


Before transform_to_exit_first_loop_alt we have this loop:
...
   <bb preheader>
   goto <bb 10>;

   <bb 10>:
   # ivtmp_19 = PHI <ivtmp_7(11), 0(9)>
   ii_36 = ivtmp_19;
   # DEBUG ii => ii_36
   _52 = (long unsigned int) ii_36;
   _53 = _52 * 4;
   _54 = c.6_51 + _53;
   _59 = a.7_56 + _53;
   _60 = *_59;
   _65 = b.8_62 + _53;
   _66 = *_65;
   _67 = _60 + _66;
   *_54 = _67;
   ii_69 = ii_36 + 1;
   # DEBUG ii => ii_69
   # DEBUG ii => ii_69
   if (ivtmp_19 < 524287)
     goto <bb 11>;
   else
     goto <bb 12>;

   <bb 11>:
   ivtmp_7 = ivtmp_19 + 1;
   goto <bb 10>;
...

And after transform_to_exit_first_loop_alt we have this loop:
...
   <bb preheader>
   goto <bb 19>;

   <bb 10>:
   # ivtmp_19 = PHI <ivtmp_35(19)>
   ii_36 = ivtmp_19;
   # DEBUG ii => ii_36
   _52 = (long unsigned int) ii_36;
   _53 = _52 * 4;
   _54 = c.6_51 + _53;
   _59 = a.7_56 + _53;
   _60 = *_59;
   _65 = b.8_62 + _53;
   _66 = *_65;
   _67 = _60 + _66;
   *_54 = _67;
   ii_69 = ii_36 + 1;
   goto <bb 11>;

   <bb 19>:
   # ivtmp_35 = PHI <ivtmp_7(11), 0(9)>
   # DEBUG ii => ii_69
   # DEBUG ii => ii_69
   if (ivtmp_35 < 524288)
     goto <bb 10>;
   else
     goto <bb 12>;

   <bb 11>:
   ivtmp_7 = ivtmp_19 + 1;
   goto <bb 19>;
...

So, the use of ii_69 in debug insn 'DEBUG ii => ii_69' in bb 19 is no 
longer dominated by the def of ii_68 in bb 10.


The patch fixes this by ensuring that 
gimple_split_block_before_cond_jump really splits before cond_jump, 
instead of after the last nondebug insn before cond_jump, as it does 
now. This behaviour also better matches the rtl implementation of the 
cfghook. Btw, note that the only user of cfghook 
split_block_before_cond_jump is transform_to_exit_first_loop_alt.

Committed to gomp-4_0-branch.

Thanks,
- Tom
diff mbox

Patch

Fix compilation libgomp.oacc-c-c++-common/kernels-loop.c -g

2015-07-01  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/66716
	* tree-cfg.c (gimple_split_block_before_cond_jump): Split before
	cond_jump, instead of split after last nondebug insn before cond_jump.

	* c-c++-common/goacc/kernels-loop-g.c: New test.

	* testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c: New test.
---
 gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c     | 19 +++++++++++++++++++
 gcc/tree-cfg.c                                        |  2 +-
 .../libgomp.oacc-c-c++-common/kernels-loop-g.c        |  5 +++++
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c

diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
new file mode 100644
index 0000000..331503a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
@@ -0,0 +1,19 @@ 
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-g" } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+/* { dg-additional-options "-fdump-tree-parloops_oacc_kernels-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include "kernels-loop.c"
+
+/* Check that only one loop is analyzed, and that it can be parallelized.  */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops_oacc_kernels" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops_oacc_kernels" } } */
+
+/* Check that the loop has been split off into a function.  */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)pragma omp target oacc_parallel.*num_gangs\\(32\\)" 1 "parloops_oacc_kernels" } } */
+
+/* { dg-final { cleanup-tree-dump "parloops_oacc_kernels" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 99b27c7..a8aec26 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -5837,7 +5837,7 @@  gimple_split_block_before_cond_jump (basic_block bb)
   if (gimple_code (last) != GIMPLE_COND
       && gimple_code (last) != GIMPLE_SWITCH)
     return NULL;
-  gsi_prev_nondebug (&gsi);
+  gsi_prev (&gsi);
   split_point = gsi_stmt (gsi);
   return split_block (bb, split_point)->dest;
 }
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c
new file mode 100644
index 0000000..96b6e4e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c
@@ -0,0 +1,5 @@ 
+/* { dg-do run } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+/* { dg-additional-options "-g" } */
+
+#include "kernels-loop.c"
-- 
1.9.1