------- Comment #18 from ubizjak at gmail dot com 2007-12-19 12:11 ------- Another baby step can be performed by:
Index: optabs.c =================================================================== --- optabs.c (revision 131053) +++ optabs.c (working copy) @@ -1245,7 +1245,7 @@ expand_doubleword_mult (enum machine_mod return NULL_RTX; } - adjust = expand_binop (word_mode, smul_optab, op0_high, op1_low, + adjust = expand_binop (word_mode, smul_optab, op1_low, op0_high, NULL_RTX, 0, OPTAB_DIRECT); if (!adjust) return NULL_RTX; @@ -1274,7 +1274,7 @@ expand_doubleword_mult (enum machine_mod return NULL_RTX; } - temp = expand_binop (word_mode, smul_optab, op1_high, op0_low, + temp = expand_binop (word_mode, smul_optab, op0_low, op1_high, NULL_RTX, 0, OPTAB_DIRECT); if (!temp) return NULL_RTX; This patch generates (note mem operands to imull): test: subl $8, %esp movl %ebx, (%esp) movl 12(%esp), %ebx movl %esi, 4(%esp) movl 20(%esp), %esi movl %ebx, %ecx movl %esi, %eax imull 24(%esp), %ecx imull 16(%esp), %eax addl %eax, %ecx movl %esi, %eax mull %ebx movl (%esp), %ebx leal (%ecx,%edx), %esi movl %esi, %edx movl 4(%esp), %esi addl $8, %esp ret but since mulsi3 is defined as: (define_insn "*mulsi3_1" [(set (match_operand:SI 0 "register_operand" "=r,r,r") (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,rm,0") (match_operand:SI 2 "general_operand" "K,i,mr"))) (clobber (reg:CC FLAGS_REG))] the question is, why didn't RA perform operand reversal by itself. Currently it converts _both_ SI multiplies from: (insn:HI 8 7 9 2 m.c:14 (parallel [ (set (reg:SI 63) (mult:SI (mem/c/i:SI (plus:SI (reg/f:SI 16 argp) (const_int 4 [0x4])) [2 a+4 S4 A32]) (reg:SI 66 [ b ]))) (clobber (reg:CC 17 flags)) ]) 214 {*mulsi3_1} (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))) into --cut here-- (insn 35 7 8 2 m.c:14 (set (reg:SI 0 ax [63]) (mem/c/i:SI (plus:SI (reg/f:SI 7 sp) (const_int 16 [0x10])) [2 a+4 S4 A32])) 41 {*movsi_1} (nil)) (insn:HI 8 35 9 2 m.c:14 (parallel [ (set (reg:SI 0 ax [63]) (mult:SI (reg:SI 0 ax [63]) (reg:SI 4 si [orig:66 b ] [66]))) (clobber (reg:CC 17 flags)) ]) 214 {*mulsi3_1} (nil)) --cut here-- -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17236