Bug 72778 - [7 Regression] internal compiler error: in create_pre_exit, at mode-switching.c:451
Summary: [7 Regression] internal compiler error: in create_pre_exit, at mode-switching...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: 7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-08-02 18:26 UTC by H.J. Lu
Modified: 2016-08-04 08:15 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-08-03 00:00:00


Attachments
Preprocessed source (25.61 KB, application/x-bzip2)
2016-08-03 10:47 UTC, Uroš Bizjak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2016-08-02 18:26:18 UTC
On x86, r238991 caused:

[hjl@gnu-6 gcc]$ ./xgcc -B./ /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc -S -O2 -fcheck-pointer-bounds -mmpx -mavx
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc: In function ‘c1 test.chkp(c2, #‘pointer_bounds_type’ not supported by dump_type#<type error>, void, ...)’:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/mpx/pr66048.cc:16:1: internal compiler error: in create_pre_exit, at mode-switching.c:451
 }
 ^
0x1b3e104 create_pre_exit
	/export/gnu/import/git/sources/gcc/gcc/mode-switching.c:437
0x1b3e377 optimize_mode_switching
	/export/gnu/import/git/sources/gcc/gcc/mode-switching.c:534
0x1b3f6a6 execute
	/export/gnu/import/git/sources/gcc/gcc/mode-switching.c:892
0xfe1176 gcc::pass_manager::execute_pass_mode_switching()
	/export/gnu/import/git/sources/gcc/gcc/passes.c:123
0x14d5a3a rest_of_handle_insert_vzeroupper
	/export/gnu/import/git/sources/gcc/gcc/config/i386/i386.c:2685
0x14d95d2 execute
	/export/gnu/import/git/sources/gcc/gcc/config/i386/i386.c:4068
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
[hjl@gnu-6 gcc]$
Comment 1 Vladimir Makarov 2016-08-02 19:22:10 UTC
H.J., thanks for reporting this.

I am planning to fix it today.
Comment 2 Vladimir Makarov 2016-08-02 20:57:35 UTC
Author: vmakarov
Date: Tue Aug  2 20:57:04 2016
New Revision: 239000

URL: https://gcc.gnu.org/viewcvs?rev=239000&root=gcc&view=rev
Log:
2016-08-02  Vladimir Makarov  <vmakarov@redhat.com>

	PR middle-end/72778
	* lra-spills.c (regno_in_use_p): New.
	(lra_final_code_change): Use it.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lra-spills.c
Comment 3 Uroš Bizjak 2016-08-03 10:46:48 UTC
The fix is not complete, I still get bootstrap failure with the above ICE when building libgo with compiler, configured with "--with-arch=core-avx-i --with-cpu=core-avx-i".

To be attached preprocessed source illustrates the problem.

./cc1 -O2 -fplan9-extensions -fexceptions -fnon-call-exceptions -march=core-avx2 -fpreprocessed -quiet sema.i

/home/uros/gcc-svn/trunk/libgo/runtime/sema.goc: In function ‘sync_runtime_notifyListAdd’:
/home/uros/gcc-svn/trunk/libgo/runtime/sema.goc:347:1: internal compiler error: in create_pre_exit, at mode-switching.c:451
 
 ^
0x12a6e8e create_pre_exit
        /home/uros/gcc-svn/trunk/gcc/mode-switching.c:437
0x12a6e8e optimize_mode_switching
        /home/uros/gcc-svn/trunk/gcc/mode-switching.c:534
0x12a6e8e execute
        /home/uros/gcc-svn/trunk/gcc/mode-switching.c:892
0xe475fd rest_of_handle_insert_vzeroupper
        /home/uros/gcc-svn/trunk/gcc/config/i386/i386.c:2685
0xe475fd execute
        /home/uros/gcc-svn/trunk/gcc/config/i386/i386.c:4068
Please submit a full bug report,
...
Comment 4 Uroš Bizjak 2016-08-03 10:47:21 UTC
Created attachment 39050 [details]
Preprocessed source
Comment 5 Uroš Bizjak 2016-08-03 11:40:49 UTC
single_set does not detect

(insn 6 19 7 2 (parallel [
            (set (reg:SI 0 ax [orig:88 _5 ] [88])
                (unspec_volatile:SI [
                        (mem/v:SI (reg/v/f:DI 5 di [orig:90 l ] [90]) [-1  S4 A32])
                        (const_int 32773 [0x8005])
                    ] UNSPECV_XCHG))
            (set (mem/v:SI (reg/v/f:DI 5 di [orig:90 l ] [90]) [-1  S4 A32])
                (plus:SI (mem/v:SI (reg/v/f:DI 5 di [orig:90 l ] [90]) [-1  S4 A32])
                    (reg:SI 0 ax [orig:88 _5 ] [88])))
            (clobber (reg:CC 17 flags))
        ]) /home/uros/gcc-svn/trunk/libgo/runtime/sema.goc:345 4933 {atomic_fetch_addsi}
     (nil))

as a single-set insn.
Comment 6 Uroš Bizjak 2016-08-03 12:25:39 UTC
Before the patch, register allocator used to leave self-assignments (e.g. insn 20) in the insn stream. Post-reload vzeroupper insertion mode-swithing pass depends on these instructions. Self-assignments are later removed by subsequent passes.

...
(insn 6 19 20 2 (parallel [
            (set (reg:SI 0 ax [orig:88 _5 ] [88])
                (unspec_volatile:SI [
                        (mem/v:SI (reg/v/f:DI 5 di [orig:90 l ] [90]) [-1  S4 A32])
                        (const_int 32773 [0x8005])
                    ] UNSPECV_XCHG))
            (set (mem/v:SI (reg/v/f:DI 5 di [orig:90 l ] [90]) [-1  S4 A32])
                (plus:SI (mem/v:SI (reg/v/f:DI 5 di [orig:90 l ] [90]) [-1  S4 A32])
                    (reg:SI 0 ax [orig:88 _5 ] [88])))
            (clobber (reg:CC 17 flags))
        ]) /home/uros/gcc-svn/trunk/libgo/runtime/sema.goc:345 4933 {atomic_fetch_addsi}
     (nil))
(insn 20 6 7 2 (set (reg:SI 0 ax [orig:88 _5 ] [88])
        (reg:SI 0 ax [orig:88 _5 ] [88])) /home/uros/gcc-svn/trunk/libgo/runtime/sema.goc:345 82 {*movsi_internal}
     (nil))
...

Can we have these self-assignments back?
Comment 7 Vladimir Makarov 2016-08-03 18:03:45 UTC
(In reply to Uroš Bizjak from comment #6)

Hi, Uros. Thanks for reporting this.  It was my mistake that I did not check bootstrap with GO.  I am going to fix it soon.

> Before the patch, register allocator used to leave self-assignments (e.g.
> insn 20) in the insn stream. Post-reload vzeroupper insertion mode-swithing
> pass depends on these instructions. Self-assignments are later removed by
> subsequent passes.
> 
> 
> Can we have these self-assignments back?

Unfortunately, LRA can produce wrong moves (it was even before I implemented invariant inheritance which also can do it).  It is important to remove them at this stage, otherwise GCC crashes on later passes.
Comment 8 Vladimir Makarov 2016-08-03 18:55:21 UTC
Author: vmakarov
Date: Wed Aug  3 18:54:49 2016
New Revision: 239091

URL: https://gcc.gnu.org/viewcvs?rev=239091&root=gcc&view=rev
Log:
2016-08-03  Vladimir Makarov  <vmakarov@redhat.com>

	PR middle-end/72778
	* lra-spills.c (regno_in_use_p): Check bb and regno modification.
	Don't stop on regular insns.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lra-spills.c
Comment 9 Uroš Bizjak 2016-08-04 08:15:32 UTC
(In reply to Vladimir Makarov from comment #7)
> (In reply to Uroš Bizjak from comment #6)
> 
> Hi, Uros. Thanks for reporting this.  It was my mistake that I did not check
> bootstrap with GO.  I am going to fix it soon.

Yes, the patch fixes bootstrap problem (all default languages + obj-c++ and go) for build with ivybridge default cpu and architecture.

Thanks!