Optimizing Integer Multiply And Divide - Intel XScale Core Developer's Manual

Table of Contents

Advertisement

A.3.4

Optimizing Integer Multiply and Divide

Multiplication by an integer constant should be optimized to make use of the shift operation
whenever possible.
;Multiplication of R0 by 2
mov
;Multiplication of R0 by 2
add
Multiplication by an integer constant that can be expressed as
optimized as:
;Multiplication of r0 by an integer constant that can be
;expressed as (2
add
mov
Please note that the above optimization should only be used in cases where the multiply operation
cannot be advanced far enough to prevent pipeline stalls.
Dividing an unsigned integer by an integer constant should be optimized to make use of the shift
operation whenever possible.
;Dividing r0 containing an unsigned value by an integer constant
;that can be represented as 2
mov
Dividing a signed integer by an integer constant should be optimized to make use of the shift
operation whenever possible.
;Dividing r0 containing a signed value by an integer constant
;that can be represented as 2
mov
add
mov
The add instruction would stall for one cycle. The stall can be prevented by filling in another
instruction before add.
Developer's Manual
n
r0, r0, LSL #n
n
+1
r0, r0, r0, LSL #n
n
m
+1)*(2
)
r0, r0, r0, LSL #n
r0, r0, LSL #m
n
r0, r0, LSR #n
n
r1, r0, ASR #31
r0, r0, r1, LSR #(32 - n)
r0, r0, ASR #n
January, 2004
Intel XScale® Core Developer's Manual
Optimization Guide
·
n
m
can similarly be
2
+
1
2
189

Advertisement

Table of Contents
loading

Table of Contents