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
8package main
9
10//go:noinline
11func 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
22func 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
33func 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
42func 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
51func f4(a, b bool) bool {
52	return a || b // ERROR "converted OpPhi to OrB$"
53}
54
55//go:noinline
56func 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
67func 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
78func 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
88func 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
98func f7or(a bool, b bool) bool {
99	return a || b // ERROR "converted OpPhi to OrB$"
100}
101
102//go:noinline
103func f7and(a bool, b bool) bool {
104	return a && b // ERROR "converted OpPhi to AndB$"
105}
106
107//go:noinline
108func 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
117var d int
118
119//go:noinline
120func 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
131func main() {
132}
133