]> Cypherpunks.ru repositories - gostls13.git/blob - test/phiopt.go
cmd/compile: add single-precision FMA code generation for riscv64
[gostls13.git] / test / phiopt.go
1 // +build amd64 s390x arm64
2 // errorcheck -0 -d=ssa/phiopt/debug=3
3
4 // Copyright 2016 The Go Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file.
7
8 package main
9
10 //go:noinline
11 func f0(a bool) bool {
12         x := false
13         if a {
14                 x = true
15         } else {
16                 x = false
17         }
18         return x // ERROR "converted OpPhi to Copy$"
19 }
20
21 //go:noinline
22 func f1(a bool) bool {
23         x := false
24         if a {
25                 x = false
26         } else {
27                 x = true
28         }
29         return x // ERROR "converted OpPhi to Not$"
30 }
31
32 //go:noinline
33 func f2(a, b int) bool {
34         x := true
35         if a == b {
36                 x = false
37         }
38         return x // ERROR "converted OpPhi to Not$"
39 }
40
41 //go:noinline
42 func f3(a, b int) bool {
43         x := false
44         if a == b {
45                 x = true
46         }
47         return x // ERROR "converted OpPhi to Copy$"
48 }
49
50 //go:noinline
51 func f4(a, b bool) bool {
52         return a || b // ERROR "converted OpPhi to OrB$"
53 }
54
55 //go:noinline
56 func f5or(a int, b bool) bool {
57         var x bool
58         if a == 0 {
59                 x = true
60         } else {
61                 x = b
62         }
63         return x // ERROR "converted OpPhi to OrB$"
64 }
65
66 //go:noinline
67 func f5and(a int, b bool) bool {
68         var x bool
69         if a == 0 {
70                 x = b
71         } else {
72                 x = false
73         }
74         return x // ERROR "converted OpPhi to AndB$"
75 }
76
77 //go:noinline
78 func f6or(a int, b bool) bool {
79         x := b
80         if a == 0 {
81                 // f6or has side effects so the OpPhi should not be converted.
82                 x = f6or(a, b)
83         }
84         return x
85 }
86
87 //go:noinline
88 func f6and(a int, b bool) bool {
89         x := b
90         if a == 0 {
91                 // f6and has side effects so the OpPhi should not be converted.
92                 x = f6and(a, b)
93         }
94         return x
95 }
96
97 //go:noinline
98 func f7or(a bool, b bool) bool {
99         return a || b // ERROR "converted OpPhi to OrB$"
100 }
101
102 //go:noinline
103 func f7and(a bool, b bool) bool {
104         return a && b // ERROR "converted OpPhi to AndB$"
105 }
106
107 //go:noinline
108 func f8(s string) (string, bool) {
109         neg := false
110         if s[0] == '-' {    // ERROR "converted OpPhi to Copy$"
111                 neg = true
112                 s = s[1:]
113         }
114         return s, neg
115 }
116
117 var d int
118
119 //go:noinline
120 func f9(a, b int) bool {
121         c := false
122         if a < 0 {          // ERROR "converted OpPhi to Copy$"
123                 if b < 0 {
124                         d = d + 1
125                 }
126                 c = true
127         }
128         return c
129 }
130
131 func main() {
132 }