It happens at -Os and in 32-bit mode only. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 8.0.0 20171106 (experimental) [trunk revision 254453] (GCC) $ gcc-trunk -m32 -Os abc.c during RTL pass: expand abc.c: In function ‘fn1’: abc.c:15:25: internal compiler error: in find_widening_optab_handler_and_mode, at optabs-query.c:414 d ? (a %= c) * (e *= a ? f : b) : 0; ^~ 0xb9b215 find_widening_optab_handler_and_mode(optab_tag, machine_mode, machine_mode, machine_mode*) ../../gcc/gcc/optabs-query.c:414 0xb8e9da expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) ../../gcc/gcc/optabs.c:1152 0xb91fc0 expand_doubleword_mult ../../gcc/gcc/optabs.c:865 0xb8fbc8 expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) ../../gcc/gcc/optabs.c:1705 0x966155 expand_mult(machine_mode, rtx_def*, rtx_def*, rtx_def*, int) ../../gcc/gcc/expmed.c:3427 0x98b314 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc/gcc/expr.c:8802 0x865371 expand_gimple_stmt_1 ../../gcc/gcc/cfgexpand.c:3712 0x865371 expand_gimple_stmt ../../gcc/gcc/cfgexpand.c:3773 0x8669d8 expand_gimple_basic_block ../../gcc/gcc/cfgexpand.c:5774 0x86b756 execute ../../gcc/gcc/cfgexpand.c:6375 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. $ cat abc.c char a; unsigned b; long c, d; long long e; void fn1() { short f = a = 6; for (; 4 <= 3;) for (; a <= 7;) { for (;;) ; l1: for (; c <= 73;) ; e = 20; d ? (a %= c) * (e *= a ? f : b) : 0; } goto l1; }
This is likely a duplicate of PR82816.
(In reply to Arseny Solokha from comment #1) > This is likely a duplicate of PR82816. Hi Arseny, I tried it on r254484. It still exists. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 8.0.0 20171107 (experimental) [trunk revision 254484] (GCC) $ gcc-trunk -m32 -Os a.c during RTL pass: expand a.c: In function ‘fn1’: a.c:15:25: internal compiler error: in find_widening_optab_handler_and_mode, at optabs-query.c:414 d ? (a %= c) * (e *= a ? f : b) : 0; ^~ 0xb9b285 find_widening_optab_handler_and_mode(optab_tag, machine_mode, machine_mode, machine_mode*) ../../gcc/gcc/optabs-query.c:414 0xb8ea4a expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) ../../gcc/gcc/optabs.c:1152 0xb92030 expand_doubleword_mult ../../gcc/gcc/optabs.c:865 0xb8fc38 expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) ../../gcc/gcc/optabs.c:1705 0x9661b5 expand_mult(machine_mode, rtx_def*, rtx_def*, rtx_def*, int) ../../gcc/gcc/expmed.c:3427 0x98b374 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc/gcc/expr.c:8802 0x8653b1 expand_gimple_stmt_1 ../../gcc/gcc/cfgexpand.c:3712 0x8653b1 expand_gimple_stmt ../../gcc/gcc/cfgexpand.c:3773 0x866a18 expand_gimple_basic_block ../../gcc/gcc/cfgexpand.c:5774 0x86b796 execute ../../gcc/gcc/cfgexpand.c:6375 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.
Confirmed, I see same back-trace starting from r254302: $ cat ice.i const int a = 100; void b () { int c[a]; } $ gcc -ftree-ter ice.i -c during RTL pass: expand ice.i: In function ‘b’: ice.i:2:17: internal compiler error: in find_widening_optab_handler_and_mode, at optabs-query.c:414 void b () { int c[a]; } ^ 0xab7891 find_widening_optab_handler_and_mode(optab_tag, machine_mode, machine_mode, machine_mode*) ../../gcc/optabs-query.c:414 0xaaaf7c expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) ../../gcc/optabs.c:1152 0xaae410 expand_doubleword_mult ../../gcc/optabs.c:865 0xaac2a7 expand_binop(machine_mode, optab_tag, rtx_def*, rtx_def*, rtx_def*, int, optab_methods) ../../gcc/optabs.c:1705 0x85141d expand_mult(machine_mode, rtx_def*, rtx_def*, rtx_def*, int) ../../gcc/expmed.c:3427 0x876594 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc/expr.c:8802 0x746dc9 expand_gimple_stmt_1 ../../gcc/cfgexpand.c:3712 0x746dc9 expand_gimple_stmt ../../gcc/cfgexpand.c:3773 0x74861f expand_gimple_basic_block ../../gcc/cfgexpand.c:5774 0x74e76e execute ../../gcc/cfgexpand.c:6375
Created attachment 42672 [details] gcc8-pr82875.patch Untested fix.
Author: jakub Date: Wed Nov 22 09:57:28 2017 New Revision: 255050 URL: https://gcc.gnu.org/viewcvs?rev=255050&root=gcc&view=rev Log: PR middle-end/82875 * optabs.c (expand_doubleword_mult, expand_binop): Before calling expand_binop with *mul_widen_optab, make sure at least one of the operands doesn't have VOIDmode. * gcc.dg/pr82875.c: New test. * gcc.c-torture/compile/pr82875.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr82875.c trunk/gcc/testsuite/gcc.dg/pr82875.c Modified: trunk/gcc/ChangeLog trunk/gcc/optabs.c trunk/gcc/testsuite/ChangeLog
Fixed.