Given the simple function:
double uniform_double_from_int(unsigned n) {
return n / 4294967296.0;
}
GCC 13.2 with -O3 generates the following assembly:
uniform_double_from_int(unsigned int):
mov edi, edi
vxorps xmm0, xmm0, xmm0
vcvtsi2sd xmm0, xmm0, rdi
vmulsd xmm0, xmm0, QWORD PTR .LC0[rip]
ret
.LC0:
.long 0
.long 1039138816
Why on earth is GCC performing the no-op mov edi, edi
at the begining of this function?