Download CC665S User's Manual

Transcript
CC665S Ver.2.01 User Guide
7.5.3 Use Of Algebraic Identities
Expressions that conform to algebraic laws are modified, so that unnecessary operations are eliminated.
Example 7.18
int a, b, c, d ;
alg_identities ()
{
a=b+0;
c=d*1;
}
/* addition is eliminated */
/* multiplication is eliminated */
Assembly code generated by CC665S for the above function ‘alg_identities’ is shown below:
CFUNCTION 0
_alg_identities
:
;;
a=b+0;
CLINE 6
mov
dir _a,
/* addition is eliminated */
;;
c=d*1;
CLINE 7
mov
dir _c,
/* multiplication is eliminated */
dir _b
dir _d
;;}
CLINE 8
rt
7.6 EFFECT OF ALIASING ON OPTIMIZATIONS
An ‘alias’ is a name used to refer to a memory location already referred to by a different name.
As a location can be referred to by more than one variable, performing optimization on variables becomes
unsafe. By default CC665S does not check for aliases. The default optimizations performed by CC665S
may result in unsafe code, when the following assumptions are violated :
1. If a variable is used directly, no pointers are used to reference that variable.
2. If a pointer is used to refer to a variable, that variable is not referred to directly.
3. If a pointer is used to modify a memory location, no other pointers are used to access the same
memory location.
The term ‘reference’ means the use of a variable on the right-hand side or left-hand side of an assignment
expression or use of a variable as an argument to a function call.
Page 128