http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49497
Summary: Incorrect lea peephole Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: hjl.to...@gmail.com CC: ubiz...@gmail.com Target: x86 i386.md has ;; Convert imul by three, five and nine into lea (define_peephole2 [(parallel [(set (match_operand:SWI48 0 "register_operand" "") (mult:SWI48 (match_operand:SWI48 1 "register_operand" "") (match_operand:SWI48 2 "const_int_operand" ""))) (clobber (reg:CC FLAGS_REG))])] "INTVAL (operands[2]) == 3 || INTVAL (operands[2]) == 5 || INTVAL (operands[2]) == 9" [(set (match_dup 0) (plus:SWI48 (mult:SWI48 (match_dup 1) (match_dup 2)) (match_dup 1)))] "operands[2] = GEN_INT (INTVAL (operands[2]) - 1);") (define_peephole2 [(parallel [(set (match_operand:SWI48 0 "register_operand" "") (mult:SWI48 (match_operand:SWI48 1 "nonimmediate_operand" "") (match_operand:SWI48 2 "const_int_operand" ""))) (clobber (reg:CC FLAGS_REG))])] "optimize_insn_for_speed_p () && (INTVAL (operands[2]) == 3 || INTVAL (operands[2]) == 5 || INTVAL (operands[2]) == 9)" [(set (match_dup 0) (match_dup 1)) (set (match_dup 0) (plus:SWI48 (mult:SWI48 (match_dup 0) (match_dup 2)) (match_dup 0)))] "operands[2] = GEN_INT (INTVAL (operands[2]) - 1);") But lea split has && (!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)) When TARGET_PARTIAL_REG_STALL is true, get got [hjl@gnu-33 1036]$ cat x.i char *progName; int *tt; unsigned char *ll8; extern void foo (const char *); void cleanUpAndFail ( int ec ) { __builtin_exit ( ec ); } void uncompressOutOfMemory ( int draw, int blockSize ) { foo ( "\tand failing that, find a machine with more memory.\n"); cleanUpAndFail(1); } void setDecompressStructureSizes ( int newSize100k ) { int n = 100000 * newSize100k; ll8 = __builtin_malloc ( n * sizeof(unsigned char) ); if (ll8 == ((void *)0) || tt == ((void *)0)) { int totalDraw = n * sizeof(unsigned char) + n * sizeof(unsigned int); uncompressOutOfMemory ( totalDraw, n ); } } [hjl@gnu-33 1036]$ make x.s /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -S x.i x.i: In function ‘setDecompressStructureSizes’: x.i:19:2: error: unrecognizable insn: (insn 43 19 21 4 (set (reg:SI 5 di [69]) (plus:SI (mult:SI (reg/v:SI 3 bx [orig:59 n ] [59]) (const_int 4 [0x4])) (reg/v:SI 3 bx [orig:59 n ] [59]))) x.i:16 -1 (nil)) x.i:19:2: internal compiler error: in extract_insn, at recog.c:2113 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. make: *** [x.s] Error 1 [hjl@gnu-33 1036]$