Bug 88051 - internal compiler error: in add_clobbers, at config/i386/sync.md:1762
Summary: internal compiler error: in add_clobbers, at config/i386/sync.md:1762
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 7.4
Assignee: Uroš Bizjak
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2018-11-15 20:17 UTC by Jan
Modified: 2023-05-20 05:33 UTC (History)
0 users

See Also:
Host:
Target: i?86-linux-gnu
Build:
Known to work: 8.2.0
Known to fail: 9.0
Last reconfirmed: 2018-11-15 00:00:00


Attachments
preprocessed source (143.10 KB, application/x-bzip)
2018-11-15 20:17 UTC, Jan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan 2018-11-15 20:17:42 UTC
Created attachment 45015 [details]
preprocessed source

happens with ffmpeg 4.1

ICE seems to be related to -m32 with -march=skylake-avx512

x86_64-pc-linux-gnu-gcc -m32 -I. -Isrc/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DZLIB_CONST -DHAVE_AV_CONFIG_H -DBUILDING_avcodec -march=skylake-avx512 -std=c11 -fPIC  -pthread   -I/usr/include/bs2b -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include  -I/usr/include/opus -I/usr/include/opus -D_REENTRANT -pthread -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib32/glib-2.0/include -I/usr/include/libdrm -I/usr/include/libpng16          -I/usr/include/alsa        -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -Wno-bool-operation -pipe -g -fuse-linker-plugin -O2 -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla -Wformat -fdiagnostics-color=auto -Wno-maybe-uninitialized -D_REENTRANT -I/usr/include/SDL2 -mfpmath=both  -MMD -MF libavcodec/ffv1enc.d -MT libavcodec/ffv1enc.o -save-temps -c -o libavcodec/ffv1enc.o  src/libavcodec/ffv1enc.c                                                                                                           
during RTL pass: combine
src/libavcodec/ffv1enc.c: In function ‘encode_init’:
src/libavcodec/ffv1enc.c:919:1: internal compiler error: in add_clobbers, at config/i386/sync.md:1762                                                                            
  919 | }
      | ^
0x12616da add_clobbers(rtx_def*, int)
        /var/tmp/portage/sys-devel/gcc-9.0.0_pre9999/work/gcc-9.0.0-9999/gcc/config/i386/sync.md:1762                                                                            
0x1057fe0 recog_for_combine_1
        /var/tmp/portage/sys-devel/gcc-9.0.0_pre9999/work/gcc-9.0.0-9999/gcc/combine.c:11451                                                                                     
0x1057fe0 recog_for_combine
        /var/tmp/portage/sys-devel/gcc-9.0.0_pre9999/work/gcc-9.0.0-9999/gcc/combine.c:11651                                                                                     
0x104f29d try_combine
        /var/tmp/portage/sys-devel/gcc-9.0.0_pre9999/work/gcc-9.0.0-9999/gcc/combine.c:4132                                                                                      
0x128d1e9 combine_instructions
        /var/tmp/portage/sys-devel/gcc-9.0.0_pre9999/work/gcc-9.0.0-9999/gcc/combine.c:1301                                                                                      
0x128d1e9 rest_of_handle_combine
        /var/tmp/portage/sys-devel/gcc-9.0.0_pre9999/work/gcc-9.0.0-9999/gcc/combine.c:14993                                                                                     
0x128d1e9 execute
        /var/tmp/portage/sys-devel/gcc-9.0.0_pre9999/work/gcc-9.0.0-9999/gcc/combine.c:15038                                                                                     
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
Comment 1 Uroš Bizjak 2018-11-15 22:03:14 UTC
Confirmed.

./cc1 -O2 -m32 -march=skylake-avx512 -mfpmath=both ffv1enc.i

(gdb) bt
#0  internal_error (gmsgid=gmsgid@entry=0x1d7c231 "in %s, at %s:%d") at /home/uros/gcc-svn/trunk/gcc/diagnostic.c:1500
#1  0x00000000007705c9 in fancy_abort (file=file@entry=0x1b34318 "/home/uros/gcc-svn/trunk/gcc/config/i386/sync.md", 
    line=line@entry=1762, function=function@entry=0x1b379c0 <add_clobbers(rtx_def*, int)::__FUNCTION__> "add_clobbers")
    at /home/uros/gcc-svn/trunk/gcc/diagnostic.c:1572
#2  0x00000000013311dc in add_clobbers (pattern=pattern@entry=0x7fffefa76a30, insn_code_number=insn_code_number@entry=1266)
    at /home/uros/gcc-svn/trunk/gcc/config/i386/sync.md:1762
#3  0x000000000146f7c2 in recog_for_combine_1 (pnewpat=0x7fffffffcdd0, insn=0x7ffff091dd80, pnotes=0x7fffffffce20)
    at /home/uros/gcc-svn/trunk/gcc/combine.c:11451
#4  0x00000000014704df in recog_for_combine (pnewpat=pnewpat@entry=0x7fffffffcdd0, insn=insn@entry=0x7ffff091dd80, 
    pnotes=pnotes@entry=0x7fffffffce20) at /home/uros/gcc-svn/trunk/gcc/combine.c:11651
#5  0x0000000001483ecd in try_combine (i3=0x7ffff091dd80, i2=<optimized out>, i1=0x0, i0=0x0, 

The problematic part is in combine, where:

#4  0x00000000014704df in recog_for_combine (pnewpat=pnewpat@entry=0x7fffffffcdd0, insn=insn@entry=0x7ffff091dd80, 
    pnotes=pnotes@entry=0x7fffffffce20) at /home/uros/gcc-svn/trunk/gcc/combine.c:11651
11651     int insn_code_number = recog_for_combine_1 (pnewpat, insn, pnotes);

(gdb) p debug_rtx (insn)
(insn 1576 1575 1577 194 (parallel [
            (set (reg:V4SI 909)
                (subreg:V4SI (mem:DI (plus:SI (reg/f:SI 244 [ _206 ])
                            (reg:SI 1143)) [9 *_206 S8 A32]) 0))
            (clobber (scratch:V4SI))
        ]) "src/libavcodec/ffv1enc.c":853:23 1266 {movdi_to_sse}
     (nil))

(gdb) down
#3  0x000000000146f7c2 in recog_for_combine_1 (pnewpat=0x7fffffffcdd0, insn=0x7ffff091dd80, pnotes=0x7fffffffce20)
    at /home/uros/gcc-svn/trunk/gcc/combine.c:11451
11451         add_clobbers (newpat, insn_code_number);

(gdb) p debug_rtx (newpat)
(parallel [
        (set (reg:V4SI 909)
            (subreg:V4SI (mem:DI (plus:SI (reg/f:SI 244 [ _206 ])
                        (reg:SI 1143)) [9 *_206 S8 A32]) 0))
        (nil)
    ])
(gdb) p insn_code_number
$12 = 1266

The relevant pattern is defined as:

(define_insn_and_split "movdi_to_sse"
  [(parallel
    [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
	  (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
     (clobber (match_scratch:V4SI 2 "=&x,X"))])]
  "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
  "#"
  "&& reload_completed"
  [(const_int 0)]

But for some reason isn't listed in generated add_clobbers in insn-emit.c. Note that there is no "case 1266:" in the switch, although there is:

    case 4852:
    case 4851:
    case 4836:
    case 4835:
    case 4820:
    case 4819:
    case 4804:
    case 4803:
      XVECEXP (pattern, 0, 1) = gen_rtx_CLOBBER (VOIDmode,
	gen_rtx_SCRATCH (V4SImode));
      break;

It doesn't look like a target problem to me.
Comment 2 Uroš Bizjak 2018-11-15 22:50:10 UTC
(In reply to Uroš Bizjak from comment #1)
> It doesn't look like a target problem to me.

Ouch... one (parallel) too many.

--cut here--
Index: config/i386/sse.md
===================================================================
--- config/i386/sse.md  (revision 266189)
+++ config/i386/sse.md  (working copy)
@@ -1235,10 +1235,9 @@
 ;; from there.
 
 (define_insn_and_split "movdi_to_sse"
-  [(parallel
-    [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
-         (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
-     (clobber (match_scratch:V4SI 2 "=&x,X"))])]
+  [(set (match_operand:V4SI 0 "register_operand" "=?x,x")
+       (subreg:V4SI (match_operand:DI 1 "nonimmediate_operand" "r,m") 0))
+   (clobber (match_scratch:V4SI 2 "=&x,X"))]
   "!TARGET_64BIT && TARGET_SSE2 && TARGET_INTER_UNIT_MOVES_TO_VEC"
   "#"
   "&& reload_completed"
--cut here--
Comment 3 uros 2018-11-16 16:42:48 UTC
Author: uros
Date: Fri Nov 16 16:42:16 2018
New Revision: 266218

URL: https://gcc.gnu.org/viewcvs?rev=266218&root=gcc&view=rev
Log:
	PR target/88051
	* config/i386/i386.md (floatunsdidf2): Allow only 64bit AVX512F targets.
	* config/i386/sse.md (UNSPEC_MOVDI_TO_SSE): New UNSPEC.
	(movdi_to_sse): Rewrite using UNSPEC_MOVDI_TO_SSE unspec.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.md
    trunk/gcc/config/i386/sse.md
Comment 4 uros 2018-11-22 21:45:34 UTC
Author: uros
Date: Thu Nov 22 21:45:01 2018
New Revision: 266392

URL: https://gcc.gnu.org/viewcvs?rev=266392&root=gcc&view=rev
Log:
	Backport from mainline
	2018-11-16  Uros Bizjak  <ubizjak@gmail.com>

	PR target/88051
	* config/i386/sse.md (UNSPEC_MOVDI_TO_SSE): New UNSPEC.
	(movdi_to_sse): Rewrite using UNSPEC_MOVDI_TO_SSE unspec.


Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/config/i386/sse.md
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
Comment 5 uros 2018-11-22 22:47:25 UTC
Author: uros
Date: Thu Nov 22 22:46:54 2018
New Revision: 266393

URL: https://gcc.gnu.org/viewcvs?rev=266393&root=gcc&view=rev
Log:
	Backport from mainline
	2018-11-16  Uros Bizjak  <ubizjak@gmail.com>

	PR target/88051
	* config/i386/sse.md (UNSPEC_MOVDI_TO_SSE): New UNSPEC.
	(movdi_to_sse): Rewrite using UNSPEC_MOVDI_TO_SSE unspec.


Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/config/i386/sse.md
Comment 6 Uroš Bizjak 2018-11-22 22:53:29 UTC
Fixed everywhere.