Bug 82129 - [8 Regression] ICE in compute_antic, at tree-ssa-pre.c:2447
Summary: [8 Regression] ICE in compute_antic, at tree-ssa-pre.c:2447
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:
 
Reported: 2017-09-07 10:32 UTC by Arseny Solokha
Modified: 2017-10-30 12:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-09-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2017-09-07 10:32:19 UTC
gcc-8.0.0-alpha20170903 snapshot (r251628) ICEs when compiling the following snippet w/ -O2, -O3, or -Ofast:

int pj;

void
g4 (unsigned long int *bc, unsigned long int *h5)
{
  if (pj != 0)
    {
      int ib = 0;

      while (bc != 0)
        {
 m6:
          for (pj = 0; pj < 2; ++pj)
            pj = 0;

          while (pj != 0)
            {
              for (;;)
                {
                }

              while (ib != 0)
                {
                  unsigned long int tv = *bc;
                  unsigned long int n7;

                  *bc = 1;
                  while (*bc != 0)
                    {
                    }

 ut:
                  if (pj == 0)
                    n7 = *h5 > 0;
                  else
                    {
                      *h5 = tv;
                      n7 = *h5;
                    }
                  ib += n7;
                }
            }
        }

      goto ut;
    }

  goto m6;
}

% gcc-8.0.0-alpha20170903 -O2 -c vbgefb2z.c                         
during GIMPLE pass: pre
vbgefb2z.c: In function 'g4':
vbgefb2z.c:4:1: internal compiler error: in compute_antic, at tree-ssa-pre.c:2447
 g4 (unsigned long int *bc, unsigned long int *h5)
 ^~
Comment 1 Martin Liška 2017-09-07 11:14:48 UTC
Confirmed, started with r249063.
Comment 2 Richard Biener 2017-09-07 11:15:35 UTC
Hum...
Comment 3 Richard Biener 2017-09-12 12:36:14 UTC
Not yet analyzed but I see LIM performs store-motion on

   <bb 8> [0.00%] [count: INV] [loop 5 header]:
-  *h5_26(D) = tv_24(D);
+  h5__lsm.7_18 = tv_24(D);

where I think stores from undefined SSA names could be turned into CLOBBERs.

"Fixes" the testcase.

Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c   (revision 252002)
+++ gcc/gimple-fold.c   (working copy)
@@ -410,6 +410,16 @@ fold_gimple_assign (gimple_stmt_iterator
 
        else if (DECL_P (rhs))
          return get_symbol_constant_value (rhs);
+
+       else if (TREE_CODE (rhs) == SSA_NAME
+                && SSA_NAME_IS_DEFAULT_DEF (rhs)
+                && ! ssa_defined_default_def_p (rhs)
+                && gimple_store_p (stmt))
+         {
+           tree clobber = build_constructor (TREE_TYPE (rhs), NULL);
+           TREE_THIS_VOLATILE (clobber) = true;
+           return clobber;
+         }
       }
       break;
Comment 4 Richard Biener 2017-10-20 13:42:24 UTC
So we oscillate in the expression set because we "randomly" take expressions when intersecting ANTIC_OUT.  Both keeping all and canonicalizing to lowest expression ID fixes this.

Testing patch.
Comment 5 Richard Biener 2017-10-23 09:20:46 UTC
Author: rguenth
Date: Mon Oct 23 09:20:14 2017
New Revision: 253998

URL: https://gcc.gnu.org/viewcvs?rev=253998&root=gcc&view=rev
Log:
2017-10-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82129
	* tree-ssa-pre.c (bitmap_set_and): Remove.
	(compute_antic_aux): Compute ANTIC_OUT intersection in a way
	canonicalizing expressions in the set to those with lowest
	ID rather than taking that from the first edge.

	* gcc.dg/torture/pr82129.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr82129.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c
Comment 6 Richard Biener 2017-10-23 09:21:58 UTC
Fixed.
Comment 7 Richard Biener 2017-10-23 11:15:23 UTC
Author: rguenth
Date: Mon Oct 23 11:14:40 2017
New Revision: 254005

URL: https://gcc.gnu.org/viewcvs?rev=254005&root=gcc&view=rev
Log:
2017-10-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82129
	Revert
	2017-08-01  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81181
	* tree-ssa-pre.c (compute_antic_aux): Defer clean() to ...
	(compute_antic): ... end of iteration here.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-pre.c
Comment 8 Richard Biener 2017-10-30 12:46:25 UTC
Author: rguenth
Date: Mon Oct 30 12:45:53 2017
New Revision: 254218

URL: https://gcc.gnu.org/viewcvs?rev=254218&root=gcc&view=rev
Log:
2017-10-30  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82762
	Revert
	2017-10-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82129
	Revert
	2017-08-01  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81181
	* tree-ssa-pre.c (compute_antic_aux): Defer clean() to ...
	(compute_antic): ... end of iteration here.

	* gcc.dg/torture/pr82762.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr82762.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c