Skip to content

FR: perform floating “x * 2” as “x + x”, always.

×2s often occur in formulas (recent example), and I didn't go into details, but GCC seems to do it on sight, even at -O0, nor does it require -ffast-math.

Additions can be slightly cheaper in general, but more importantly, this often (with SSE in particular) saves on reading constant “2” from memory. Example of the potential effect where this also prevents the suboptimal decision to cache “2” by using a nonvolatile xmm6:

Mul_OX

Result on FPU is worse though, because the compiler stores t in memory (i386/win32). If it could work with t entirely in FPU register, result would be better again. Even if it can’t, who cares about FPU anyway.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information