github.com/euank/go@v0.0.0-20160829210321-495514729181/src/cmd/compile/internal/gc/testdata/cmp_ssa.go (about)

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // cmp_ssa.go tests compare simplification operations.
     6  package main
     7  
     8  import "fmt"
     9  
    10  var failed = false
    11  
    12  //go:noinline
    13  func eq_ssa(a int64) bool {
    14  	return 4+a == 10
    15  }
    16  
    17  //go:noinline
    18  func neq_ssa(a int64) bool {
    19  	return 10 != a+4
    20  }
    21  
    22  func testCmp() {
    23  	if wanted, got := true, eq_ssa(6); wanted != got {
    24  		fmt.Printf("eq_ssa: expected %v, got %v\n", wanted, got)
    25  		failed = true
    26  	}
    27  	if wanted, got := false, eq_ssa(7); wanted != got {
    28  		fmt.Printf("eq_ssa: expected %v, got %v\n", wanted, got)
    29  		failed = true
    30  	}
    31  
    32  	if wanted, got := false, neq_ssa(6); wanted != got {
    33  		fmt.Printf("neq_ssa: expected %v, got %v\n", wanted, got)
    34  		failed = true
    35  	}
    36  	if wanted, got := true, neq_ssa(7); wanted != got {
    37  		fmt.Printf("neq_ssa: expected %v, got %v\n", wanted, got)
    38  		failed = true
    39  	}
    40  }
    41  
    42  func main() {
    43  	testCmp()
    44  
    45  	if failed {
    46  		panic("failed")
    47  	}
    48  }