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.

Compiler/TMS320F28335: TMS320F28335 code generation error on float comparisons

Part Number: TMS320F28335

Tool/software: TI C/C++ Compiler

Hello.

I have been all days struggling with a problem we have in one of our products.

We are currently using C++ compiler version 18.12.3, but I checked is still present in 18.12.4 and 19.6.0. The problem only arises when we acivate basic optimizations (-O0), and works correctly without optimizations.

To reproduce it I executed this simple code:

struct Data
{
    int r0;
    int r1;
};

void test(float a, float b, Data& data)
{
    float ab = 0.0F;
    data.r0 = 0;
    data.r1 = 0;
    if(a<b)
    {
        b = a;
        ab = a;
        data.r0 = 1+ab;
        data.r1 = 1;
    }
}

int main()
{
    float a = 3.5F;
    Data d0;
    test(a, a, d0);
}

When calling "test" with different numbers, it behaves correctly, but when numbers are equal (3.5 i.e.) data will be "half filled".

Calling with 3.5, I will expect d0 to be = {0, 0} as the numbers are equal. I could also expect d0 to be { 4,1 }, but I got d0 == {1, 1}

So it executes just some code inside the "if" of the "test".

The problem is solved by reordering some instructions inside the "if" or adding a NOP in the beggining of it.