Question: Why does the compiler produce shifts and adds for integer multiplication with constants?

Answer: The comment in the generated assembler claims that the multiplication is done with 24 Bit only in hardware. This would be true for the C30 but not for the C40.

Answer : This is an error in the asm header. Please ignore it.

If the -mm (hardware multiply) flag is used, it will not generate a shift, but will use the hardware multiply. Otherwise, it will generate shifts whenever

  • a) the multiplier is a power of 2 -- which is faster than calling the built-in C30 MULT RTS function, and just as fast as the C40 hardware multiply. OR
  • b) if the precision of the operation requires >24 bits and we are not using the -mm flag -- which again is faster than calling the C30 RTS mult, but is very incorrect for the C40 which can usually do it faster in hardware.

Whenever using C40, use the -mm flag to circumvent the problem of using shifts and adds.


Device: TMS320C4x
Category: TI Tools Information
Detail: Code Generation Tools
Detail2: Compiler
Title: Integer Multiplication
Source: Case from TMS320 Hotline
Date: 4/28/98
GenId: aa2

© Copyright 1998 Texas Instruments Incorporated. All rights reserved.
Trademarks, Important Notice!