Skip to content

-CfAVX girls are still not at ease with frac(single), performance-wise

Now that #38248 (closed) was supposedly and mostly fixed, the echoes of past fears linger.

On x64 with -CfAVX or -CfAVX2, and -O2 or greater,

var
	x: single;
begin
	x := random;
	x := frac(x);
end.

compiles into

; x := frac(x);
vroundss $0x3,%xmm1,%xmm1,%xmm0
vsubss %xmm0,%xmm1,%xmm0
vcvtss2sd %xmm0,%xmm0,%xmm0
vcvtsd2ss %xmm0,%xmm0,%xmm0

Saying straightly, frac(single) produces useless single→double→single epilogue.

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