Claims
- 1. A method of recognizing full-word saturating addition and subtraction in a program for every basis statement A of the form z=ADD(x,y) or z=SUB(x,y ), the method comprising:
inserting the statement Zsat=ADDSAT(x,y) or Zsat=SUBSAT(x,y) immediately following the statement A; computing bits values BITS(E,v) properties of the variable v at edges E in the program; computing condition COND(E) properties under which the edges E are executed in the program; computing reach REACH(E,v) properties indicating which values of the variable v reaches a use of variable z in statement S at edges E in the program for overflow or underflow or normal occurrences; replacing z in a statement S that uses z with the use of Zsat if all of the following conditions hold for the statement S: a) the only value of z that reach S assigns SATMAX to z when overflow has occurred, b) the only value of z that reach S assigns SATMIN to z if underflow has occurred, and c) the only value of z that reaches S is from the basis statement A if no underflow and no overflow has occurred; and removing statements made unnecessary by the replacement of uses of z with Zsat in the previous step.
- 2. The method according to claim 1, including defining overflow, underflow and “normal” predicates for REACH as follows wherein X, Y, Z are the signs of variables x, y, z respectively:
- 3. The method according to claim 2, wherein the REACH properties include a constant value COF(E,v) taken by the variable v when the edge E is executed, if overflow had occurred; a constant value CUF(E,v) taken by the variable v when the edge E is executed, if underflow had occurred; and a Boolean flag ISZ(E,v) which indicates whether v carries the same value as the variable z in the basis statement A when the edge E is executed and neither overflow nor underflow had occurred.
- 4. In a method of formulation and solving program analysis equations that facilitate recognition of full word saturating addition and subtraction, the method of formulation comprising, for each basis addition statement z=x+y or subtraction statement z=x−y, formulating data flow equations that describe the following properties of the program statements being analyzed:
a) values BITS of program variables x, y, z as Boolean functions of the sign bits of X, Y and Z; b) condition COND under which program statements S are executed as Boolean functions of the sign bits of X, Y and Z; and c) condition REACH of which values of the variables reaches a use of variable z in statements S for overflow or underflow or normal occurrences.
- 5. The method according to claim 4, wherein the occurrences of overflow or underflow or normal is determined as a function of the sign bits of X, Y and Z.
- 6. The method according to claim 4, including replacing z in a statement S of the program that uses z with the use of Zsat if and only if all of the following conditions hold for that statement S: a) the only values of z that reach S assigns SATMAX to z when overflow has occurred, c) the only values of z that reach S assigns SATMIN to z if underflow has occurred, and d) the only values of z that reaches S is from the basis statement A if no underflow and no overflow has occurred.
- 7. The method according to claim 6, including removing statements made unnecessary by the replacement of uses of z with Zsat.
- 8. The method according to claim 4, including solving the equations for BITS, COND and REACH using dense techniques.
- 9. The method according to claim 4, including solving the equations for BITS, COND and REACH using sparse program representation.
- 10. The method according to claim 4, wherein the values and conditions are approximated using global data flow analysis, which includes a lattice for approximating BITS, COND, REACH and a system of equations relating approximations to various program points.
- 11. The method according to claim 10, including compressing of lattice vectors assigned to the variables.
- 12. The method according to claim 4, wherein REACH includes a constant value COF(E,v) taken by the variable v when the edge E is executed, if overflow had occurred; a constant value CUF(E,v) taken by the variable v when the edge E is executed, if underflow had occurred; and a Boolean flag ISZ(E,v) which indicates whether v carries the same value as the variable z in the basis statement A when the edge E is executed and neither overflow nor underflow had occurred.
- 13. A method of formulating and solving equations that facilitate recognition of full word saturating addition and subtraction, the method comprising:
formulating, for each basis addition statement z=x+y or subtraction statement z=x−y, data flow equations that describe properties of the program statements being analyzed and solving the data flow equations.
- 14. The method according to claim 13, wherein the properties include:
a) values BITS of program variables x, y, z as Boolean functions of the sign bits of X, Y and Z; b) condition COND under which program statements S are executed as Boolean functions of the sign bits of X, Y and Z; and c) condition REACH of which values of the variables reaches a use of variable z in statements S for overflow or underflow or normal occurrences.
- 15. The method according to claim 14, wherein the occurrences of overflow or underflow or normal is determined as a function of the sign bits of X, Y and Z.
- 16. The method according to claim 14, including replacing z in a statement S of the program that uses z with the use of Zsat if and only if all of the following conditions hold for that statement S: a) the only values of z that reach S assigns SATMAX to z when overflow has occurred, c) the only values of z that reach S assigns SATMIN to z if underflow has occurred, and d) the only values of z that reaches S is from the basis statement A if no underflow and no overflow has occurred.
- 17. The method according to claim 16, including removing statements made unnecessary by the replacement of uses of z with Zsat.
- 18. The method according to claim 13, including solving the equations using dense techniques.
- 19. The method according to claim 13, including solving the equations using sparse program representation.
- 20. The method according to claim 14, wherein the values and conditions are approximated using global data flow analysis, which includes a lattice for approximating BITS, COND, REACH and a system of equations relating approximations to various program points.
- 21. The method according to claim 20, including compressing of lattice vectors assigned to the variables.
- 22. The method according to claim 14, wherein REACH includes a constant value COF(E,v) taken by the variable v when the edge E is executed, if overflow had occurred; a constant value CUF(E,v) taken by the variable v when the edge E is executed, if underflow had occurred; and a Boolean flag ISZ(E,v) which indicates whether v carries the same value as the variable z in the basis statement A when the edge E is executed and neither overflow nor underflow had occurred.
CROSS REFERENCE
[0001] The present application claims the benefit of the U.S. provisional application entitled Method for Recognition of Full-Word Saturating Addition and Subtraction, filed Nov. 12, 2002, which is incorporated herein by reference.