2016-02-29 11:29:04 -07:00
|
|
|
// +build amd64
|
|
|
|
// errorcheck -0 -d=ssa/phiopt/debug=3
|
|
|
|
|
2016-04-12 10:24:34 -06:00
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2016-02-29 11:29:04 -07:00
|
|
|
package main
|
|
|
|
|
2016-04-12 10:24:34 -06:00
|
|
|
//go:noinline
|
2016-02-29 11:29:04 -07:00
|
|
|
func f0(a bool) bool {
|
|
|
|
x := false
|
|
|
|
if a {
|
|
|
|
x = true
|
|
|
|
} else {
|
|
|
|
x = false
|
|
|
|
}
|
2016-04-12 10:24:34 -06:00
|
|
|
return x // ERROR "converted OpPhi to Copy$"
|
2016-02-29 11:29:04 -07:00
|
|
|
}
|
|
|
|
|
2016-04-12 10:24:34 -06:00
|
|
|
//go:noinline
|
2016-02-29 11:29:04 -07:00
|
|
|
func f1(a bool) bool {
|
|
|
|
x := false
|
|
|
|
if a {
|
|
|
|
x = false
|
|
|
|
} else {
|
|
|
|
x = true
|
|
|
|
}
|
2016-04-12 10:24:34 -06:00
|
|
|
return x // ERROR "converted OpPhi to Not$"
|
2016-02-29 11:29:04 -07:00
|
|
|
}
|
|
|
|
|
2016-04-12 10:24:34 -06:00
|
|
|
//go:noinline
|
2016-02-29 11:29:04 -07:00
|
|
|
func f2(a, b int) bool {
|
|
|
|
x := true
|
|
|
|
if a == b {
|
|
|
|
x = false
|
|
|
|
}
|
2016-04-12 10:24:34 -06:00
|
|
|
return x // ERROR "converted OpPhi to Not$"
|
2016-02-29 11:29:04 -07:00
|
|
|
}
|
|
|
|
|
2016-04-12 10:24:34 -06:00
|
|
|
//go:noinline
|
2016-02-29 11:29:04 -07:00
|
|
|
func f3(a, b int) bool {
|
|
|
|
x := false
|
|
|
|
if a == b {
|
|
|
|
x = true
|
|
|
|
}
|
2016-04-12 10:24:34 -06:00
|
|
|
return x // ERROR "converted OpPhi to Copy$"
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:noinline
|
|
|
|
func f4(a, b bool) bool {
|
2016-04-24 13:21:07 -06:00
|
|
|
return a || b // ERROR "converted OpPhi to OrB$"
|
2016-04-12 10:24:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//go:noinline
|
2016-04-22 04:44:31 -06:00
|
|
|
func f5or(a int, b bool) bool {
|
|
|
|
var x bool
|
2016-04-12 10:24:34 -06:00
|
|
|
if a == 0 {
|
|
|
|
x = true
|
2016-04-22 04:44:31 -06:00
|
|
|
} else {
|
|
|
|
x = b
|
2016-04-12 10:24:34 -06:00
|
|
|
}
|
2016-04-24 13:21:07 -06:00
|
|
|
return x // ERROR "converted OpPhi to OrB$"
|
2016-04-12 10:24:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//go:noinline
|
2016-04-22 04:44:31 -06:00
|
|
|
func f5and(a int, b bool) bool {
|
|
|
|
var x bool
|
|
|
|
if a == 0 {
|
|
|
|
x = b
|
|
|
|
} else {
|
|
|
|
x = false
|
|
|
|
}
|
2016-04-24 13:21:07 -06:00
|
|
|
return x // ERROR "converted OpPhi to AndB$"
|
2016-04-22 04:44:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//go:noinline
|
|
|
|
func f6or(a int, b bool) bool {
|
2016-04-12 10:24:34 -06:00
|
|
|
x := b
|
|
|
|
if a == 0 {
|
2016-04-22 04:44:31 -06:00
|
|
|
// f6or has side effects so the OpPhi should not be converted.
|
|
|
|
x = f6or(a, b)
|
2016-04-12 10:24:34 -06:00
|
|
|
}
|
|
|
|
return x
|
2016-02-29 11:29:04 -07:00
|
|
|
}
|
|
|
|
|
2016-04-22 04:44:31 -06:00
|
|
|
//go:noinline
|
|
|
|
func f6and(a int, b bool) bool {
|
|
|
|
x := b
|
|
|
|
if a == 0 {
|
|
|
|
// f6and has side effects so the OpPhi should not be converted.
|
|
|
|
x = f6and(a, b)
|
|
|
|
}
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:noinline
|
|
|
|
func f7or(a bool, b bool) bool {
|
2016-04-24 13:21:07 -06:00
|
|
|
return a || b // ERROR "converted OpPhi to OrB$"
|
2016-04-22 04:44:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//go:noinline
|
|
|
|
func f7and(a bool, b bool) bool {
|
2016-04-24 13:21:07 -06:00
|
|
|
return a && b // ERROR "converted OpPhi to AndB$"
|
2016-04-22 04:44:31 -06:00
|
|
|
}
|
|
|
|
|
2016-02-29 11:29:04 -07:00
|
|
|
func main() {
|
|
|
|
}
|