This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/81464] [8 Regression] ICE in expand_omp_for_static_chunk, at omp-expand.c:4236


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81464

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
Minimal example:
...
program main
  implicit none
  real, dimension(:,:),allocatable :: a, b, c
  real :: sm

  allocate (a(2,2), b(2,2), c(2,2))

  call random_number(a)
  call random_number(b)

  c = matmul(a,b)
  sm = sum(c)

  deallocate(a,b,c)

end program main
...

The assert happens in expand_omp_for_static_chunk when trying to expand a
region from bb71 to bb72:
...
(gdb) p region.entry.index
$1 = 71
(gdb) p region.exit.index
$2 = 72
...

In other words:
...
;;   basic block 71, loop depth 0, freq 48, maybe hot
;;    prev block 69, next block 67, flags: (NEW)
;;    pred:       69 [always]  (FALLTHRU)
  #pragma omp for schedule(static,2)
  for (ivtmp_87 = 0; ivtmp_87 < _144; ivtmp_87 =  + 1)
;;    succ:       67 [always]  (FALLTHRU)
;;                72 [never (guessed)]

   ...

;;   basic block 72, loop depth 0, freq 47, maybe hot
;;   Invalid sum of incoming frequencies 269, should be 47
;;    prev block 63, next block 70, flags: (NEW)
;;    pred:       46 [always]  (FALLTHRU)
;;                71 [never (guessed)] 
  # .MEM_88 = PHI <.MEM_86(46), .MEM_86(71)>
  #pragma omp return(nowait)
;;    succ:       70 [always]  (FALLTHRU)
...

When we're ICE-ing, we're executing a bit:
...
      /* When we redirect the edge from trip_update_bb to iter_part_bb, we      
         remove arguments of the phi nodes in fin_bb.  We need to create        
         appropriate phi nodes in iter_part_bb instead.  */
...

When we look at fin_bb, we see indeed that one of the arguments of the phi has
been dropped.:
...
(gdb) call debug_bb (fin_bb)
;; basic block 72, loop depth 0, freq 47, maybe hot
;;  prev block 100, next block 70, flags: (NEW)
;;  pred:       98 [never (guessed)]  (FALSE_VALUE)
# .MEM_88 = PHI <.MEM_86(98)>
;;  succ:       70 [always]  (FALLTHRU)
...

But since the arguments were equal anyway, this is fine, and there's no need to
do anything.

Tentative patch:
...
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 929c530..089bffc 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -4206,6 +4206,10 @@ expand_omp_for_static_chunk (struct omp_region *region,
          source_location locus;

          phi = psi.phi ();
+         if (operand_equal_p (gimple_phi_arg_def (phi, 0),
+                              gimple_phi_arg_def (phi, 1), 0))
+             continue;
+
          t = gimple_phi_result (phi);
          gcc_assert (t == redirect_edge_var_map_result (vm));

...

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]