Bug 94603 - ICE: in extract_insn, at recog.c:2343 (unrecognizable insn) with -mno-sse2 and __builtin_ia32_movq128
Summary: ICE: in extract_insn, at recog.c:2343 (unrecognizable insn) with -mno-sse2 an...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: 8.5
Assignee: Uroš Bizjak
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2020-04-15 07:02 UTC by Zdenek Sojka
Modified: 2020-04-15 21:27 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail: 10.0, 5.5.0, 6.5.0, 7.5.0, 8.4.1, 9.3.1
Last reconfirmed: 2020-04-15 00:00:00


Attachments
reduced testcase (110 bytes, text/plain)
2020-04-15 07:02 UTC, Zdenek Sojka
Details
Patch in testing. (349 bytes, patch)
2020-04-15 07:57 UTC, Uroš Bizjak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2020-04-15 07:02:49 UTC
Created attachment 48277 [details]
reduced testcase

Compiler output:
$ x86_64-pc-linux-gnu-gcc -mno-sse2 testcase.c 
testcase.c: In function 'foo':
testcase.c:7:1: error: unrecognizable insn:
    7 | }
      | ^
(insn 7 6 8 2 (set (reg:V2DI 84)
        (vec_concat:V2DI (vec_select:DI (subreg:V2DI (reg:TI 85) 0)
                (parallel [
                        (const_int 0 [0])
                    ]))
            (const_int 0 [0]))) "testcase.c":6:10 -1
     (nil))
during RTL pass: vregs
testcase.c:7:1: internal compiler error: in extract_insn, at recog.c:2294
0x6d3efe _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
        /repo/gcc-trunk/gcc/rtl-error.c:108
0x6d3f81 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        /repo/gcc-trunk/gcc/rtl-error.c:116
0x6c3367 extract_insn(rtx_insn*)
        /repo/gcc-trunk/gcc/recog.c:2294
0xca8923 instantiate_virtual_regs_in_insn
        /repo/gcc-trunk/gcc/function.c:1607
0xca8923 instantiate_virtual_regs
        /repo/gcc-trunk/gcc/function.c:1977
0xca8923 execute
        /repo/gcc-trunk/gcc/function.c:2026
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r10-7691-20200412170534-g87be4cecfc6-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/10.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++ --enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra --with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld --with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch --prefix=/repo/gcc-trunk//binary-trunk-r10-7691-20200412170534-g87be4cecfc6-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.0.1 20200412 (experimental) (GCC)
Comment 1 Martin Liška 2020-04-15 07:27:51 UTC
Confirmed, at least as old as 4.8.0.
Comment 2 Uroš Bizjak 2020-04-15 07:57:53 UTC
Created attachment 48278 [details]
Patch in testing.
Comment 3 Jakub Jelinek 2020-04-15 08:16:54 UTC
The testcase will need -msse -mno-sse2.
Comment 4 Uroš Bizjak 2020-04-15 08:22:37 UTC
(In reply to Jakub Jelinek from comment #3)
> The testcase will need -msse -mno-sse2.

Yes, but the testcase is invalid, because __builtin_ia32_movq128 should not be used without SSE2. Fixed compiler reports:

pr94603.c: In function ‘foo’:
pr94603.c:6:10: warning: implicit declaration of function ‘__builtin_ia32_movq128’; did you mean ‘__builtin_ia32_movntps’? [-Wimplicit-function-declaration]
pr94603.c:6:10: error: incompatible types when returning type ‘int’ but ‘V’ {aka ‘__vector(2) long long int’} was expected
Comment 5 Jakub Jelinek 2020-04-15 08:25:13 UTC
(In reply to Uroš Bizjak from comment #4)
> (In reply to Jakub Jelinek from comment #3)
> > The testcase will need -msse -mno-sse2.
> 
> Yes, but the testcase is invalid, because __builtin_ia32_movq128 should not
> be used without SSE2. Fixed compiler reports:
> 
> pr94603.c: In function ‘foo’:
> pr94603.c:6:10: warning: implicit declaration of function
> ‘__builtin_ia32_movq128’; did you mean ‘__builtin_ia32_movntps’?
> [-Wimplicit-function-declaration]
> pr94603.c:6:10: error: incompatible types when returning type ‘int’ but ‘V’
> {aka ‘__vector(2) long long int’} was expected

I know.  But we (often) include even invalid testcases, perhaps with just dg-error "" and dg-warning "" (or use -w too) if we don't care about exact wording but just want to verify there is no ICE.
Comment 6 Uroš Bizjak 2020-04-15 08:38:50 UTC
(In reply to Jakub Jelinek from comment #5)
> (In reply to Uroš Bizjak from comment #4)
> > (In reply to Jakub Jelinek from comment #3)
> > > The testcase will need -msse -mno-sse2.
> > 
> > Yes, but the testcase is invalid, because __builtin_ia32_movq128 should not
> > be used without SSE2. Fixed compiler reports:
> > 
> > pr94603.c: In function ‘foo’:
> > pr94603.c:6:10: warning: implicit declaration of function
> > ‘__builtin_ia32_movq128’; did you mean ‘__builtin_ia32_movntps’?
> > [-Wimplicit-function-declaration]
> > pr94603.c:6:10: error: incompatible types when returning type ‘int’ but ‘V’
> > {aka ‘__vector(2) long long int’} was expected
> 
> I know.  But we (often) include even invalid testcases, perhaps with just
> dg-error "" and dg-warning "" (or use -w too) if we don't care about exact
> wording but just want to verify there is no ICE.

This is the testcase:

--cut here--
/* PR target/94603 */
/* { dg-do compile } */
/* { dg-options "-Wno-implicit-function-declaration -msse -mno-sse2" } */

typedef long long __attribute__ ((__vector_size__ (16))) V;

V
foo (V v)
{
  return __builtin_ia32_movq128 (v);  /* { dg-error "" } */
}
--cut here--
Comment 7 GCC Commits 2020-04-15 15:08:46 UTC
The master branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:d4f655724c6e19ef0aeb5ac9e8d04abd962ccde7

commit r10-7737-gd4f655724c6e19ef0aeb5ac9e8d04abd962ccde7
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Wed Apr 15 17:08:07 2020 +0200

    i386: Require OPTION_MASK_ISA_SSE2 for __builtin_ia32_movq128 [PR94603]
    
            PR target/94603
            * config/i386/i386-builtin.def (__builtin_ia32_movq128):
            Require OPTION_MASK_ISA_SSE2.
    
    testsuite/ChangeLog:
    
            PR target/94603
            * gcc.target/i386/pr94603.c: New test.
Comment 8 GCC Commits 2020-04-15 20:03:13 UTC
The releases/gcc-9 branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:1eccf9955614a6f0597bf624bbc88788b8b0fdc5

commit r9-8499-g1eccf9955614a6f0597bf624bbc88788b8b0fdc5
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Wed Apr 15 22:02:39 2020 +0200

    i386: Require OPTION_MASK_ISA_SSE2 for __builtin_ia32_movq128 [PR94603]
    
            PR target/94603
            * config/i386/i386-builtin.def (__builtin_ia32_movq128):
            Require OPTION_MASK_ISA_SSE2.
    
    testsuite/ChangeLog:
    
            PR target/94603
            * gcc.target/i386/pr94603.c: New test.
Comment 9 GCC Commits 2020-04-15 21:26:17 UTC
The releases/gcc-8 branch has been updated by Uros Bizjak <uros@gcc.gnu.org>:

https://gcc.gnu.org/g:06d6120b7a5621d584bd0c861bc94096cc8b60b7

commit r8-10183-g06d6120b7a5621d584bd0c861bc94096cc8b60b7
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Wed Apr 15 23:25:27 2020 +0200

    i386: Require OPTION_MASK_ISA_SSE2 for __builtin_ia32_movq128 [PR94603]
    
            PR target/94603
            * config/i386/i386-builtin.def (__builtin_ia32_movq128):
            Require OPTION_MASK_ISA_SSE2.
    
    testsuite/ChangeLog:
    
            PR target/94603
            * gcc.target/i386/pr94603.c: New test.
Comment 10 Uroš Bizjak 2020-04-15 21:27:42 UTC
Fixed for gcc-8.5+.