|
1 From 5dda3bc2fd0616f8789cc7f2919d2af49fc64a66 Mon Sep 17 00:00:00 2001 |
|
2 From: Michael Hudson-Doyle <[email protected]> |
|
3 Date: Fri, 6 Nov 2015 10:10:07 +1300 |
|
4 Subject: [PATCH 40/63] [release-branch.go1.5] cmd/internal/obj/ppc64: fix |
|
5 assembly of SRADCC with immediate |
|
6 |
|
7 sradi and sradi. hide the top bit of their immediate argument apart from the |
|
8 rest of it, but the code only handled the sradi case. |
|
9 |
|
10 I'm pretty sure this is the only instruction missing (a couple of the rotate |
|
11 instructions encode their immediate the same way but their handling looks OK). |
|
12 |
|
13 This fixes the failure of "GOARCH=amd64 ~/go/bin/go install -v runtime" as |
|
14 reported in the bug. |
|
15 |
|
16 Fixes #11987 |
|
17 |
|
18 Change-Id: I0cdefcd7a04e0e8fce45827e7054ffde9a83f589 |
|
19 Reviewed-on: https://go-review.googlesource.com/16710 |
|
20 Reviewed-by: Minux Ma <[email protected]> |
|
21 Reviewed-on: https://go-review.googlesource.com/16983 |
|
22 Run-TryBot: Austin Clements <[email protected]> |
|
23 Reviewed-by: Ian Lance Taylor <[email protected]> |
|
24 Reviewed-by: Russ Cox <[email protected]> |
|
25 --- |
|
26 src/cmd/internal/obj/ppc64/asm9.go | 2 +- |
|
27 test/fixedbugs/issue11987.go | 23 +++++++++++++++++++++++ |
|
28 2 files changed, 24 insertions(+), 1 deletion(-) |
|
29 create mode 100644 test/fixedbugs/issue11987.go |
|
30 |
|
31 diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go |
|
32 index 2955a00..f074d90 100644 |
|
33 --- a/src/cmd/internal/obj/ppc64/asm9.go |
|
34 +++ b/src/cmd/internal/obj/ppc64/asm9.go |
|
35 @@ -2173,7 +2173,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) { |
|
36 r = int(p.To.Reg) |
|
37 } |
|
38 o1 = AOP_RRR(uint32(opirr(ctxt, int(p.As))), uint32(r), uint32(p.To.Reg), uint32(v)&31) |
|
39 - if p.As == ASRAD && (v&0x20 != 0) { |
|
40 + if (p.As == ASRAD || p.As == ASRADCC) && (v&0x20 != 0) { |
|
41 o1 |= 1 << 1 /* mb[5] */ |
|
42 } |
|
43 |
|
44 diff --git a/test/fixedbugs/issue11987.go b/test/fixedbugs/issue11987.go |
|
45 new file mode 100644 |
|
46 index 0000000..78fc28b |
|
47 --- /dev/null |
|
48 +++ b/test/fixedbugs/issue11987.go |
|
49 @@ -0,0 +1,23 @@ |
|
50 +// run |
|
51 + |
|
52 +// Copyright 2015 The Go Authors. All rights reserved. |
|
53 +// Use of this source code is governed by a BSD-style |
|
54 +// license that can be found in the LICENSE file. |
|
55 + |
|
56 +// Issue 11987. The ppc64 SRADCC instruction was misassembled in a way |
|
57 +// lost bit 5 of the immediate so v>>32 was assembled as v>>0. SRADCC |
|
58 +// is only ever inserted by peep so it's hard to be sure when it will |
|
59 +// be used. This formulation worked when the bug was fixed. |
|
60 + |
|
61 +package main |
|
62 + |
|
63 +import "fmt" |
|
64 + |
|
65 +var v int64 = 0x80000000 |
|
66 + |
|
67 +func main() { |
|
68 + s := fmt.Sprintf("%v", v>>32 == 0) |
|
69 + if s != "true" { |
|
70 + fmt.Printf("BUG: v>>32 == 0 evaluated as %q\n", s) |
|
71 + } |
|
72 +} |
|
73 -- |
|
74 2.6.1 |
|
75 |