This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C2000-CGT: Cast to unsigned is ignored under certain circumstances

Part Number: C2000-CGT

Tool/software:

Dear TI-Team,

we recently had to update the CGT for C2000 since the version we used was not available on Linux systems. We now use CGT 22.6.1 on Delfino 28346 devices. After upgrading the compiler we ran in some miscalculations.

Having done some investigation I could figure out that an (unsigned)cast is being ignored. I also could make up some minimal example where a similar error occurs:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "typedefs.h"
int16_t someValue = 0xC0;
int16_t someOtherValue = 0xC000;
int32_t multiplyUnsignedByGlobalInitial()
{
int32_t tmp;
tmp = someValue;
tmp *= (uint16_t)someOtherValue;
return tmp; //incorrect: -3145728
}
int32_t multiplyUnsignedByLocalInitial()
{
int16_t someLocalValue = 0xC0;
int32_t tmp;
tmp = someLocalValue;
tmp *= (uint16_t)someOtherValue;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Here are my compiler flags:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
--silicon_version=28
--large_memory_model
--unified_memory
--float_support=fpu32
--opt_level=3
--opt_for_speed=5
--symdebug:dwarf
--display_error_number
--issue_remarks
--asm_listing
--diag_warning=225
--keep_asm
--quiet
--diag_wrap=off
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Disabling optimisation (setting opt_level = 1) did not solve neither the initial nor the minimal problem. Can you reproduce the problem?

Best regards,

Christian Kasper

7455.unsigned.asm