Most functions in the math
package operate on float64s. For users who work with float32s this leads to a lot of code like float32(math.Floor(float64(v))
where var v float32
(where Floor
could be any one of the many math functions). On amd64 with GOAMD64=v2, that example compiles to
CVTSS2SD X0, X1
ROUNDSD $1, X1, X1
CVTSD2SS X1, X1
which is the literal interpretation of the code. I suggest that this sequence gets optimized to a use of ROUNDSS
instead. The example uses ROUNDSD
, but of course I'd like this to work for all relevant instructions.
Comment From: mrkfrmn
@golang/compiler
Comment From: adonovan
Just curious: what are you using float32 for?
Comment From: dominikh
@adonovan 2D vector graphics renderer. Among other things, colors are represented as [4]float32.