Source file test/codegen/known_bits.go

     1  // asmcheck
     2  
     3  // Copyright 2026 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  func knownBitsPhiAnd(cond bool) int {
    10  	x := 1
    11  	if cond {
    12  		x = 3
    13  	}
    14  	// amd64:-"AND"
    15  	// arm64:-"AND"
    16  	return x & 1
    17  }
    18  
    19  func knownBitsDeferPattern(a, b bool) int {
    20  	bits := 0
    21  	bits |= 1 << 0
    22  	if a {
    23  		bits |= 1 << 1
    24  	}
    25  	bits |= 1 << 2
    26  	if b {
    27  		bits |= 1 << 3
    28  	}
    29  	// amd64:-"AND"
    30  	// arm64:-"AND"
    31  	return bits & (1<<2 | 1<<0)
    32  }
    33  
    34  func knownBitsXorToggle(a, b, c bool) int {
    35  	bits := 0
    36  	bits ^= 1 << 0
    37  	if a {
    38  		bits ^= 1 << 1
    39  	}
    40  	bits ^= 1 << 2
    41  	if b {
    42  		bits ^= 1 << 3
    43  	}
    44  	bits ^= 1 << 2
    45  	if c {
    46  		bits ^= 1 << 4
    47  	}
    48  	// amd64:-"AND"
    49  	// arm64:-"AND"
    50  	return bits & (1<<2 | 1<<0)
    51  }
    52  

View as plain text