Bug 81987 - [8 Regression] ICE in verify_ssa with -O3 -march=skylake-avx512
Summary: [8 Regression] ICE in verify_ssa with -O3 -march=skylake-avx512
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2017-08-25 15:21 UTC by Vsevolod Livinskii
Modified: 2021-11-01 23:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-08-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vsevolod Livinskii 2017-08-25 15:21:42 UTC
g++ -O3 -march=skylake-avx512 fails with ICE in verify_ssa with error: definition in block 11 does not dominate use in block 2

There are several trackers with the same error message, but some of them fails only with -O2 -floop-nest-optimize option (69675, 79483), other were fixed (71252). So i don't know, if this bug is duplicate or not.

>$ cat repr.cpp
extern short var_1;
extern const short var_3;
extern unsigned long int var_9;
extern short var_13;
extern const unsigned long int var_15;
extern const unsigned long int var_37;
extern unsigned long int var_40;
extern long long int var_47;
extern short var_48;
extern const short var_54;
extern long long int var_79;
extern long long int var_81;
extern long long int var_94;
extern long long int var_95;
extern long long int var_701;
extern unsigned long int var_786;
extern short var_788;
extern long long int var_844;

struct struct_1 {
    short member_1_2 : 30;
    static long long int member_1_3;
};

extern struct_1 struct_obj_6;
extern struct_1 struct_obj_8;

void foo() {
  int a = var_3 <= 602154393864UL;
  if (var_81 ? 0 : var_3 && var_9)
    ;
  else {
    var_94 = 0;
    if (var_3 && var_48 || var_13) {
      if (var_48)
        var_95 = 0;
      short b((2364461588881776511UL + var_3) * (2 ? var_13 : 0) || var_1);
      struct_obj_8.member_1_2 = b;
      if (var_15) {
        if (var_81)
          if (var_47)
            ;
          else if (var_40)
            var_701 = 0;
      } else {
        if (var_40)
          var_79 = 0;
        if (var_54) {
          if (var_37)
            var_786 = 0;
          else
            var_788 = 0;
          struct_obj_6.member_1_3 =
              (2364461588881776511UL + var_3) * (2 ? var_13 : 0);
        }
      }
      if ((2364461588881776511UL + var_3) * (2 ? var_13 : 0))
        var_844 = 0;
    }
  }
}

Error:
>g++ -O3 -march=skylake-avx512 -c repr.cpp
repr.cpp: In function ‘void foo()’:
repr.cpp:28:6: error: definition in block 11 does not dominate use in block 2
 void foo() {
      ^~~
for SSA_NAME: _10 in statement:
slsr_104 = _10 * 2364461588881776511;
during GIMPLE pass: slsr
repr.cpp:28:6: internal compiler error: verify_ssa failed
0x1095c1b verify_ssa(bool, bool)
	/home/vsevolod/workspace/gcc-dev/trunk/gcc/tree-ssa.c:1188
0xd7ad1d execute_function_todo
	/home/vsevolod/workspace/gcc-dev/trunk/gcc/passes.c:1999
0xd7b619 execute_todo
	/home/vsevolod/workspace/gcc-dev/trunk/gcc/passes.c:2046

GCC version is 251301
Comment 1 Martin Liška 2017-08-28 07:46:28 UTC
Confirmed, started with r251264. Bit reduced test-case:

short b, c, d, f, k, l, s;
int e, g, h, i, j, m, n, o, p, q, r, t;
long u;
void
v ()
{
  int a = c <= 602154393864UL;
  if (n ? 0 : c && e)
    ;
  else
    {
      o = 0;
      if (c && f || d)
	{
	  if (f)
	    p = 0;
	  short w ((2364461588881776511UL + c) * (2 ? d : 0) || b);
	  s = w;
	  if (g)
	    {
	      if (n)
		if (j)
		  ;
		else if (i)
		  q = 0;
	    }
	  else
	    {
	      if (i)
		m = 0;
	      if (k)
		{
		  if (h)
		    r = 0;
		  else
		    l = 0;
		  u = (2364461588881776511UL + c) * (2 ? d : 0);
		}
	    }
	  if ((2364461588881776511UL + c) * (2 ? d : 0))
	    t = 0;
	}
    }
}
Comment 2 Richard Biener 2017-08-28 08:16:49 UTC
I will have a looksee.
Comment 3 Richard Biener 2017-08-28 09:25:00 UTC
It looks like the SLSR issue is latent before the change.  The change introduces IL differences in PRE:

   <bb 11> [54.69%] [count: INV]:
-  # prephitmp_66 = PHI <d.6_6(9), prephitmp_104(10), pretmp_105(30)>
-  pretmp_117 = _2;
-  pretmp_116 = c.0_1;
+  # prephitmp_72 = PHI <d.6_6(9), prephitmp_112(10), pretmp_113(33)>
+  # prephitmp_73 = PHI <c.0_1(9), c.0_1(10), c.0_1(33)>
+  # prephitmp_74 = PHI <_2(9), _2(10), _2(33)>

the first CFG difference appears after VRP1 where we see a predecessor
edge order difference.

--- a/t.c.104t.vrp1     2017-08-28 11:14:39.031605121 +0200
+++ b/t.c.104t.vrp1     2017-08-28 11:14:33.247510516 +0200
@@ -294,10 +294,10 @@
 ;;                7
 
 ;;   basic block 7, loop depth 0
-;;    pred:       28
-;;                6
+;;    pred:       6
+;;                28
 ;;                5
-  # .MEM_60 = PHI <.MEM_57(28), .MEM_59(6), .MEM_39(5)>
+  # .MEM_60 = PHI <.MEM_59(6), .MEM_57(28), .MEM_39(5)>
   # VUSE <.MEM_60>
   # rhs access alignment 16+0
   d.6_6 = d;

That's expected given we change the order we install edges in split_edge.

The PRE IL change is also somewhat expected as it uses post-order on the
inverted graph to compute ANTIC_IN and this order is dependent on the
order of edges in pred.  I will poke a bit to see why there's a difference
in what PRE finally does.

So Bill - can you look at the SLSR issue?
Comment 4 Bill Schmidt 2017-08-28 13:08:22 UTC
Sure, I'll try to get to this this week.
Comment 5 Bill Schmidt 2017-08-29 16:06:49 UTC
-march is not required.  This repros on powerpc64le-linux-gnu as well with just -O3.
Comment 6 Bill Schmidt 2017-08-30 18:53:01 UTC
Patch submitted here:  https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01743.html
Comment 7 Bill Schmidt 2017-08-30 20:04:39 UTC
Author: wschmidt
Date: Wed Aug 30 20:04:07 2017
New Revision: 251547

URL: https://gcc.gnu.org/viewcvs?rev=251547&root=gcc&view=rev
Log:
[gcc]

2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* gimple-ssa-strength-reduction.c (insert_initializers): Don't
	insert an initializer in a location not dominated by the stride
	definition.

[gcc/testsuite]

2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* g++.dg/torture/pr81987.C: New file.


Added:
    trunk/gcc/testsuite/g++.dg/torture/pr81987.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gimple-ssa-strength-reduction.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Bill Schmidt 2017-08-30 20:13:09 UTC
Fixed on trunk so far.  Holding this open until the fix is backported in about a week.
Comment 9 Bill Schmidt 2017-09-06 18:43:27 UTC
Author: wschmidt
Date: Wed Sep  6 18:42:56 2017
New Revision: 251815

URL: https://gcc.gnu.org/viewcvs?rev=251815&root=gcc&view=rev
Log:
[gcc]

2017-09-06  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline:
	2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* gimple-ssa-strength-reduction.c (insert_initializers): Don't
	insert an initializer in a location not dominated by the stride
	definition.

[gcc/testsuite]

2017-09-06  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline:
	2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* g++.dg/torture/pr81987.C: New file.


Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/torture/pr81987.C
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/gimple-ssa-strength-reduction.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
Comment 10 Bill Schmidt 2017-09-06 18:45:23 UTC
Author: wschmidt
Date: Wed Sep  6 18:44:51 2017
New Revision: 251816

URL: https://gcc.gnu.org/viewcvs?rev=251816&root=gcc&view=rev
Log:
[gcc]

2017-09-06  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline:
	2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* gimple-ssa-strength-reduction.c (insert_initializers): Don't
	insert an initializer in a location not dominated by the stride
	definition.

[gcc/testsuite]

2017-09-06  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline:
	2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* g++.dg/torture/pr81987.C: New file.


Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/torture/pr81987.C
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/gimple-ssa-strength-reduction.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 11 Bill Schmidt 2017-09-06 18:49:22 UTC
Author: wschmidt
Date: Wed Sep  6 18:48:50 2017
New Revision: 251817

URL: https://gcc.gnu.org/viewcvs?rev=251817&root=gcc&view=rev
Log:
[gcc]

2017-09-06  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline:
	2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* gimple-ssa-strength-reduction.c (insert_initializers): Don't
	insert an initializer in a location not dominated by the stride
	definition.

[gcc/testsuite]

2017-09-06  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline:
	2017-08-30  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/81987
	* g++.dg/torture/pr81987.C: New file.


Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/torture/pr81987.C
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/gimple-ssa-strength-reduction.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 12 Bill Schmidt 2017-09-06 18:50:00 UTC
Now fixed everywhere.  Thanks again for the report!