GCC throws an internal compiler error on the following code when run with optimizations. Bug exists in 3.2, 3.3, and 3.4. Environment: System: Linux mrbean 2.6.1 #1 Wed Jan 21 16:45:49 CST 2004 i686 GNU/Linux Architecture: i686 libc: 2.3.2.ds1-12 (Debian) host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu Configured with: ./configure --enable-languages=c --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-debug How-To-Repeat: Here's the command-line I ran with output: davedude@mrbean:/usr/src/gcc-3.4.0/gcc$ ./xgcc -B. -v -O2 -fno-strict-aliasing ~/c/uiuc/cs348/mp6/bug.i Reading specs from ./specs Configured with: ./configure --enable-languages=c --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-debug Thread model: posix gcc version 3.4.0 ./cc1 -fpreprocessed /home/davedude/c/uiuc/cs348/mp6/bug.i -quiet -dumpbase bug.i -mtune=pentiumpro -auxbase bug -O2 -version -fno-strict-aliasing -o /tmp/ccOtjqJK.s GNU C version 3.4.0 (i686-pc-linux-gnu) compiled by GNU C version 3.3.3 (Debian 20040401). GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32090 bug.c: In function `main': bug.c:20: error: insn does not satisfy its constraints: (insn:HI 41 40 53 2 (set (reg/v:SI 3 bx [orig:74 y ] [74]) (sign_extend:SI (mem/s/j:QI (mult:SI (plus:SI (reg/f:SI 6 bp) (const_int -13 [0xfffffff3])) (const_int 2 [0x2])) [0 dir S1 A8]))) 86 {extendqisi2} (nil) (nil)) bug.c:20: internal compiler error: in reload_cse_simplify_operands, at postreload.c:378 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. Here's bug.i: # 1 "bug.c" # 1 "<built-in>" # 1 "<command line>" # 1 "bug.c" int globl; void dummy(char arg) { globl = arg; } int main(int argc, char *argv[]) { char dir[1]; int y = 0, best; while (y > *argv[0]) { best = (int)dir; y = dir[best]; dummy(*argv[1|best]); } return 0; }
Fix: Bug only appears with optimizations on. Also, this is as small as I could make the bug. Most changes to the above code will remove the problem. Although the code is obviously artificial, the problem did crop up in real code originally.
Confirmed.
Retargeting to 3.4.1, being a regression on that release branch.
This looks to be a bug in reload, or a problem with the x86 backend's constraint matching. In .19.life, we have (insn 38 33 39 2 (set (reg:QI 84) (mem/s:QI (plus:SI (reg/f:SI 93) (reg/f:SI 93)) [0 dir S1 A8])) 46 {*movqi_1} (nil) (nil)) (insn 39 38 42 2 (set (reg/v:SI 63 [ y ]) (sign_extend:SI (reg:QI 84))) 86 {extendqisi2} (insn_list 38 (nil)) (expr_list:REG_DEAD (reg:QI 84) (nil))) These get smushed in combine, but I believe are stiil valid in .20.combine (insn 39 38 42 2 (set (reg/v:SI 63 [ y ]) (sign_extend:SI (mem/s:QI (mult:SI (reg/f:SI 93) (const_int 2 [0x2])) [0 dir S1 A8]))) 86 {extendqisi2} (nil) (nil)) But everything goes to hell in reload, as we consider substituting pseduo 93 for "(plus (reg/f:SI bp) (const_int -13))", producing this monster in .26.greg Reloads for insn # 39 Reload 0: reload_in (QI) = (mem/s:QI (mult:SI (plus:SI (reg/f:SI 6 bp) (const_int -13 [0xfffffff3])) (const_int 2 [0x2])) [0 dir S1 A8]) Q_REGS, RELOAD_FOR_INPUT (opnum = 1), optional reload_in_reg: (mem/s:QI (mult:SI (plus:SI (reg/f:SI 6 bp) (const_int -13 [0xfffffff3])) (const_int 2 [0x2])) [0 dir S1 A8]) (insn:HI 39 38 42 2 (set (reg/v:SI 3 bx [orig:63 y ] [63]) (sign_extend:SI (mem/s:QI (mult:SI (plus:SI (reg/f:SI 6 bp) (const_int -13 [0xfffffff3])) (const_int 2 [0x2])) [0 dir S1 A8]))) 86 {extendqisi2} (nil) (nil))
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-06/msg01980.html>.
rth commented on the patch and the discussion died out. Suggestions?
Postponed until GCC 3.4.3.
No ICE on mainline as of 2004-09-12.
Patch keyword removed as the patch was rejected by RTH.
Postponed until GCC 3.4.4.
Works in 4.0 and up. Won't fix for 3.4.6