Closed ktye closed 10 months ago
e.g. modified indexed assign
#include<stdint.h> void f(int32_t *x, int32_t y, int32_t z) { x[y]+=z; } // f vs g int32_t *I; #define I32(x) I[(x)>>2] #define SetI32(x,y) I[(x)>>2]=(y) void g(uint64_t x, int32_t y, int32_t z) { SetI32(((int32_t)(x)+(4*y)),(I32(((int32_t)(x)+(4*y)))+z)); }
with -O3
-O3
f: movsx rsi, esi add DWORD PTR [rdi+rsi*4], edx ret g: lea eax, [rdi+rsi*4] mov ecx, edx mov rdx, QWORD PTR I[rip] sar eax, 2 cdqe add DWORD PTR [rdx+rax*4], ecx ret I: .zero 8
e.g. modified indexed assign
with
-O3