Intel® IXP42X Product Line of Network Processors and IXC1100 Control Plane Processor
September 2006 DM
Order Number: 252480-006US 179
Intel XScale® Processor—Intel® IXP42X product line and IXC1100 control plane processors
Multiplication by an integer constant that can be expressed as can
similarly be optimized as:
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 a signed integer by an integer constant should be optimized to make use of
the shift operation whenever possible.
The add instruction would stall for 1 cycle. The stall can be prevented by filling in
another instruction before add.
3.10.3.5 Effective Use of Addressing Modes
The IXP42X product line and IXC1100 control plane processors provide a variety of
addressing modes that make indexing an array of objects highly efficient. For a detailed
description of these addressing modes please refer to the ARM* Architecture Reference
Manual. The following code samples illustrate how various kinds of array operations can
be optimized to make use of these addressing modes:
;Multiplication of R0 by 2n
mov r0, r0, LSL #n
;Multiplication of R0 by 2n+1
add r0, r0, r0, LSL #n
2n1+()
·2m
()
;Multiplication of r0 by an integer constant that can be
;expressed as (2n+1)*(2m)
add r0, r0, r0, LSL #n
mov r0, r0, LSL #m
;Dividing r0 containing an unsigned value by an integer constant
;that can be represented as 2n
mov r0, r0, LSR #n
;Dividing r0 containing a signed value by an integer constant
;that can be represented as 2n
mov r1, r0, ASR #31
add r0, r0, r1, LSR #(32 - n)
mov r0, r0, ASR #n
;Set the contents of the word pointed to by r0 to the value
;contained in r1 and make r0 point to the next word
str r1,[r0], #4
;Increment the contents of r0 to make it point to the next word
;and set the contents of the word pointed to the value contained
;in r1
str r1, [r0, #4]!
;Set the contents of the word pointed to by r0 to the value
;contained in r1 and make r0 point to the previous word
str r1,[r0], #-4
;Decrement the contents of r0 to make it point to the previous
;word and set the contents of the word pointed to the value
;contained in r1
str r1,[r0, #-4]!