SPRU514Y August 2001 – June 2022
In addition to the --cla_support command-line option, the following command line options apply specifically to the CLA compiler:
--cla_default Causes files with an extension of .c to also be compiled as CLA files.
--cla_signed_compare_workaround={on|off} Enables the automatic use of a workaround for a CLA hardware flaw that affects integer comparisons. This is necessary because certain types of integer comparisons may produce incorrect results due to integer overflows, for example when the values compared have opposite signs and are near the extreme values. This option is off by default.
If you enable this option, a floating-point comparison is used internally to check the upper bits of the integer values being compared. This comparison detects whether an integer overflow may occur if the difference between the values being compared is too large. If an integer comparison may have an incorrect result, a floating-point comparison is performed instead. For a comparison like
if (x < y)
, the modified comparison performed is as follows:
(float)x < (float)y || (float)x == (float)y && (x <= y)
Enabling this option increases code size and execution time if your code performs many 32-bit integer comparisons.
The following types of integer comparisons are always safe from integer overflows. The workaround is not used for such comparisons even if this option is enabled.
Note than comparisons between unsigned integers are still subject to incorrect results, because the comparisons are performed internally in terms of signed integers.
If you do not want to use the workaround because of its effects on code size and execution time, you can use any of these manual coding alternatives:
if (__mlt(x, y))
if ((short)x < (short)y)
for (short i = 0; i < (short)y); i++)
if ((float)x < (float)y)
for (float i = 0; i < (float)y); i++)
for (int i = y-1; i >= 0; i--)