1// Copyright 2022 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package main 6 7import ( 8 "fmt" 9 "os" 10) 11 12//go:noinline 13func f(x float64) float64 { 14 return x 15} 16 17func inlineFma(x, y, z float64) float64 { 18 return x + y*z 19} 20 21func main() { 22 w, x, y := 1.0, 1.0, 1.0 23 x = f(x + x/(1<<52)) 24 w = f(w / (1 << 27)) 25 y = f(y + y/(1<<52)) 26 w0 := f(2 * w * (1 - w)) 27 w1 := f(w * (1 + w)) 28 x = x + w0*w1 29 x = inlineFma(x, w0, w1) 30 y = y + f(w0*w1) 31 y = y + f(w0*w1) 32 fmt.Println(x, y, x-y) 33 34 if x != y { 35 os.Exit(1) 36 } 37} 38