User account creation filtered due to spam.

Bug 65289 - [5/6/7/8 regression] ICE when compiling libjpegturbo with -floop-nest-optimize
Summary: [5/6/7/8 regression] ICE when compiling libjpegturbo with -floop-nest-optimize
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 5.0
: P4 major
Target Milestone: 5.5
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-03 00:36 UTC by Matt Hargett
Modified: 2016-07-12 21:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-12 00:00:00


Attachments
pre-processed source file that reproduces the crash (26.82 KB, text/plain)
2015-03-03 00:36 UTC, Matt Hargett
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Hargett 2015-03-03 00:36:58 UTC
Created attachment 34929 [details]
pre-processed source file that reproduces the crash

Using either Ubuntu's gcc-snapshot on amd64 and my armv6j cross-compiling toolchain, I get a crash when compiling libjpegturbo 1.4.0 from sources when using -floop-nest-optimize. Pre-processed source is attached (generated by cross-toolchain, but amd64 GCC reproduces same crash).

The crash does NOT happen with 4.9.1 from Ubuntu 14.10 on amd64.

Ubuntu version string: 
gcc (Ubuntu 20150225-1ubuntu1) 5.0.0 20150225 (experimental) [trunk revision 220970]

armv6j cross-compiler built from SVN version string:
arm-kindle-linux-gnueabi-gcc (GCC) 5.0.0 20150224 (experimental)

To reproduce:
CFLAGS="-O2 -floop-nest-optimize" CC=/path/to/gcc5/bin/gcc ./configure --disable-static --without-simd && make
.... or....
/path/to/gcc5/bin/gcc -O2 -floop-nest-optimize turbojpeg.c.i

result:

turbojpeg.c: In function 'tjCompress2':
turbojpeg.c:713:6: error: loop 3's latch is marked as part of irreducible region
 DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf,
      ^
turbojpeg.c:713:6: error: edge from 64 to 78 should be marked irreducible
turbojpeg.c:713:6: error: basic block 78 should be marked irreducible
turbojpeg.c:713:6: error: edge from 78 to 82 should be marked irreducible
turbojpeg.c:713:6: error: edge from 78 to 92 should be marked irreducible
turbojpeg.c:713:6: error: basic block 92 should be marked irreducible
turbojpeg.c:713:6: error: edge from 92 to 98 should be marked irreducible
turbojpeg.c:713:6: error: edge from 92 to 95 should be marked irreducible
turbojpeg.c:713:6: error: basic block 95 should be marked irreducible
turbojpeg.c:713:6: error: edge from 95 to 93 should be marked irreducible
turbojpeg.c:713:6: error: basic block 98 should be marked irreducible
turbojpeg.c:713:6: error: edge from 98 to 96 should be marked irreducible
turbojpeg.c:713:6: error: edge from 99 to 100 should be marked irreducible
turbojpeg.c:713:6: error: basic block 100 should be marked irreducible
turbojpeg.c:713:6: error: edge from 100 to 94 should be marked irreducible
turbojpeg.c:713:6: error: basic block 94 should be marked irreducible
turbojpeg.c:713:6: error: edge from 94 to 93 should be marked irreducible
turbojpeg.c:713:6: error: basic block 93 should be marked irreducible
turbojpeg.c:713:6: error: edge from 93 to 81 should be marked irreducible
turbojpeg.c:713:6: error: basic block 81 should be marked irreducible
turbojpeg.c:713:6: error: edge from 81 to 79 should be marked irreducible
turbojpeg.c:713:6: error: basic block 82 should be marked irreducible
turbojpeg.c:713:6: error: edge from 82 to 88 should be marked irreducible
turbojpeg.c:713:6: error: edge from 82 to 85 should be marked irreducible
turbojpeg.c:713:6: error: basic block 85 should be marked irreducible
turbojpeg.c:713:6: error: edge from 85 to 83 should be marked irreducible
turbojpeg.c:713:6: error: basic block 88 should be marked irreducible
turbojpeg.c:713:6: error: edge from 88 to 86 should be marked irreducible
turbojpeg.c:713:6: error: edge from 89 to 90 should be marked irreducible
turbojpeg.c:713:6: error: basic block 90 should be marked irreducible
turbojpeg.c:713:6: error: edge from 90 to 84 should be marked irreducible
turbojpeg.c:713:6: error: basic block 84 should be marked irreducible
turbojpeg.c:713:6: error: edge from 84 to 83 should be marked irreducible
turbojpeg.c:713:6: error: basic block 83 should be marked irreducible
turbojpeg.c:713:6: error: edge from 83 to 80 should be marked irreducible
turbojpeg.c:713:6: error: basic block 80 should be marked irreducible
turbojpeg.c:713:6: error: edge from 80 to 79 should be marked irreducible
turbojpeg.c:713:6: error: basic block 79 should be marked irreducible
turbojpeg.c:713:6: error: edge from 79 to 67 should be marked irreducible
turbojpeg.c:713:6: error: basic block 67 should be marked irreducible
turbojpeg.c:713:6: error: edge from 67 to 65 should be marked irreducible
turbojpeg.c:713:6: error: edge from 68 to 71 should be marked irreducible
turbojpeg.c:713:6: error: basic block 71 should be marked irreducible
turbojpeg.c:713:6: error: edge from 71 to 69 should be marked irreducible
turbojpeg.c:713:6: error: basic block 72 should not be marked irreducible
turbojpeg.c:713:6: error: edge from 72 to 77 should not be marked irreducible
turbojpeg.c:713:6: error: basic block 77 should not be marked irreducible
turbojpeg.c:713:6: error: edge from 77 to 75 should not be marked irreducible
turbojpeg.c:713:6: error: basic block 75 should not be marked irreducible
turbojpeg.c:713:6: error: edge from 75 to 76 should be marked irreducible
turbojpeg.c:713:6: error: basic block 73 should not be marked irreducible
turbojpeg.c:713:6: error: edge from 73 to 72 should not be marked irreducible
turbojpeg.c:713:6: error: basic block 76 should be marked irreducible
turbojpeg.c:713:6: error: edge from 76 to 70 should be marked irreducible
turbojpeg.c:713:6: internal compiler error: in verify_loop_structure, at cfgloop.c:1652
Comment 1 Matt Hargett 2015-03-03 00:45:41 UTC
Also reproducible with -O2 -fgraphite-identity .

I use both of these optimizations regularly to help get the most out of prefetch on the embedded ARM targets I work on.
Comment 2 Mikhail Maltsev 2015-03-03 08:21:11 UTC
Reduced test case, reproduces ICE for both sets of options (-O2 -fgraphite-identity and -O2 -floop-nest-optimize):

tjCompress2(srcBuf, height) {
  int i, *row_pointer;
  if (_setjmp())
    for (; i < height; i++)
      row_pointer[i] = srcBuf;
  jpeg_abort_compress();
}

Of course, this program now involves undefined behavior, but the error message is still the same as in the original one.

Here is another example:

void bar ();
int foo (char *dest, int i)
{
    _setjmp();
    while (i)
        dest[--i] = 0;
    bar();
}

./test1.c: In function 'foo':
./test1.c:2:5: error: loop 2's latch is marked as part of irreducible region
 int foo (char *dest, int i)
     ^
./test1.c:2:5: error: edge from 16 to 19 should be marked irreducible
./test1.c:2:5: error: basic block 19 should be marked irreducible
./test1.c:2:5: error: edge from 19 to 17 should be marked irreducible
./test1.c:2:5: error: basic block 20 should not be marked irreducible
./test1.c:2:5: error: edge from 20 to 25 should not be marked irreducible
./test1.c:2:5: error: basic block 25 should not be marked irreducible
./test1.c:2:5: error: edge from 25 to 23 should not be marked irreducible
./test1.c:2:5: error: basic block 23 should not be marked irreducible
./test1.c:2:5: error: edge from 23 to 24 should be marked irreducible
./test1.c:2:5: error: basic block 21 should not be marked irreducible
./test1.c:2:5: error: edge from 21 to 20 should not be marked irreducible
./test1.c:2:5: error: basic block 24 should be marked irreducible
./test1.c:2:5: error: edge from 24 to 18 should be marked irreducible
./test1.c:2:5: internal compiler error: in verify_loop_structure, at cfgloop.c:1652
Comment 3 Jeffrey A. Law 2015-03-03 15:55:45 UTC
Graphite issue, thus P4.
Comment 4 Jakub Jelinek 2015-04-22 11:57:59 UTC
GCC 5.1 has been released.
Comment 5 Richard Biener 2015-07-16 09:12:49 UTC
GCC 5.2 is being released, adjusting target milestone to 5.3.
Comment 6 Richard Biener 2015-12-04 10:46:00 UTC
GCC 5.3 is being released, adjusting target milestone.
Comment 7 Richard Biener 2016-06-03 10:05:52 UTC
GCC 5.4 is being released, adjusting target milestone.
Comment 8 Martin Liška 2016-07-12 21:18:14 UTC
I've just tried to reproduce the problem on x86_64-linux-gnu and I see:

4.9.x:
sorry, unimplemented: Graphite loop optimizations cannot be used

5.x:
ICE

6.1 and 7.0 look good, is it because I'm not using the cross-compiler, as you do?

Thanks