Tool/software: TI C/C++ Compiler
Looking for help understanding the compilers use of SUBL with 32-bit unsigned math.
This is a system where it is desired to set OVM once globally for all signed math operations. However, the surprise is that SUBL is being used with unsigned operations and signed saturation is applied to the unsigned math.
For example
unsigned long global_A, global_B, global_C;
main()
{
asm (" SETC OVM");
global_A = 0x7fffffffUL;
global_B = 0x80000000UL;
global_C = global_B-global_A;
}
the operation will use SUBL instead of SUBUL and produces erroneous results due to sign context with unsigned variables. With SUBL, Overflow will be treated as signed math with saturation at 0x7fffffff and 0x80000000. This seems strange. Since the core doesn't support an unsigned OVM mode with 0xffffffff and 0x00000000 saturation, why does the compiler choose SUBL instead of SUBUL for these operations?
Understand that SUBUL has an intended use with 64-bit math (SUBUL/SUBBL), and also that the user must manage OVM appropriately (This can be worked around by selectively applying OVM). However, looking for the rationale behind this. The docs don't provide any clear warnings about this potential case.
v16.9.1.LTS. Haven't tried 17.9
Regards,
Eric