Given a platform that supports the fused multiply add (FMA) instruction and the code:
contract MA(t T) { t * t + t } func ma(type T MA)(a, b, c T) T { return a*b + c } Does the compiled-for-any-type version support the FMA optimization when called with a floating-point type? If not, does a specialized version, making the two different based on whether the compiler chooses to specialize the function? If I specifically want to not use the optimization when instantiated with floats, can I do: func maNoFMA(type T MA)(a, b, c T) T { return T(a*b) + c } If I need it to use the guaranteed FMA intrinsic (see https://github.com/golang/go/issues/25819 ) when instantiated with floats, I can't do func maMustFMA(type T MA)(a, b, c T) T { switch a.(type) { case float32: return T(math.Fma( float64(a.(float32)), float64(b.(float32)), float64(c.(float32)), )) case float64: return T(math.Fma(a.(float64), b.(float64), c.(float64))) } return a*b + c } because that misses cases like type Float float64 so I have to use reflect which can't be dead-code eliminated during specialization. I'm sure there are other cases where similar questions could be asked, but this seems like a good proxy for the whole class. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.