Please see below:
float32_t A;
int32_t B;
I found a very simple comparison statement " if (A < B) " consumes about 10~13 system clocks. Is this normal? Why does it take so long? Any way to reduce the execution time?
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.
Please see below:
float32_t A;
int32_t B;
I found a very simple comparison statement " if (A < B) " consumes about 10~13 system clocks. Is this normal? Why does it take so long? Any way to reduce the execution time?
Compile with optimization --opt_level=2 or higher. B must be converted to a float before the comparison to A. Consider the speed of the memory that holds A, B, and the instructions. If those suggestions do not help, then for the source file that contains this comparison, please follow the directions in the article How to Submit a Compiler Test Case.
Thanks and regards,
-George
Thanks, George. Actually I found even with: int A, B;
how many system clocks are consumed for such a simple comparison on your side?
Context matters. Are A and B local variables, global variables, parameters to a function? What is being controlled by the if? A return, a single statement, a block of statements? The best way to answer these questions is by submitting a test case. And the best way to submit a test case is to please follow the directions in the article How to Submit a Compiler Test Case.
Thanks and regards,
-George
Thanks, Geroge. Please see below:
1. Both A and B are global variables: both are int.
2. the "if" statement " if (A < B) " controls a single statement
in such a scenario, how many system clocks is " if (A < B) " supposed to be consume?
I only know one way to answer the question ...
how many system clocks is " if (A < B) " supposed to be consume?
Please submit the test case I have requested. I'll build it down to assembly code, then tell you how many clock cycles it takes.
Thanks and regards,
-George