Keith Randall | 0de0ed3 | 2018-04-09 10:25:15 -0700 | [diff] [blame] | 1 | // run |
| 2 | |
| 3 | // Copyright 2018 The Go Authors. All rights reserved. |
| 4 | // Use of this source code is governed by a BSD-style |
| 5 | // license that can be found in the LICENSE file. |
| 6 | |
| 7 | package main |
| 8 | |
| 9 | // On 32-bit archs, one of the f fields of a [2]T |
| 10 | // will be unaligned (address of 4 mod 8). |
| 11 | // Make sure we can access the f fields successfully, |
| 12 | // particularly for load-add combo instructions |
| 13 | // introduced by CL 102036. |
| 14 | type T struct { |
| 15 | pad uint32 |
| 16 | f float64 |
| 17 | } |
| 18 | |
| 19 | //go:noinline |
| 20 | func f(t, u *T) float64 { |
| 21 | return 3.0 + t.f + u.f |
| 22 | } |
| 23 | |
| 24 | func main() { |
| 25 | t := [2]T{{0, 1.0}, {0, 2.0}} |
| 26 | sink = f(&t[0], &t[1]) |
| 27 | } |
| 28 | |
| 29 | var sink float64 |