Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```c++
- #include <string.h>
- #include <algorithm>
- #include <iterator>
- #include <limits>
- float sky_mins[2][6], sky_maxs[2][6];
- void ClearSkyBox1()
- {
- std::fill( *sky_mins, (*sky_mins)+2*6, 9999 );
- std::fill( *sky_maxs, (*sky_maxs)+2*6, -9999 );
- }
- void ClearSkyBox2()
- {
- static const float mins[ 2 ][ 6 ] = {
- { 9999, 9999, 9999, 9999, 9999, 9999 },
- { 9999, 9999, 9999, 9999, 9999, 9999 }
- };
- static const float maxs[ 2 ][ 6 ] = {
- { -9999, -9999, -9999, -9999, -9999, -9999 },
- { -9999, -9999, -9999, -9999, -9999, -9999 }
- };
- memcpy( sky_mins, mins, sizeof( mins ) );
- memcpy( sky_maxs, maxs, sizeof( maxs ) );
- }
- unsigned char i;
- __attribute__((noinline)) void call1()
- {
- for( i = 0; i < std::numeric_limits<decltype(i)>::max(); ++i )
- {
- ClearSkyBox1();
- }
- }
- __attribute__((noinline)) void call2()
- {
- for( i = 0; i < std::numeric_limits<decltype(i)>::max(); ++i )
- {
- ClearSkyBox2();
- }
- }
- int main()
- {
- while ( true )
- {
- call1();
- call2();
- }
- }
- ```
- # gcc -O2
- * call1: 88.41%
- * call2: 11.52%
- ```asm
- asm: /* call1() */
- Platform: X86 64 (Intel syntax)
- 0x55812a208200: endbr64
- 0x55812a208204: movss xmm1, dword ptr [rip + 0xe84]
- 0x55812a20820c: movss xmm0, dword ptr [rip + 0xe80]
- 0x55812a208214: mov esi, 0xffffffff
- 0x55812a208219: lea rcx, [rip + 0x2eb0]
- 0x55812a208220: lea rdx, [rip + 0x2e69]
- 0x55812a208227: nop word ptr [rax + rax]
- 0x55812a208230: lea rax, [rip + 0x2e69]
- 0x55812a208237: nop word ptr [rax + rax]
- 0x55812a208240: movss dword ptr [rax], xmm1
- 0x55812a208244: add rax, 4
- 0x55812a208248: cmp rax, rcx
- 0x55812a20824b: jne 0x55812a208240
- 0x55812a20824d: lea rax, [rip + 0x2e0c]
- 0x55812a208254: nop dword ptr [rax]
- 0x55812a208258: movss dword ptr [rax], xmm0
- 0x55812a20825c: add rax, 4
- 0x55812a208260: cmp rax, rdx
- 0x55812a208263: jne 0x55812a208258
- 0x55812a208265: sub sil, 1
- 0x55812a208269: jne 0x55812a208230
- 0x55812a20826b: mov byte ptr [rip + 0x2dce], 0xff
- 0x55812a208272: ret
- 0x55812a208273:
- ```
- ```asm
- asm: /* call2() */
- Platform: X86 64 (Intel syntax)
- 0x55812a208280: endbr64
- 0x55812a208284: lea r9, [rip + 0x2e15]
- 0x55812a20828b: lea rsi, [rip + 0x2dce]
- 0x55812a208292: movdqa xmm5, xmmword ptr [rip + 0xdd6]
- 0x55812a20829a: movdqa xmm4, xmmword ptr [rip + 0xdde]
- 0x55812a2082a2: lea r8, [r9 + 0x10]
- 0x55812a2082a6: lea rcx, [rsi + 0x10]
- 0x55812a2082aa: movdqa xmm3, xmmword ptr [rip + 0xd7e]
- 0x55812a2082b2: movdqa xmm2, xmmword ptr [rip + 0xd86]
- 0x55812a2082ba: movdqa xmm1, xmmword ptr [rip + 0xd9e]
- 0x55812a2082c2: movdqa xmm0, xmmword ptr [rip + 0xd56]
- 0x55812a2082ca: lea rdi, [r8 + 0x10]
- 0x55812a2082ce: lea rdx, [rcx + 0x10]
- 0x55812a2082d2: mov eax, 1
- 0x55812a2082d7: nop word ptr [rax + rax]
- 0x55812a2082e0: movaps xmmword ptr [r9], xmm1
- 0x55812a2082e4: movaps xmmword ptr [rsi], xmm0
- 0x55812a2082e7: movaps xmmword ptr [r8], xmm5
- 0x55812a2082eb: movaps xmmword ptr [rcx], xmm3
- 0x55812a2082ee: mov byte ptr [rip + 0x2d4c], al
- 0x55812a2082f4: movaps xmmword ptr [rdi], xmm4
- 0x55812a2082f7: movaps xmmword ptr [rdx], xmm2
- 0x55812a2082fa: add al, 1
- 0x55812a2082fc: jne 0x55812a2082e0
- 0x55812a2082fe: ret
- 0x55812a2082ff:
- ```
- # gcc -O3
- * call1: 1.25%
- * call2: 97.86%
- ```asm
- asm: /* call1() */
- Platform: X86 64 (Intel syntax)
- 0x55a33459c1f0: endbr64
- 0x55a33459c1f4: movaps xmm0, xmmword ptr [rip + 0xe95]
- 0x55a33459c1fb: mov byte ptr [rip + 0x2e3e], 0xff
- 0x55a33459c202: movaps xmmword ptr [rip + 0x2e97], xmm0
- 0x55a33459c209: movaps xmmword ptr [rip + 0x2ea0], xmm0
- 0x55a33459c210: movaps xmmword ptr [rip + 0x2ea9], xmm0
- 0x55a33459c217: movaps xmm0, xmmword ptr [rip + 0xe82]
- 0x55a33459c21e: movaps xmmword ptr [rip + 0x2e3b], xmm0
- 0x55a33459c225: movaps xmmword ptr [rip + 0x2e44], xmm0
- 0x55a33459c22c: movaps xmmword ptr [rip + 0x2e4d], xmm0
- 0x55a33459c233: ret
- 0x55a33459c234:
- ```
- ```asm
- asm: /* call2() */
- Platform: X86 64 (Intel syntax)
- 0x55a33459c240: endbr64
- 0x55a33459c244: lea r9, [rip + 0x2e55]
- 0x55a33459c24b: lea rsi, [rip + 0x2e0e]
- 0x55a33459c252: movdqa xmm5, xmmword ptr [rip + 0xe16]
- 0x55a33459c25a: movdqa xmm4, xmmword ptr [rip + 0xe1e]
- 0x55a33459c262: lea r8, [r9 + 0x10]
- 0x55a33459c266: lea rcx, [rsi + 0x10]
- 0x55a33459c26a: movdqa xmm3, xmmword ptr [rip + 0xdbe]
- 0x55a33459c272: movdqa xmm2, xmmword ptr [rip + 0xdc6]
- 0x55a33459c27a: movdqa xmm1, xmmword ptr [rip + 0xdde]
- 0x55a33459c282: movdqa xmm0, xmmword ptr [rip + 0xd96]
- 0x55a33459c28a: lea rdi, [r8 + 0x10]
- 0x55a33459c28e: lea rdx, [rcx + 0x10]
- 0x55a33459c292: mov eax, 1
- 0x55a33459c297: nop word ptr [rax + rax]
- 0x55a33459c2a0: movaps xmmword ptr [r9], xmm1
- 0x55a33459c2a4: movaps xmmword ptr [rsi], xmm0
- 0x55a33459c2a7: movaps xmmword ptr [r8], xmm5
- 0x55a33459c2ab: movaps xmmword ptr [rcx], xmm3
- 0x55a33459c2ae: mov byte ptr [rip + 0x2d8c], al
- 0x55a33459c2b4: movaps xmmword ptr [rdi], xmm4
- 0x55a33459c2b7: movaps xmmword ptr [rdx], xmm2
- 0x55a33459c2ba: add al, 1
- 0x55a33459c2bc: jne 0x55a33459c2a0
- 0x55a33459c2be: ret
- ```
Add Comment
Please, Sign In to add comment