Bug 52891 - [4.8 Regression] ICE in adjust_bool_pattern
Summary: [4.8 Regression] ICE in adjust_bool_pattern
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-06 17:16 UTC by Antoine Balestrat
Modified: 2012-04-24 17:19 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-04-10 00:00:00


Attachments
gcc48-pr52891.patch (771 bytes, patch)
2012-04-20 12:58 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Balestrat 2012-04-06 17:16:29 UTC
I seem to have triggered a bug in the tree vectorizer of GCC as of 20120404.

$ cat file.c

struct S1
{
    int intfield;

    struct
    {
        unsigned ufield:10;
    } sfield;
};

int func2(short param1, short param2)
{
    int **intptr;

    if((param1 && param2) + **intptr)
	    while(1);
}

void func1(void)
{
    struct S1 foo;
    func2(foo.intfield, foo.sfield.ufield);
}

$ ~/gcc/dist/bin/gcc --version

gcc (GCC) 4.8.0 20120404 (experimental)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ~/gcc/dist/bin/gcc -O2 -ftree-vectorize file.c


Using built-in specs.
COLLECT_GCC=/home/merkil/gcc/dist/bin/gcc
COLLECT_LTO_WRAPPER=/home/merkil/gcc/dist/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../srcdir/configure --prefix=/home/merkil/gcc/dist CFLAGS=' -O2 -pipe' CXXFLAGS=' -O2 -pipe' --enable-languages=c,c++,lto
Thread model: posix
gcc version 4.8.0 20120404 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-O2' '-ftree-vectorize' '-v' '-mtune=generic' '-march=x86-64'
 /home/merkil/gcc/dist/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/cc1 -quiet -v file.c -quiet -dumpbase file.c -mtune=generic -march=x86-64 -auxbase file -O2 -version -ftree-vectorize -o /tmp/ccuzSuSy.s
GNU C (GCC) version 4.8.0 20120404 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.8.0 20120404 (experimental), GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "/home/merkil/gcc/dist/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/merkil/gcc/dist/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include
 /usr/local/include
 /home/merkil/gcc/dist/include
 /home/merkil/gcc/dist/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include-fixed
 /usr/include
End of search list.
GNU C (GCC) version 4.8.0 20120404 (experimental) (x86_64-unknown-linux-gnu)
	compiled by GNU C version 4.8.0 20120404 (experimental), GMP version 5.0.4, MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 77c744b2fbaa15d9025679f4b671f18a
file.c: In function 'func1':
file.c:19:6: internal compiler error: in adjust_bool_pattern, at tree-vect-patterns.c:2301
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Hope that is useful to you :-)
Comment 1 Richard Biener 2012-04-10 12:08:01 UTC
Confirmed.
Comment 2 John Regehr 2012-04-10 14:08:41 UTC
Another small testcase, if that's helpful.

[regehr@dyson r18]$ cat small.c 
#pragma pack(1)
struct S2
{
    unsigned f0:22;
};
struct
{
    struct S2 f0;
} c;
int a, b, d;
void
fn1 ()
{
    if (1 ? (!c.f0.f0 & d < 0) < a : 0)
        b = 0;
}


[regehr@dyson r18]$ current-gcc -O3 -c small.c
small.c: In function 'fn1':
small.c:12:1: internal compiler error: in adjust_bool_pattern, at tree-vect-patterns.c:2301
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


[regehr@dyson r18]$ current-gcc -v
Using built-in specs.
COLLECT_GCC=current-gcc
COLLECT_LTO_WRAPPER=/uusoc/exports/scratch/regehr/z/compiler-install/gcc-r186257-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.8.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-r186257-install --program-prefix=r186257- --enable-languages=c,c++
Thread model: posix
gcc version 4.8.0 20120410 (experimental) (GCC)
Comment 3 Jakub Jelinek 2012-04-20 12:58:28 UTC
Created attachment 27202 [details]
gcc48-pr52891.patch

Untested fix.  Sorry for the delay.
Comment 4 Jakub Jelinek 2012-04-23 10:13:46 UTC
Author: jakub
Date: Mon Apr 23 10:13:39 2012
New Revision: 186694

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186694
Log:
	PR tree-optimizations/52891
	* tree-vect-patterns.c (adjust_bool_pattern): Use
	build_nonstandard_type even if rhs1 has unsigned INTEGER_TYPE,
	but with non-standard precision.

	* gcc.c-torture/compile/pr52891-1.c: New test.	
	* gcc.c-torture/compile/pr52891-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c
    trunk/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-patterns.c
Comment 5 Jakub Jelinek 2012-04-23 10:17:08 UTC
Author: jakub
Date: Mon Apr 23 10:16:57 2012
New Revision: 186695

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186695
Log:
	PR tree-optimizations/52891
	* tree-vect-patterns.c (adjust_bool_pattern): Use
	build_nonstandard_type even if rhs1 has unsigned INTEGER_TYPE,
	but with non-standard precision.

	* gcc.c-torture/compile/pr52891-1.c: New test.	
	* gcc.c-torture/compile/pr52891-2.c: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c
    branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-vect-patterns.c
Comment 6 Jakub Jelinek 2012-04-24 11:47:12 UTC
Fixed.
Comment 7 Georg-Johann Lay 2012-04-24 17:08:28 UTC
Author: gjl
Date: Tue Apr 24 17:08:20 2012
New Revision: 186775

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186775
Log:
	PR testsuite/52641
	PR tree-optimizations/52891
	* gcc.c-torture/compile/pr52891-2.c: Fix test for 16-bit int.


Modified:
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c
Comment 8 Georg-Johann Lay 2012-04-24 17:19:03 UTC
Author: gjl
Date: Tue Apr 24 17:18:54 2012
New Revision: 186776

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186776
Log:
	PR testsuite/52641
	PR tree-optimizations/52891
	* gcc.c-torture/compile/pr52891-2.c: Fix test for 16-bit int.


Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c