Bug 79565 - ICE in copy_to_mode_reg, at explow.c:612
Summary: ICE in copy_to_mode_reg, at explow.c:612
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-02-16 22:45 UTC by Martin Liška
Modified: 2017-10-10 20:14 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-*-*, i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-08-08 00:00:00


Attachments
A patch (3.57 KB, patch)
2017-08-09 16:26 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2017-02-16 22:45:27 UTC
All releases I have suffer from:

$ cat /tmp/ice3.i
typedef float a __attribute__ ((__vector_size__ (16)));
a b, d;
int __attribute__ ((__vector_size__ (2 * sizeof (int)))) c;
void e () { d = __builtin_ia32_cvtpi2ps (b, c); }

gcc /tmp/ice3.i -mno-mmx
/tmp/ice3.i: In function ‘e’:
/tmp/ice3.i:4:17: internal compiler error: in copy_to_mode_reg, at explow.c:612
 void e () { d = __builtin_ia32_cvtpi2ps (b, c); }
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x7cabfb copy_to_mode_reg(machine_mode, rtx_def*)
	../../gcc/explow.c:612
0xd13f6b ix86_expand_binop_builtin
	../../gcc/config/i386/i386.c:34104
0xd16d4b ix86_expand_args_builtin
	../../gcc/config/i386/i386.c:35018
0xd200c4 ix86_expand_builtin
	../../gcc/config/i386/i386.c:38461
0x6e6a4c expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
	../../gcc/builtins.c:6362
0x7dfe18 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	../../gcc/expr.c:10782
0x7e8ef9 store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*)
	../../gcc/expr.c:5552
0x7e9d9f expand_assignment(tree_node*, tree_node*, bool)
	../../gcc/expr.c:5321
0x702832 expand_call_stmt
	../../gcc/cfgexpand.c:2656
0x702832 expand_gimple_stmt_1
	../../gcc/cfgexpand.c:3571
0x702832 expand_gimple_stmt
	../../gcc/cfgexpand.c:3737
0x7041f5 expand_gimple_basic_block
	../../gcc/cfgexpand.c:5744
0x709066 execute
	../../gcc/cfgexpand.c:6357

Clang is also broken, ICC work for that test-case.
Comment 1 H.J. Lu 2017-08-09 15:04:11 UTC
(In reply to Martin Liška from comment #0)
> All releases I have suffer from:
> 
> Clang is also broken, ICC work for that test-case.

What does ICC generate with -mno-mmx -O0?
Comment 2 H.J. Lu 2017-08-09 16:26:08 UTC
Created attachment 41959 [details]
A patch

I got

[hjl@gnu-6 pr79565]$ cat x.i
typedef float a __attribute__ ((__vector_size__ (16)));
a b, d;
int __attribute__ ((__vector_size__ (2 * sizeof (int)))) c;
void e () { d = __builtin_ia32_cvtpi2ps (b, c); }
[hjl@gnu-6 pr79565]$ make x.s
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -mno-mmx -S -o x.s x.i
x.i: In function ‘e’:
x.i:4:17: error: ‘__builtin_ia32_cvtpi2ps’ needs isa option -m32 -msse -mmmx
 void e () { d = __builtin_ia32_cvtpi2ps (b, c); }
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:21: x.s] Error 1
[hjl@gnu-6 pr79565]$ cat y.i
typedef short v4hi __attribute__ ((__vector_size__ (4 * sizeof (short))));
v4hi a, b, c;
void
foo (void)
{
  a = __builtin_ia32_psubusw (b, c);
}
[hjl@gnu-6 pr79565]$ make y.s
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -mno-mmx -S -o y.s y.i
y.i: In function ‘foo’:
y.i:6:7: error: ‘__builtin_ia32_psubusw’ needs isa option -m32 -mmmx
   a = __builtin_ia32_psubusw (b, c);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:21: y.s] Error 1
[hjl@gnu-6 pr79565]$
Comment 3 Jakub Jelinek 2017-10-10 20:07:05 UTC
Author: jakub
Date: Tue Oct 10 20:06:33 2017
New Revision: 253609

URL: https://gcc.gnu.org/viewcvs?rev=253609&root=gcc&view=rev
Log:
	PR target/79565
	PR target/82483
	* config/i386/i386.c (ix86_init_mmx_sse_builtins): Add
	OPTION_MASK_ISA_MMX for __builtin_ia32_maskmovq,
	__builtin_ia32_vec_ext_v4hi and __builtin_ia32_vec_set_v4hi.
	(ix86_expand_builtin): Treat OPTION_MASK_ISA_MMX similarly
	to OPTION_MASK_ISA_AVX512VL - builtins that have both
	OPTION_MASK_ISA_MMX and some other bit set require both
	mmx and the ISAs without the mmx bit.
	* config/i386/i386-builtin.def (__builtin_ia32_cvtps2pi,
	__builtin_ia32_cvttps2pi, __builtin_ia32_cvtpi2ps,
	__builtin_ia32_pavgb, __builtin_ia32_pavgw, __builtin_ia32_pmulhuw,
	__builtin_ia32_pmaxub, __builtin_ia32_pmaxsw, __builtin_ia32_pminub,
	__builtin_ia32_pminsw, __builtin_ia32_psadbw, __builtin_ia32_pmovmskb,
	__builtin_ia32_pshufw, __builtin_ia32_cvtpd2pi,
	__builtin_ia32_cvttpd2pi, __builtin_ia32_cvtpi2pd,
	__builtin_ia32_pmuludq, __builtin_ia32_pabsb, __builtin_ia32_pabsw,
	__builtin_ia32_pabsd, __builtin_ia32_phaddw, __builtin_ia32_phaddd,
	__builtin_ia32_phaddsw, __builtin_ia32_phsubw, __builtin_ia32_phsubd,
	__builtin_ia32_phsubsw, __builtin_ia32_pmaddubsw,
	__builtin_ia32_pmulhrsw, __builtin_ia32_pshufb, __builtin_ia32_psignb,
	__builtin_ia32_psignw, __builtin_ia32_psignd, __builtin_ia32_movntq,
	__builtin_ia32_paddq, __builtin_ia32_psubq, __builtin_ia32_palignr):
	Add OPTION_MASK_ISA_MMX.

	* gcc.target/i386/pr82483-1.c: New test.
	* gcc.target/i386/pr82483-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr82483-1.c
    trunk/gcc/testsuite/gcc.target/i386/pr82483-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386-builtin.def
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Jakub Jelinek 2017-10-10 20:14:19 UTC
Should be fixed now.