github.com/hikaru7719/go@v0.0.0-20181025140707-c8b2ac68906a/test/codegen/memops.go (about)

     1  // asmcheck
     2  
     3  // Copyright 2018 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package codegen
     8  
     9  var x [2]bool
    10  var x8 [2]uint8
    11  var x16 [2]uint16
    12  var x32 [2]uint32
    13  var x64 [2]uint64
    14  
    15  func compMem1() int {
    16  	// amd64:`CMPB\t"".x\+1\(SB\), [$]0`
    17  	if x[1] {
    18  		return 1
    19  	}
    20  	// amd64:`CMPB\t"".x8\+1\(SB\), [$]7`
    21  	if x8[1] == 7 {
    22  		return 1
    23  	}
    24  	// amd64:`CMPW\t"".x16\+2\(SB\), [$]7`
    25  	if x16[1] == 7 {
    26  		return 1
    27  	}
    28  	// amd64:`CMPL\t"".x32\+4\(SB\), [$]7`
    29  	if x32[1] == 7 {
    30  		return 1
    31  	}
    32  	// amd64:`CMPQ\t"".x64\+8\(SB\), [$]7`
    33  	if x64[1] == 7 {
    34  		return 1
    35  	}
    36  	return 0
    37  }
    38  
    39  //go:noinline
    40  func f(x int) bool {
    41  	return false
    42  }
    43  
    44  //go:noinline
    45  func f8(x int) int8 {
    46  	return 0
    47  }
    48  
    49  //go:noinline
    50  func f16(x int) int16 {
    51  	return 0
    52  }
    53  
    54  //go:noinline
    55  func f32(x int) int32 {
    56  	return 0
    57  }
    58  
    59  //go:noinline
    60  func f64(x int) int64 {
    61  	return 0
    62  }
    63  
    64  func compMem2() int {
    65  	// amd64:`CMPB\t8\(SP\), [$]0`
    66  	if f(3) {
    67  		return 1
    68  	}
    69  	// amd64:`CMPB\t8\(SP\), [$]7`
    70  	if f8(3) == 7 {
    71  		return 1
    72  	}
    73  	// amd64:`CMPW\t8\(SP\), [$]7`
    74  	if f16(3) == 7 {
    75  		return 1
    76  	}
    77  	// amd64:`CMPL\t8\(SP\), [$]7`
    78  	if f32(3) == 7 {
    79  		return 1
    80  	}
    81  	// amd64:`CMPQ\t8\(SP\), [$]7`
    82  	if f64(3) == 7 {
    83  		return 1
    84  	}
    85  	return 0
    86  }