aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/gc/testdata
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2015-08-05 15:56:31 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2015-08-06 17:44:25 +0000
commitca088cf4e59a1e9ef97dbbf16f035a152a8ddda8 (patch)
treed5227355f612f8ed1806a644645b8c0fe906ba4f /src/cmd/compile/internal/gc/testdata
parentcfd8dfaa10ab387c6b9c9e620aadab5852a4c76e (diff)
downloadgo-ca088cf4e59a1e9ef97dbbf16f035a152a8ddda8.tar.xz
[dev.ssa] cmd/compile: handle phi control values
Tests courtesy of Todd Neal. Change-Id: If657c7c7d3cd1ce01e9d9ad79eb6b2110230c0f9 Reviewed-on: https://go-review.googlesource.com/13267 Reviewed-by: Todd Neal <todd@tneal.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/gc/testdata')
-rw-r--r--src/cmd/compile/internal/gc/testdata/ctl_ssa.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/gc/testdata/ctl_ssa.go b/src/cmd/compile/internal/gc/testdata/ctl_ssa.go
new file mode 100644
index 0000000000..7377c9aee8
--- /dev/null
+++ b/src/cmd/compile/internal/gc/testdata/ctl_ssa.go
@@ -0,0 +1,53 @@
+// run
+
+// Copyright 2015 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.
+
+// Test control flow
+
+package main
+
+// nor_ssa calculates NOR(a, b).
+// It is implemented in a way that generates
+// phi control values.
+func nor_ssa(a, b bool) bool {
+ var c bool
+ if a {
+ c = true
+ }
+ if b {
+ c = true
+ }
+ if c {
+ return false
+ }
+ return true
+}
+
+func testPhiControl() {
+ tests := [...][3]bool{ // a, b, want
+ {false, false, true},
+ {true, false, false},
+ {false, true, false},
+ {true, true, false},
+ }
+ for _, test := range tests {
+ a, b := test[0], test[1]
+ got := nor_ssa(a, b)
+ want := test[2]
+ if want != got {
+ print("nor(", a, ", ", b, ")=", want, " got ", got, "\n")
+ failed = true
+ }
+ }
+}
+
+var failed = false
+
+func main() {
+ testPhiControl()
+ if failed {
+ panic("failed")
+ }
+}