| 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 |
|
| 12 |
package main |
| 13 |
|
| 14 |
import "fmt" |
| 15 |
|
| 16 |
type i4 struct { |
| 17 |
a, b, c, d int |
| 18 |
} |
| 19 |
|
| 20 |
//go:registerparams |
| 21 |
//go:noinline |
| 22 |
func F(x i4) i4 { |
| 23 |
ab := x.a + x.b |
| 24 |
bc := x.b + x.c |
| 25 |
cd := x.c + x.d |
| 26 |
ad := x.a + x.d |
| 27 |
ba := x.a - x.b |
| 28 |
cb := x.b - x.c |
| 29 |
dc := x.c - x.d |
| 30 |
da := x.a - x.d |
| 31 |
|
| 32 |
return i4{ab*bc + da, cd*ad + cb, ba*cb + ad, dc*da + bc} |
| 33 |
} |
| 34 |
|
| 35 |
func main() { |
| 36 |
x := i4{1, 2, 3, 4} |
| 37 |
y := x |
| 38 |
z := F(x) |
| 39 |
if (i4{12, 34, 6, 8}) != z { |
| 40 |
fmt.Printf("y=%v, z=%v\n", y, z) |
| 41 |
} |
| 42 |
} |