Microsoft KB Archive/84478

{|
 * width="100%"|

PRB: Generating P-Code Disables Native Code Optimization

 * }

Q84478

7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbprb -- The information in this article applies to: - The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SYMPTOMS ======== In Microsoft C/C++ version 7.0 and Visual C++ version 1.0, generating p- code with the /Oq compiler option or with the following pragma #pragma optimize( &quot;q&quot;, on ) seems to disable other specified optimizations. Even using #pragma optimize( &quot;q&quot;, off ) does not seem to restore optimization to the remaining native code. CAUSE ===== This is a limitation of the p-code compiler. Any native code functions in a module compiled for p-code will get a /f level of optimization. RESOLUTION ========== Break the module into two modules, one that uses native code and another that uses p-code. MORE INFORMATION ================ The following sample code can be used to demonstrate the behavior. When compiled with /Olz, the code generated for the for loop places a 1 into j and returns. With /Oqlz, this optimization does not occur. Sample Code --- /* Compile options needed: /Oqlz /Fc Compile options needed: /Olz /Fc Compare the resulting listings generated by /Fc */ #pragma optimize( &quot;q&quot;, off ) int main { int i, j; for( i=0; i<10; i++ ) /* This loop should be optimized away. */ { j = 1; j = 1; j = 1; j = 1; j = 1; } return j; } Additional reference words: 7.00 8.00 8.00c 1.00 1.50 pcode KBCategory: kbtool kbprb KBSubcategory: CLIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCVCComp