1// run 2 3//go:build !wasm 4 5// Copyright 2021 The Go Authors. All rights reserved. 6// Use of this source code is governed by a BSD-style 7// license that can be found in the LICENSE file. 8 9// wasm is excluded because the compiler chatter about register abi pragma ends up 10// on stdout, and causes the expected output to not match. 11 12package main 13 14import "fmt" 15 16type i4 struct { 17 a, b, c, d int 18} 19 20//go:noinline 21func spills(px *i4) { 22} 23 24//go:registerparams 25//go:noinline 26func F(x i4) i4 { 27 ab := x.a + x.b 28 bc := x.b + x.c 29 cd := x.c + x.d 30 ad := x.a + x.d 31 ba := x.a - x.b 32 cb := x.b - x.c 33 dc := x.c - x.d 34 da := x.a - x.d 35 i := i4{ab*bc + da, cd*ad + cb, ba*cb + ad, dc*da + bc} 36 spills(&i) 37 return i 38} 39 40func main() { 41 x := i4{1, 2, 3, 4} 42 y := x 43 z := F(x) 44 if z != (i4{12, 34, 6, 8}) { 45 fmt.Printf("y=%v, z=%v\n", y, z) 46 } 47} 48