Bug 51070 - [4.6/4.7 Regression] ICE verify_gimple failed
Summary: [4.6/4.7 Regression] ICE verify_gimple failed
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.3
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-09 20:52 UTC by John Regehr
Modified: 2012-06-12 09:44 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.3, 4.7.0
Known to fail: 4.4.6, 4.5.3, 4.6.2
Last reconfirmed: 2011-11-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2011-11-09 20:52:03 UTC
[regehr@gamow tmp057]$ current-gcc -v


Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r181229-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --with-libelf=/usr/local --enable-lto --prefix=/home/regehr/z/compiler-install/gcc-r181229-install --program-prefix=r181229- --enable-languages=c,c++
Thread model: posix
gcc version 4.7.0 20111109 (experimental) (GCC) 


[regehr@gamow tmp057]$ current-gcc -Ofast -c -w small.c 


small.c: In function 'func_9':
small.c:24:1: error: invalid PHI argument
.MEM_3
small.c:24:1: error: incompatible types in PHI argument 0
int

void

g_95_I_lsm.15_29 = PHI <.MEM_3(5)>

small.c:24:1: internal compiler error: verify_gimple failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


[regehr@gamow tmp057]$ cat small.c


int
func_4 (int si1, int si2)
{
  return si1;
}

int
func_14 (int left, int right)
{
  return 1;
}

int
func_37 (int left, int right)
{
  return left;
}

int g_92[];
int g_95[];
int g_224;
int g_352[];
int
func_9 ()
{
  for (; g_224; g_224 += 1)
    {
      g_95[0] = func_4 (func_37 (g_92[g_224], 0), 0);
      g_92[g_224] = 0, g_352[g_224] = func_14 (0, 0);
    }
  return 0;
}
Comment 1 Richard Biener 2011-11-10 10:59:37 UTC
Catched by copyprop, caused by loop distributions memset replacement.  Fails
in random ways on all branches that have loop distribution.  A regression
with -O3 (enabled by default) since 4.6.
Comment 2 Richard Biener 2011-11-10 12:00:41 UTC
For

<bb 5>:
  # g_224.0_23 = PHI <g_224.1_10(7), g_224.0_22(4)>
  # MEM = PHI <MEM, MEM>
  D.2957_3 = g_92[g_224.0_23];
  g_92[g_224.0_23] = 0;
  g_352[g_224.0_23] = 1;
  g_224.1_10 = g_224.0_23 + 1;
  if (g_224.1_10 != 0)
    goto <bb 7>;
  else
    goto <bb 6>;

<bb 6>:
  # g_95_I_lsm.15_29 = PHI <D.2957_3(5)>
  g_95[0] = g_95_I_lsm.15_29;
  g_224 = 0;
  goto <bb 3>;

<bb 7>:
  goto <bb 5>;

we generate partitions

{ 0 1 2 3 5 6 } and { 0 4 5 6 }

note that the partition with the zero store also includes the
load from g_92[g_224.0_23] which has a use outside of the loop.
We cannot generate a memset replacement for this with the current code.

I have a patch.
Comment 3 Richard Biener 2011-11-10 13:46:35 UTC
Author: rguenth
Date: Thu Nov 10 13:46:27 2011
New Revision: 181255

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181255
Log:
2011-11-10  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/51070
	* tree-loop-distribution.c (generate_builtin): Do not replace
	the loop with a builtin if the partition contains statements which
	results are used outside of the loop.
	(pass_loop_distribution): Verify and collect.

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

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr51070.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-loop-distribution.c
Comment 4 Richard Biener 2011-11-10 13:47:01 UTC
Fixed for 4.7 for now.
Comment 5 Zdenek Sojka 2011-12-31 08:49:48 UTC
The testcase fails with -O3 -fno-inline or with -O3 when func_37() is declared with __attribute__((noinline)).

Compiler output:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/mnt/svn/gcc-trunk/binary-latest/bin/gcc
COLLECT_LTO_WRAPPER=/mnt/svn/gcc-trunk/binary-182733-lto-fortran-checking-yes-rtl-df/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /mnt/svn/gcc-trunk//configure --enable-checking=yes,rtl,df --enable-languages=c,c++,lto,fortran --prefix=/mnt/svn/gcc-trunk/binary-182733-lto-fortran-checking-yes-rtl-df/ --with-cloog --with-ppl --with-cloog-include=/usr/include/cloog-ppl/ --disable-ppl-version-check
Thread model: posix
gcc version 4.7.0 20111229 (experimental) (GCC) 

$ gcc -O3 -fno-inline gcc.dg/torture/pr51070.c
gcc.dg/torture/pr51070.c: In function 'func_9':
gcc.dg/torture/pr51070.c:26:1: error: invalid PHI argument
.MEM_5
gcc.dg/torture/pr51070.c:26:1: error: incompatible types in PHI argument 0
int

void

g_95_I_lsm.22_32 = PHI <.MEM_5(5)>

gcc.dg/torture/pr51070.c:26:1: internal compiler error: verify_gimple failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

I didn't open a new PR because the ICE message is the same and the conditions under which it happens are very similiar. Of course, I will open a new PR if you tell me so.
Comment 6 Richard Biener 2012-01-02 09:08:52 UTC
Confirmed.
Comment 7 Richard Biener 2012-01-03 12:07:22 UTC
Author: rguenth
Date: Tue Jan  3 12:07:18 2012
New Revision: 182839

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182839
Log:
2012-01-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/51070
	* tree-loop-distribution.c (stmt_has_scalar_dependences_outside_loop):
	Properly handle calls.

	* gcc.dg/torture/pr51070-2.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr51070-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-loop-distribution.c
Comment 8 Richard Biener 2012-01-03 12:11:49 UTC
Author: rguenth
Date: Tue Jan  3 12:11:41 2012
New Revision: 182840

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182840
Log:
2012-01-03  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/51070
        * tree-loop-distribution.c (generate_builtin): Do not replace
        the loop with a builtin if the partition contains statements which
        results are used outside of the loop.
        (stmt_has_scalar_dependences_outside_loop): Properly handle calls.

        * gcc.dg/torture/pr51070.c: New testcase.
        * gcc.dg/torture/pr51070-2.c: Likewise.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070-2.c
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-loop-distribution.c
Comment 9 Richard Biener 2012-01-03 12:12:13 UTC
Fixed.
Comment 10 Jiangning Liu 2012-06-12 09:44:28 UTC
Author: liujiangning
Date: Tue Jun 12 09:44:24 2012
New Revision: 188432

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188432
Log:
2011-06-12  Jiangning Liu  <jiangning.liu@arm.com>                                                        

	Backport r182839 from mainline
	2012-01-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/51070
	* tree-loop-distribution.c (generate_builtin): Do not replace
	the loop with a builtin if the partition contains statements which
	results are used outside of the loop.
	(stmt_has_scalar_dependences_outside_loop): Properly handle calls.

2011-06-12  Jiangning Liu  <jiangning.liu@arm.com>                                                        

	Backport r182839 from mainline
	2012-01-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/51070
	* gcc.dg/torture/pr51070.c: New testcase.
	* gcc.dg/torture/pr51070-2.c: Likewise.


Added:
    branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070-2.c
    branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.dg/torture/pr51070.c
Modified:
    branches/ARM/embedded-4_6-branch/gcc/ChangeLog.arm
    branches/ARM/embedded-4_6-branch/gcc/testsuite/ChangeLog.arm
    branches/ARM/embedded-4_6-branch/gcc/tree-loop-distribution.c