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.
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.
Thank you for the test case. It appears the compiler has done something wrong. I filed the issue CODEGEN-6911 in the SDOWP system to have this issue investigated. You are welcome to follow it with the SDOWP link below in my signature.
Just to be certain I am seeing the same issue for the same reasons, please show me all the compiler options exactly as the compiler sees them.
Thanks and regards,
-George
Thank you. I verified that I am seeing the same problem for the same reasons.
Thanks and regards,
-George
We are implementing workarounds on our code to fix this problem. Can you adress us on what kind statements we should take care of ? I mean besides the "if" comparing floats.
Thank you.
Samuel Ors.
The investigation of CODEGEN-6911 will result in a description of workarounds for the problem.
Thanks and regards,
-George