[Bug tree-optimization/77362] New: [7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] New: [7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

            Bug ID: 77362
           Summary: [7 Regression] [graphite] ICE in
                    sese_build_liveouts_use w/ -O2 -floop-nest-optimize
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---

gcc-7.0.0-alpha20160821 and some earlier snapshots (at least back to
7.0.0-alpha20160731) ICE when compiling the following snippet w/ -O2 (-O3,
-Ofast) -floop-nest-optimize:

int mc[2];
int f2, sk;
short int hm;

void
zm (void)
{
  int k1;

  for (k1 = 0; k1 < 2; ++k1)
    {
      for (sk = 0; sk < 2; ++sk)
        mc[sk] = hm = ++f2;
      if (hm >= 0)
        ++hm;
    }
}

% gcc-7.0.0-alpha20160821 -O2 -floop-nest-optimize -c rzmadogh.c  
rzmadogh.c: In function 'zm':
rzmadogh.c:6:1: internal compiler error: Segmentation fault

Backtrace is seemingly different for different targets, nevertheless
sese_build_liveouts_use is always on top. For x86_64 I have:

#0  0x00000000012ff0b1 in sese_build_liveouts_use(sese_info_t*, bitmap_head*,
basic_block_def*, tree_node*) ()
#1  0x00000000012ff87c in sese_insert_phis_for_liveouts(sese_info_t*,
basic_block_def*, edge_def*, edge_def*) ()
#2  0x000000000126859a in graphite_regenerate_ast_isl(scop*) ()
#3  0x000000000125edac in graphite_transform_loops() ()
#4  0x000000000125f2c1 in (anonymous
namespace)::pass_graphite_transforms::execute(function*) ()
#5  0x0000000000a8e236 in execute_one_pass(opt_pass*) ()
#6  0x0000000000a8e848 in execute_pass_list_1(opt_pass*) ()
#7  0x0000000000a8e85a in execute_pass_list_1(opt_pass*) ()
#8  0x0000000000a8e85a in execute_pass_list_1(opt_pass*) ()
#9  0x0000000000a8e85a in execute_pass_list_1(opt_pass*) ()
#10 0x0000000000a8e8a5 in execute_pass_list(function*, opt_pass*) ()
#11 0x000000000076e004 in cgraph_node::expand() ()
#12 0x000000000076f9a7 in symbol_table::compile() [clone .part.47] ()
#13 0x0000000000771c78 in symbol_table::finalize_compilation_unit() ()
#14 0x0000000000b5fd9d in compile_file() ()
#15 0x00000000005ced77 in toplev::main(int, char**) ()
#16 0x00000000005d10a7 in main ()
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-08-24
      Known to work|                            |5.4.1
   Target Milestone|---                         |6.3
            Summary|[7 Regression] [graphite]   |[6/7 Regression] [graphite]
                   |ICE in                      |ICE in
                   |sese_build_liveouts_use w/  |sese_build_liveouts_use w/
                   |-O2 -floop-nest-optimize    |-O2 -floop-nest-optimize
     Ever confirmed|0                           |1
      Known to fail|                            |6.1.0

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Also crashes on the GCC 6 branch, works with GCC 5 it seems.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Jeffrey A. Law <law at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |law at redhat dot com
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.3                         |6.4

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6.3 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Problem is that original PHI node that we want to copy lives in a single loop:

  <bb 12>:
  _13 = f2_lsm.11_24 + 2;
  _59 = (unsigned short) f2_lsm.11_24;
  _20 = _59 + 2;
  _58 = (unsigned short) _20;
  _21 = (short int) _58;
  if (_21 >= 0)
    goto <bb 7>;
  else
    goto <bb 8>;

  <bb 7>:
  hm.8_8 = (unsigned short) _21;
  _9 = hm.8_8 + 1;
  _10 = (short int) _9;

  <bb 8>:
  # hm_lsm.13_12 = PHI <_21(12), _10(7)>
  k1_22 = k1_28 + 1;
  if (k1_22 != 2)
    goto <bb 9>;
  else
    goto <bb 10>;

So applying following patch would trigger that earlier:
diff --git a/gcc/graphite-isl-ast-to-gimple.c
b/gcc/graphite-isl-ast-to-gimple.c
index fb9c8468ebc..b3f72010507 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -1826,7 +1826,7 @@ get_loc (tree op)
 std::pair<edge, edge>
 get_edges (basic_block bb)
 {
-  std::pair<edge, edge> edges;
+  std::pair<edge, edge> edges (NULL, NULL);
   edge e;
   edge_iterator ei;
   FOR_EACH_EDGE (e, ei, bb->preds)
@@ -1834,14 +1834,17 @@ get_edges (basic_block bb)
       edges.first = e;
     else
       edges.second = e;
+
+  gcc_checking_assert (edges.first != NULL);
+  gcc_checking_assert (edges.second != NULL);
+
   return edges;
 }

As I've been reading the transformed loop nest, I don't know how to fix that
copied PHI.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spop at gcc dot gnu.org
      Known to fail|                            |7.0

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r230567.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |marxin at gcc dot gnu.org

--- Comment #5 from Martin Liška <marxin at gcc dot gnu.org> ---
Reading the first commit, looks I've got patch for that :)
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
Created attachment 40623
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40623&action=edit
Patch candidate

The patch fixes issue, however I believe that PHI handling is in general broken
in graphite since r236440. This PR is very similar to PR71351. Both are
confused by PHI nodes created by LIM.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

--- Comment #7 from Sebastian Pop <spop at gcc dot gnu.org> ---
The fix looks good.  Thanks!
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

--- Comment #8 from Sebastian Pop <spop at gcc dot gnu.org> ---
LIM in general is bad for loop transforms: it introduces loop carried
dependences. If we can move graphite before LIM that would solve some problems.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Sebastian Pop from comment #8)
> LIM in general is bad for loop transforms: it introduces loop carried
> dependences. If we can move graphite before LIM that would solve some
> problems.

Yeah, but the user can write such dependences himself so ideally we have
a way to undo them, like by using local scratch memory?  So

  x_0 = 1;

loop:
  # x_1 = PHI <x_0, x_2>
  ...
  x_2 = ...;
  goto loop;

turns into

  mem = 1;

loop:
  x_1 = mem;
  x_2 = ...;
  mem = x_2;
  goto loop;

plus replacement of exit PHIs with loads.  Would that help?  Or does the
new (non-aliased, loop invariant) memory location complicate things as well?
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

--- Comment #10 from Sebastian Pop <spop at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #9)
> Yeah, but the user can write such dependences himself so ideally we have
> a way to undo them, like by using local scratch memory?  So

You are right.  LLVM-Polly has a pass that undoes LIM, it is non trivial, and
furthermore we'd better catch the LIM once the loop transforms are done!

>
>   x_0 = 1;
>
> loop:
>   # x_1 = PHI <x_0, x_2>
>   ...
>   x_2 = ...;
>   goto loop;
>
> turns into
>
>   mem = 1;
>  
> loop:
>   x_1 = mem;
>   x_2 = ...;
>   mem = x_2;
>   goto loop;
>
> plus replacement of exit PHIs with loads.  Would that help?

That's how we were handling reductions and end of loop values in the dependence
graph.  Today we can reason about scalars themselves and add the scalars to the
dependence graph instead of generating the loads that would need to be cleaned
up after graphite.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7/8 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.4                         |6.5

--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 6.4 is being released, adjusting target milestone.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
      Known to work|                            |8.0
            Summary|[6/7/8 Regression]          |[6/7 Regression] [graphite]
                   |[graphite] ICE in           |ICE in
                   |sese_build_liveouts_use w/  |sese_build_liveouts_use w/
                   |-O2 -floop-nest-optimize    |-O2 -floop-nest-optimize

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
Seems to be fixed on trunk, will add the testcase, so this is probably a dup
(don't know exactly what rev. fixed it but I did fix quite a few PHI handling
issues).
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
On trunk we do hit a code generation error btw.
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Wed Sep 20 11:21:23 2017
New Revision: 253006

URL: https://gcc.gnu.org/viewcvs?rev=253006&root=gcc&view=rev
Log:
2017-09-20  Richard Biener  <[hidden email]>

        PR tree-optimization/77362
        * gcc.dg/graphite/pr77362.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/graphite/pr77362.c
Modified:
    trunk/gcc/testsuite/ChangeLog
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [6/7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|6.5                         |7.4

--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 6 branch is being closed
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|7.4                         |7.5
Reply | Threaded
Open this post in threaded view
|

[Bug tree-optimization/77362] [7 Regression] [graphite] ICE in sese_build_liveouts_use w/ -O2 -floop-nest-optimize

msebor at gcc dot gnu.org
In reply to this post by msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77362

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|7.5                         |8.0
      Known to fail|                            |7.5.0

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC8.