https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102057
Bug ID: 102057
Summary: ICE at -O2 in extract_constrain_insn, at recog.c:2670
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
Target Milestone: ---
Hi all.
This program makes GCC ICE. I think this program is syntactically valid and GCC
should not emit any error. I found there are many fixed PRs that crash at the
same point "recog.c:2670" and similar stack information. So, I am not sure if
this is a dup case, and please kindly close it if it is.
$cat small.c
#include <stdint.h>
extern n(int f);
a, b, c, d, e, f, g, i;
fn1(int64_t j, uint16_t k) {
uint64_t *l = c;
int8_t m;
if (n(f))
if (*l) {
int8_t o;
uint16_t *p = &k;
if (i) {
int64_t q = e;
if (q)
for (; *p <= 5; k += o)
;
}
}
e = 8;
while (e--) {
a = 7;
while (a) {
a -= 5;
if (i)
if (5 << m)
while (i)
i += 4;
for (; b;)
;
}
}
int32_t r;
g = (d ? k : m) >> (r = 2) ?: 3;
for (; *l; l += f++) {
int64_t *s;
if (*s)
for (; j;)
if (0 / 0)
for (;;)
;
}
}
$gcc -O2 -w -fPIC small.c
small.c: In function ‘fn1’:
small.c:41:1: error: insn does not satisfy its constraints:
41 | }
| ^
(insn 429 394 430 22 (parallel [
(set (reg:CCZ 17 flags)
(compare:CCZ (ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
(const_int 2 [0x2]))
(const_int 0 [0])))
(set (reg:SI 41 r13 [orig:137 k ] [137])
(ashiftrt:SI (reg:SI 0 ax [orig:90 _12 ] [90])
(const_int 2 [0x2])))
]) "small.c":32:31 740 {*ashrsi3_cmp}
(expr_list:REG_DEAD (reg:SI 0 ax [orig:90 _12 ] [90])
(nil)))
during RTL pass: cprop_hardreg
small.c:41:1: internal compiler error: in extract_constrain_insn, at
recog.c:2670
0x681355 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
../../gcc/rtl-error.c:108
0x68137b _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
../../gcc/rtl-error.c:118
0x680484 extract_constrain_insn(rtx_insn*)
../../gcc/recog.c:2670
0xb738ce copyprop_hardreg_forward_1
../../gcc/regcprop.c:825
0xb7481d execute
../../gcc/regcprop.c:1390
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.
$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/haoxin/haoxin-data/compilers/gcc/build/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure
--prefix=/home/haoxin/haoxin-data/compilers/gcc/build/ --enable-bootstrap
--enable-checking=release --enable-languages=c,c++ --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210825 (experimental) (GCC)
Reproduced in Godbol: https://godbolt.org/z/EfMa7zrcj
Thanks,
Haoxin