VC ++ 10 allows a strict smoothing rule with / O 1 and higher. I use the test program (with a score of 6) in the chapter "ADVANTAGES TO THE BUILDING RULE OF STATEMENT" here . And get the following asm code. You can see that b is loaded only once.
00A910AE movzx edx,word ptr [edx+2] //Load of b 00A910B2 xor eax,eax 00A910B4 xor ecx,ecx 00A910B6 add dword ptr [esp+eax*4+34h],edx //Loop start 00A910BA add eax,1 00A910BD adc ecx,edi 00A910BF jne main+76h (0A910C6h) 00A910C1 cmp eax,6 00A910C4 jb main+66h (0A910B6h) //Loop end
But there seems to be no way to turn on a warning of a violation of this rule.
source share