This is the mail archive of the gcc@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]

multiply by a constant on an arm7TDMI


Hi,

I sent this e-mail 3 weeks ago on gcc-help mailing list, but I had no response.
Could you help me please,
Franck.

Hi,

I try to compile this kind of code:
     y = x * 0x3501;  /*(x and y are short);*/
with arm-elf-gcc for the target arm7tdmi.

The code generated by arm-elf-gcc doesn't   generate a 'mul' instruction but a sequence of 'rsb' and 'add' instructions.
It is not a bug and it gives the good result but several multiplication are in the same function and it has to store intermediate results in memory:
 str     r3, [fp, #-92]^M
        ldr     r2, [fp, #-92]^M
        rsb     r3, r3, r3, asl #4^M
        ldr     r4, [fp, #-92
        rsb     r3, r2, r3, asl #2
        add     r3, r2, r3, asl #3
        add     ip, r4, r3, asl #5

This solution is far more complex than a simple 'mul' instruction (even if 'mul' can take 4 cycles on an ARM7).

Can anyone help me to avoid generating such a code and forcing arm-elf-gcc to use 'mul' instruction.

Thanks,
regards,
Franck.
 

-- 
& france telecom 
Mamalet Franck
FTR&D DIH/OCF
Tél  : 04 76 76 45 71   Fax : 04 76 90 34 43
franck.mamalet@rd.francetelecom.fr
 
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]