For the best performance from arithmetic statements use simple two-operand arithmetic statements wherever possible. The following operations are optimized for COMP-5 and COMP-X data items up to four bytes long:
MOVE a TO b ADD a TO b SUBTRACT a FROM b MULTIPLY a BY b DIVIDE a INTO b IF a condition b
where:
a Is a numeric literal value or data item up to four bytes long.
b Is a numeric data item up to four bytes long.
On other data items, these simple operations result in faster code than more complex instructions, but the benefits are not as great as with COMP-5 or COMP-X items. More complex forms of these instructions, involving more than two operands, might not produce code which is as efficient as the simple form.
Other recommendations for optimizing arithmetic statements include:
MOVE a TO c ADD b TO c
rather than:
ADD a TO b GIVING c
However, if the operands are all of the same type, statements that contain the GIVING phrase are optimized.