From e197f467d51318305439610d44af0e20dae7062f Mon Sep 17 00:00:00 2001 From: Alexandru Moșoi Date: Mon, 29 Feb 2016 19:29:04 +0100 Subject: [dev.ssa] cmd/compile/internal/ssa: simplify boolean phis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Decreases the generated code slightly. * Similar to phiopt pass from gcc, except it only handles booleans. Handling Eq/Neq had no impact on the generated code. name old time/op new time/op delta Template 453ms ± 4% 451ms ± 4% ~ (p=0.468 n=24+24) GoTypes 1.55s ± 1% 1.55s ± 2% ~ (p=0.287 n=24+25) Compiler 6.53s ± 2% 6.56s ± 1% +0.46% (p=0.050 n=23+23) MakeBash 45.8s ± 2% 45.7s ± 2% ~ (p=0.866 n=24+25) name old text-bytes new text-bytes delta HelloSize 676k ± 0% 676k ± 0% ~ (all samples are equal) CmdGoSize 8.07M ± 0% 8.07M ± 0% -0.03% (p=0.000 n=25+25) Change-Id: Ia62477b7554127958a14cb27f85849b095d63663 Reviewed-on: https://go-review.googlesource.com/20090 Reviewed-by: Keith Randall Run-TryBot: Alexandru Moșoi TryBot-Result: Gobot Gobot --- test/phiopt.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/phiopt.go (limited to 'test/phiopt.go') diff --git a/test/phiopt.go b/test/phiopt.go new file mode 100644 index 0000000000..9b9b701124 --- /dev/null +++ b/test/phiopt.go @@ -0,0 +1,43 @@ +// +build amd64 +// errorcheck -0 -d=ssa/phiopt/debug=3 + +package main + +func f0(a bool) bool { + x := false + if a { + x = true + } else { + x = false + } + return x // ERROR "converted OpPhi to OpCopy$" +} + +func f1(a bool) bool { + x := false + if a { + x = false + } else { + x = true + } + return x // ERROR "converted OpPhi to OpNot$" +} + +func f2(a, b int) bool { + x := true + if a == b { + x = false + } + return x // ERROR "converted OpPhi to OpNot$" +} + +func f3(a, b int) bool { + x := false + if a == b { + x = true + } + return x // ERROR "converted OpPhi to OpCopy$" +} + +func main() { +} -- cgit v1.3