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.
Most functions in the
mathpackage operate on float64s. For users who work with float32s this leads to a lot of code likefloat32(math.Floor(float64(v))wherevar v float32(whereFloorcould be any one of the many math functions). On amd64 with GOAMD64=v2, that example compiles towhich is the literal interpretation of the code. I suggest that this sequence gets optimized to a use of
ROUNDSSinstead. The example usesROUNDSD, but of course I'd like this to work for all relevant instructions.