Advertisement
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];
- __attribute__((noinline)) void ClearSkyBox1()
- {
- std::fill( *sky_mins, (*sky_mins)+2*6, 9999 );
- std::fill( *sky_maxs, (*sky_maxs)+2*6, -9999 );
- }
- __attribute__((noinline)) 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 ) );
- }
- int main()
- {
- while ( true )
- {
- ClearSkyBox1();
- ClearSkyBox2();
- }
- }
- ```
- # gcc -O2
- * ClearSkyBox1: 51.26%
- * ClearSkyBox2: 43.13%
- ```asm
- asm: /* ClearSkyBox1() */
- Platform: X86 64 (Intel syntax)
- 0x55d41bc4b150: endbr64
- 0x55d41bc4b154: lea rax, [rip + 0x2f25]
- 0x55d41bc4b15b: movss xmm0, dword ptr [rip + 0xf2d]
- 0x55d41bc4b163: lea rdx, [rax + 0x30]
- 0x55d41bc4b167: nop word ptr [rax + rax]
- 0x55d41bc4b170: movss dword ptr [rax], xmm0
- 0x55d41bc4b174: add rax, 4
- 0x55d41bc4b178: cmp rax, rdx
- 0x55d41bc4b17b: jne 0x55d41bc4b170
- 0x55d41bc4b17d: lea rax, [rip + 0x2ebc]
- 0x55d41bc4b184: movss xmm0, dword ptr [rip + 0xf08]
- 0x55d41bc4b18c: lea rdx, [rax + 0x30]
- 0x55d41bc4b190: movss dword ptr [rax], xmm0
- 0x55d41bc4b194: add rax, 4
- 0x55d41bc4b198: cmp rax, rdx
- 0x55d41bc4b19b: jne 0x55d41bc4b190
- 0x55d41bc4b19d: ret
- 0x55d41bc4b19e:
- ```
- ```asm
- asm: /* ClearSkyBox2() */
- Platform: X86 64 (Intel syntax)
- 0x55d41bc4b1a0: endbr64
- 0x55d41bc4b1a4: movdqa xmm0, xmmword ptr [rip + 0xeb4]
- 0x55d41bc4b1ac: movdqa xmm1, xmmword ptr [rip + 0xebc]
- 0x55d41bc4b1b4: movdqa xmm2, xmmword ptr [rip + 0xec4]
- 0x55d41bc4b1bc: movdqa xmm3, xmmword ptr [rip + 0xe5c]
- 0x55d41bc4b1c4: movdqa xmm4, xmmword ptr [rip + 0xe64]
- 0x55d41bc4b1cc: movdqa xmm5, xmmword ptr [rip + 0xe6c]
- 0x55d41bc4b1d4: movaps xmmword ptr [rip + 0x2ea5], xmm0
- 0x55d41bc4b1db: movaps xmmword ptr [rip + 0x2eae], xmm1
- 0x55d41bc4b1e2: movaps xmmword ptr [rip + 0x2eb7], xmm2
- 0x55d41bc4b1e9: movaps xmmword ptr [rip + 0x2e50], xmm3
- 0x55d41bc4b1f0: movaps xmmword ptr [rip + 0x2e59], xmm4
- 0x55d41bc4b1f7: movaps xmmword ptr [rip + 0x2e62], xmm5
- 0x55d41bc4b1fe: ret
- 0x55d41bc4b1ff:
- ```
- # gcc -O3
- * ClearSkyBox1: 68.17%
- * ClearSkyBox2: 22.81%
- ```asm
- asm: /* ClearSkyBox1() */
- Platform: X86 64 (Intel syntax)
- 0x55b02e8b1150: endbr64
- 0x55b02e8b1154: movaps xmm0, xmmword ptr [rip + 0xf35]
- 0x55b02e8b115b: movaps xmmword ptr [rip + 0x2f1e], xmm0
- 0x55b02e8b1162: movaps xmmword ptr [rip + 0x2f27], xmm0
- 0x55b02e8b1169: movaps xmmword ptr [rip + 0x2f30], xmm0
- 0x55b02e8b1170: movaps xmm0, xmmword ptr [rip + 0xf29]
- 0x55b02e8b1177: movaps xmmword ptr [rip + 0x2ec2], xmm0
- 0x55b02e8b117e: movaps xmmword ptr [rip + 0x2ecb], xmm0
- 0x55b02e8b1185: movaps xmmword ptr [rip + 0x2ed4], xmm0
- 0x55b02e8b118c: ret
- 0x55b02e8b118d:
- ```
- ```asm
- asm: /* ClearSkyBox2() */
- Platform: X86 64 (Intel syntax)
- 0x55b02e8b1190: endbr64
- 0x55b02e8b1194: movdqa xmm0, xmmword ptr [rip + 0xec4]
- 0x55b02e8b119c: movdqa xmm1, xmmword ptr [rip + 0xecc]
- 0x55b02e8b11a4: movdqa xmm2, xmmword ptr [rip + 0xed4]
- 0x55b02e8b11ac: movdqa xmm3, xmmword ptr [rip + 0xe6c]
- 0x55b02e8b11b4: movdqa xmm4, xmmword ptr [rip + 0xe74]
- 0x55b02e8b11bc: movdqa xmm5, xmmword ptr [rip + 0xe7c]
- 0x55b02e8b11c4: movaps xmmword ptr [rip + 0x2eb5], xmm0
- 0x55b02e8b11cb: movaps xmmword ptr [rip + 0x2ebe], xmm1
- 0x55b02e8b11d2: movaps xmmword ptr [rip + 0x2ec7], xmm2
- 0x55b02e8b11d9: movaps xmmword ptr [rip + 0x2e60], xmm3
- 0x55b02e8b11e0: movaps xmmword ptr [rip + 0x2e69], xmm4
- 0x55b02e8b11e7: movaps xmmword ptr [rip + 0x2e72], xmm5
- 0x55b02e8b11ee: ret
- 0x55b02e8b11ef:
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement