This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

MIPS don't gererate MUL when muliplying by constant of for 2^N +/- 1 optimizing for size


Hi Richard,
 
When -Os is used  and the multiplier is of the for 2^N +- 1 we generate a MUL instruction
rather that a  shift-left   N and add-sub 1.
 
The problem is that rtx cost for the MUL is too cheap causing the shift-left and add-sub sequence
to be  more expensive.
 
This patch makes the MUL slightly more expension so the alternate sequence and better sequence
used. The shift + add/sub is faster and can probaly be scheduled better.
 
This change is code size neutral because the MUL requires a load-immediate.
 
ChangeLog:
        * config/mips/mips.c: (mips_rtx_costs): Slightly increase cost of MUL when optimizing
       for size. This allows a better sequence to be choosen when multiply by a constant of the
        form 2^N +- 1.
 
Graham

Attachment: mips.c.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]