1 // +build amd64 s390x 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 func main() { 108 } 109