Community
cancel
Showing results for 
Search instead for 
Did you mean: 
SKost
Valued Contributor II
133 Views

Pragma directive [ #pragma optimize ( "", off | on ) ] - Does it really work?

*** Pragma directive [ #pragma optimize ( "", off | on ) ] - Does it really work? ***
0 Kudos
8 Replies
SKost
Valued Contributor II
133 Views

[ Abstract ] Pragma directive [ #pragma optimize ( "", off | on ) ] - Does it really work? A set of tests was completed for Microsoft and Intel C++ compilers and it looks like the directive does not work. Generated binary codes are the same when the switch is on or off.
0 Kudos
SKost
Valued Contributor II
133 Views

[ Microsoft C++ compiler ] ... #pragma optimize ( "", on ) // C/C++ codes for a function ... Assembler codes ... 00248B10 push ebp 00248B11 mov ebp, esp 00248B13 sub esp, 10h 00248B16 push esi 00248B17 rdtsc 00248B19 mov dword ptr [ebp-10h], eax 00248B1C mov dword ptr [ebp-0Ch], edx 00248B1F mov eax, dword ptr [ebp+8] 00248B22 clflush [eax] 00248B25 rdtsc 00248B27 mov dword ptr [ebp-8], eax 00248B2A mov dword ptr [ebp-4], edx 00248B2D mov edx, dword ptr [ebp-8] 00248B30 mov eax, dword ptr [ebp-4] 00248B33 mov ecx, dword ptr [ebp-10h] 00248B36 mov esi, dword ptr [ebp-0Ch] 00248B39 sub edx, ecx 00248B3B sbb eax, esi 00248B3D push edx 00248B3E push 24C420h 00248B43 call dword ptr ds:[24A234h] 00248B49 add esp, 8 00248B4C pop esi 00248B4D mov esp, ebp 00248B4F pop ebp 00248B50 ret ...
0 Kudos
SKost
Valued Contributor II
133 Views

[ Microsoft C++ compiler ] ... #pragma optimize ( "", off ) // C/C++ codes for a function ... Assembler codes ... 00248B10 push ebp 00248B11 mov ebp, esp 00248B13 sub esp, 10h 00248B16 push esi 00248B17 rdtsc 00248B19 mov dword ptr [ebp-10h], eax 00248B1C mov dword ptr [ebp-0Ch], edx 00248B1F mov eax, dword ptr [ebp+8] 00248B22 clflush [eax] 00248B25 rdtsc 00248B27 mov dword ptr [ebp-8], eax 00248B2A mov dword ptr [ebp-4], edx 00248B2D mov edx, dword ptr [ebp-8] 00248B30 mov eax, dword ptr [ebp-4] 00248B33 mov ecx, dword ptr [ebp-10h] 00248B36 mov esi, dword ptr [ebp-0Ch] 00248B39 sub edx, ecx 00248B3B sbb eax, esi 00248B3D push edx 00248B3E push 24C420h 00248B43 call dword ptr ds:[24A234h] 00248B49 add esp, 8 00248B4C pop esi 00248B4D mov esp, ebp 00248B4F pop ebp 00248B50 ret ...
0 Kudos
SKost
Valued Contributor II
133 Views

[ Intel C++ compiler ] ... #pragma optimize ( "", on ) // C/C++ codes for a function ... Assembler codes ... 004034A0 push ebp 004034A1 mov ebp, esp 004034A3 sub esp, 38h 004034A6 rdtsc 004034A8 mov dword ptr [ebp-30h], eax 004034AB mov dword ptr [ebp-2Ch], edx 004034AE mov eax, dword ptr [ebp-30h] 004034B1 mov edx, dword ptr [ebp-2Ch] 004034B4 mov dword ptr [ebp-28h], eax 004034B7 mov dword ptr [ebp-24h], edx 004034BA mov eax, dword ptr [ebp+8] 004034BD clflush [eax] 004034C0 rdtsc 004034C2 mov dword ptr [ebp-20h], eax 004034C5 mov dword ptr [ebp-1Ch], edx 004034C8 mov eax, dword ptr [ebp-20h] 004034CB mov edx, dword ptr [ebp-1Ch] 004034CE mov dword ptr [ebp-18h], eax 004034D1 mov dword ptr [ebp-14h], edx 004034D4 mov eax, dword ptr [ebp-18h] 004034D7 mov edx, dword ptr [ebp-14h] 004034DA mov dword ptr [ebp-10h], eax 004034DD mov dword ptr [ebp-0Ch], edx 004034E0 mov eax, dword ptr [ebp-28h] 004034E3 mov edx, dword ptr [ebp-24h] 004034E6 mov dword ptr [ebp-8], eax 004034E9 mov dword ptr [ebp-4], edx 004034EC add esp, 0FFFFFFF8h 004034EF mov dword ptr [esp], 425F60h 004034F6 mov eax, dword ptr [ebp-8] 004034F9 mov edx, 0 004034FE sub edx, eax 00403500 add edx, dword ptr [ebp-10h] 00403503 mov dword ptr [esp+4], edx 00403507 call InitMemoryTracer+12Dh (40A821h) 0040350C add esp, 8 0040350F mov dword ptr [ebp-38h], eax 00403512 leave 00403513 ret ...
0 Kudos
SKost
Valued Contributor II
133 Views

[ Intel C++ compiler ] ... #pragma optimize ( "", off ) // C/C++ codes for a function ... Assembler codes ... 004034A0 push ebp 004034A1 mov ebp, esp 004034A3 sub esp, 38h 004034A6 rdtsc 004034A8 mov dword ptr [ebp-30h], eax 004034AB mov dword ptr [ebp-2Ch], edx 004034AE mov eax, dword ptr [ebp-30h] 004034B1 mov edx, dword ptr [ebp-2Ch] 004034B4 mov dword ptr [ebp-28h], eax 004034B7 mov dword ptr [ebp-24h], edx 004034BA mov eax, dword ptr [ebp+8] 004034BD clflush [eax] 004034C0 rdtsc 004034C2 mov dword ptr [ebp-20h], eax 004034C5 mov dword ptr [ebp-1Ch], edx 004034C8 mov eax, dword ptr [ebp-20h] 004034CB mov edx, dword ptr [ebp-1Ch] 004034CE mov dword ptr [ebp-18h], eax 004034D1 mov dword ptr [ebp-14h], edx 004034D4 mov eax, dword ptr [ebp-18h] 004034D7 mov edx, dword ptr [ebp-14h] 004034DA mov dword ptr [ebp-10h], eax 004034DD mov dword ptr [ebp-0Ch], edx 004034E0 mov eax, dword ptr [ebp-28h] 004034E3 mov edx, dword ptr [ebp-24h] 004034E6 mov dword ptr [ebp-8], eax 004034E9 mov dword ptr [ebp-4], edx 004034EC add esp, 0FFFFFFF8h 004034EF mov dword ptr [esp], 425F60h 004034F6 mov eax, dword ptr [ebp-8] 004034F9 mov edx, 0 004034FE sub edx, eax 00403500 add edx, dword ptr [ebp-10h] 00403503 mov dword ptr [esp+4], edx 00403507 call InitMemoryTracer+12Dh (40A821h) 0040350C add esp, 8 0040350F mov dword ptr [ebp-38h], eax 00403512 leave 00403513 ret ...
0 Kudos
SKost
Valued Contributor II
133 Views

[ Command Line Options ] [ Microsoft C++ compiler ( VS2005 PE ) 32-bit ] [ Compiler ] /O2 /Ob1 /Oi /Ot /Oy /GL /I "..\..\Include" /D "WIN32" /D "_CONSOLE" /D "NDEBUG" /D "_WIN32_MSC" /D "_VC80_UPGRADE=0x0710" /D "_UNICODE" /D "UNICODE" /GF /Gm /MT /GS- /fp:fast /GR- /openmp /Yu"Stdphf.h" /Fp"Release\MscTestApp.pch" /Fo"Release/" /Fd"Release/" /W4 /nologo /c /Wp64 /Zi /Gd /TP /wd4005 /U "_WINCE_MSC" /U "WIN32_PLATFORM_PSPC" /U "WIN32_PLATFORM_WFSP" /U "WIN32_PLATFORM_WM50" /U "_WIN32_MGW" /U "_WIN32_BCC" /U "_COS16_TCC" /U "_WIN32_ICC" /U "_WIN32_WCC" /errorReport:prompt /arch:SSE2 [ Linker ] /OUT:"Release/MscTestApp.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"Release\MscTestApp.exe.intermediate.manifest" /NODEFAULTLIB:"../../Bin/Release/ScaLib.lib" /SUBSYSTEM:CONSOLE /STACK:268435456 /LARGEADDRESSAWARE /LTCG /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "..\..\bin\release\scalib.lib"
0 Kudos
SKost
Valued Contributor II
133 Views

[ Command Line Options ] [ Intel C++ compiler v12.1.7 ( u371 ) 32-bit ] [ Compiler ] /c /O3 /Ob1 /Oi /Ot /Oy /Qipo /I "..\..\Include" /D "WIN32" /D "_CONSOLE" /D "NDEBUG" /D "_WIN32_ICC" /D "INTEL_SUITE_VERSION=PE121_300" /D "_VC80_UPGRADE=0x0710" /D "_UNICODE" /D "UNICODE" /GF /MT /GS- /fp:fast=2 /GR- /Yu"Stdphf.h" /Fp"Release\IccTestApp.pch" /Fo"Release/" /W5 /nologo /Wp64 /Zi /Gd /TP /Qdiag-disable:2012 /Qdiag-disable:2013 /Qdiag-disable:2014 /Qdiag-disable:2015 /Qdiag-disable:2017 /Qdiag-disable:2021 /Qdiag-disable:2022 /Qdiag-disable:2304 /U "_WIN32_MSC" /U "_WINCE_MSC" /U "WIN32_PLATFORM_PSPC" /U "WIN32_PLATFORM_WFSP" /U "WIN32_PLATFORM_WM50" /U "_WIN32_MGW" /U "_WIN32_BCC" /U "_COS16_TCC" /U "_WIN32_WCC" /Qopenmp /Qfp-speculation:fast /Qopt-matmul /Qparallel /Qstd=c++0x /Qrestrict /Qdiag-disable:111,673,10121 /Wport /Qeffc++ /QxSSE2 /Qansi-alias /Qvec-report=0 /Qfma /Qunroll:8 /Qunroll-aggressive /Qopt-streaming-stores:always /Qopt-block-factor:128 /Qopt-mem-layout-trans:2 /Wport /Qeffc++ /QxSSE2 /Qansi-alias /Qvec-report=0 /Qfma /Qunroll:8 /Qunroll-aggressive /Qopt-streaming-stores:always /Qopt-block-factor:128 /Qopt-mem-layout-trans:2 [ Linker ] kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /OUT:"Release/IccTestApp.exe" /INCREMENTAL:NO /nologo /MANIFEST /MANIFESTFILE:"Release\IccTestApp.exe.intermediate.manifest" /NODEFAULTLIB:"../../Bin/Release/ScaLib.lib" /TLBID:1 /SUBSYSTEM:CONSOLE /STACK:268435456 /LARGEADDRESSAWARE /MACHINE:X86 /qdiag-disable:111,673,10121
0 Kudos
SKost
Valued Contributor II
133 Views

[ C codes for the function] ... // #pragma optimize ( "", on ) // #pragma optimize ( "", off ) _RTINLINE RTvoid CrtClflush( RTvoid RTconst *pvAddress ) { _RTvolatile RTuint64 uiClock1 = IrtRdtsc(); IrtClflush( pvAddress ); _RTvolatile RTuint64 uiClock2 = IrtRdtsc(); CrtPrintf( RTU("[ CrtClflush ] - Executed in %u clock cycles\n"), ( RTuint )( uiClock2 - uiClock1 ) ); } ...
0 Kudos