Data-Flow Optimizations - Texas Instruments TMS320C2x User Manual

Optimizing c compiler digital signal processor
Hide thumbs Also See for TMS320C2x:
Table of Contents

Advertisement

Example 3−3. Data-Flow Optimizations
simp(int j)
{
}
TMS320C2x/C2xx/C5x C Compiler Output:
_simp:
. . .
*****************************************************
* b = j * 5;
*****************************************************
*****************************************************
* call(3, b, j << 3, (j >> 3) + (j << b));
*****************************************************
***
The constant 3, assigned to a, is copy propagated to all uses of a; a becomes a dead variable
and is eliminated. The sum of multiplying j by 3 (a) and 2 is simplified into b = j * 5, which is recog-
nized as a common subexpression. The assignments to c and d are dead and are replaced with
their expressions. These optimizations are performed across jumps.
int a = 3;
int b = (j * a) + (j * 2);
int c = (j << a);
int d = (j >> 3) + (j << b);
call(a,b,c,d);
...
LARK
AR2,−3+LF1
MAR
*0+
LT
*
MPYK
5
ADRK
4−LF1
SPL
*
LT
*
SBRK
4−LF1
LACT
* ,AR1
SACL
* ,AR2
SSXM
LAC
* ,12,AR1
ADD
* ,15
SACH
*+,1,AR2
LAC
* ,3,AR1
SACL
*+,AR2
ADRK
4−LF1
LAC
* ,AR1
SACL
*+
CALLD _call
LACK
3
SACL
*+
CALL
_call OCCURS
. . .
What Kind of Optimization Is Being Performed?
; AR2 = &j
; t = *AR2
; p = t * 5
; AR2 = &b
; *AR2 = p
; t = *AR2 (b)
; AR2 = &j
; ACC = j << b
; save off ACC on TOS (top of stack)
; need sign extension for right shift
; high ACC = j >> 3
; add TOS to high ACC
; stack high ACC
; ACC = j << 3
; stack ACC
; AR2 = &b
; ACC = b
; stack ACC
; call begins
; ACC = 3
; stack ACC
; call occurs
Optimizing Your Code
3-19

Advertisement

Table of Contents
loading

This manual is also suitable for:

Tms320c2xxTms320c5x

Table of Contents