This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

optimization question

I want to perform math compares using constants so that we test that the compare operation performs correctly. The compiler obviously recognizes that the compare operation produces a true result with the constants given so it doesn't generate any code for it. What can I specify to the compiler to tell it to generate code for what it sees and not perform any optimization?
Here is an example piece of the code:

    BOOL BoolResult = FALSE;
    /*---------------------------------------------------
     * integer compare operations
     *---------------------------------------------------*/
    if ( (10000 <  20000) &&
          (20000 <= 30000) &&
          (30000 >  25000) &&
          (25000 >= 20000) &&
          (20000 == 20000) &&
          (20000 != 20001)
       )
    {
            BoolResult = TRUE;
    }

Parents
  • The object is to validate that the processor is working correctly (for safety reasons), this is one of the suggested tests.

    Setting aside the huge issue of whether that kind of test still makes any sense whatsoever, these days: if that's what you want to test, you really have to write that code in assembly. If you want to force the tools to generate a particular code sequence, no high-level language, not even C, is the proper tool for the job.

Reply
  • The object is to validate that the processor is working correctly (for safety reasons), this is one of the suggested tests.

    Setting aside the huge issue of whether that kind of test still makes any sense whatsoever, these days: if that's what you want to test, you really have to write that code in assembly. If you want to force the tools to generate a particular code sequence, no high-level language, not even C, is the proper tool for the job.

Children
No data