Source file test/codegen/bool.go

     1  // asmcheck
     2  
     3  // Copyright 2020 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  // This file contains codegen tests related to boolean simplifications/optimizations.
    10  
    11  func convertNeq0B(x uint8, c bool) bool {
    12  	// amd64:"ANDL\t[$]1",-"SETNE"
    13  	// ppc64:"ANDCC",-"CMPW",-"ISEL"
    14  	// ppc64le:"ANDCC",-"CMPW",-"ISEL"
    15  	// ppc64le/power9:"ANDCC",-"CMPW",-"ISEL"
    16  	b := x&1 != 0
    17  	return c && b
    18  }
    19  
    20  func convertNeq0W(x uint16, c bool) bool {
    21  	// amd64:"ANDL\t[$]1",-"SETNE"
    22  	// ppc64:"ANDCC",-"CMPW",-"ISEL"
    23  	// ppc64le:"ANDCC",-"CMPW",-"ISEL"
    24  	// ppc64le/power9:"ANDCC",-CMPW",-"ISEL"
    25  	b := x&1 != 0
    26  	return c && b
    27  }
    28  
    29  func convertNeq0L(x uint32, c bool) bool {
    30  	// amd64:"ANDL\t[$]1",-"SETB"
    31  	// ppc64:"ANDCC",-"CMPW",-"ISEL"
    32  	// ppc64le:"ANDCC",-"CMPW",-"ISEL"
    33  	// ppc64le/power9:"ANDCC",-"CMPW",-"ISEL"
    34  	b := x&1 != 0
    35  	return c && b
    36  }
    37  
    38  func convertNeq0Q(x uint64, c bool) bool {
    39  	// amd64:"ANDL\t[$]1",-"SETB"
    40  	// ppc64:"ANDCC",-"CMP",-"ISEL"
    41  	// ppc64le:"ANDCC",-"CMP",-"ISEL"
    42  	// ppc64le/power9:"ANDCC",-"CMP",-"ISEL"
    43  	b := x&1 != 0
    44  	return c && b
    45  }
    46  
    47  func convertNeqBool32(x uint32) bool {
    48          // ppc64:"ANDCC",-"CMPW",-"ISEL"
    49          // ppc64le:"ANDCC",-"CMPW",-"ISEL"
    50          // ppc64le/power9:"ANDCC",-"CMPW",-"ISEL"
    51          return x&1 != 0
    52  }
    53  
    54  func convertEqBool32(x uint32) bool {
    55          // ppc64:"ANDCC",-"CMPW","XOR",-"ISEL"
    56          // ppc64le:"ANDCC",-"CMPW","XOR",-"ISEL"
    57          // ppc64le/power9:"ANDCC","XOR",-"CMPW",-"ISEL"
    58          return x&1 == 0
    59  }
    60  
    61  func convertNeqBool64(x uint64) bool {
    62          // ppc64:"ANDCC",-"CMP",-"ISEL"
    63          // ppc64le:"ANDCC",-"CMP",-"ISEL"
    64          // ppc64le/power9:"ANDCC",-"CMP",-"ISEL"
    65          return x&1 != 0
    66  }
    67  
    68  func convertEqBool64(x uint64) bool {
    69          // ppc64:"ANDCC","XOR",-"CMP",-"ISEL"
    70          // ppc64le:"ANDCC","XOR",-"CMP",-"ISEL"
    71          // ppc64le/power9:"ANDCC","XOR",-"CMP",-"ISEL"
    72          return x&1 == 0
    73  }
    74  

View as plain text