ZipCPU / zipcpu

A small, light weight, RISC CPU soft core
1.27k stars 153 forks source link

zip-gcc internal compiler error when compiling with "-O3" #10

Closed jope12 closed 5 years ago

jope12 commented 5 years ago

I've found another bug. This code, compiled with "-O3", will give an "internal compiler error":

include

void func(char str) { while (1) { uint64_t x; char c = (x > 1) ? (x - 1) : x; str++ = c;
}
}

The code is bogus, stripped down to a minimum from actual code, but gives the same error. As far as I've checked, if the the bit width of variable "x" is smaller than 64 bit there is no error. Error output from "zip-gcc -O3 -c test.c":

test.c: In function 'func': test.c:11:1: error: unrecognizable insn: } ^ (insn 37 36 38 2 (set (reg:SI 74) (reg/v:DI 67 [ x ])) -1 (nil)) test.c:11:1: internal compiler error: in extract_insn, at recog.c:2297 0x9d5993 _fatal_insn(char const, rtx_def const, char const, int, char const) ../../gcc-6.2.0-zip/gcc/rtl-error.c:108 0x9d59c9 _fatal_insn_not_found(rtx_def const, char const, int, char const) ../../gcc-6.2.0-zip/gcc/rtl-error.c:116 0x9ab3cf extract_insn(rtx_insn) ../../gcc-6.2.0-zip/gcc/recog.c:2297 0x796473 instantiate_virtual_regs_in_insn ../../gcc-6.2.0-zip/gcc/function.c:1582 0x796473 instantiate_virtual_regs ../../gcc-6.2.0-zip/gcc/function.c:1950 0x796473 execute ../../gcc-6.2.0-zip/gcc/function.c:1999

Cheers, Jochen

ZipCPU commented 5 years ago

Okay, I see it.

I'll also note that if "x" is given an initial value, such as zero, then the bug goes away. You might find that useful until I get the fix together.

Dan

ZipCPU commented 5 years ago

Fixed in master now.

Dan