]> Cypherpunks.ru repositories - gostls13.git/blob - test/codegen/bool.go
cmd/compile: optimize x & 1 != 0 to x & 1 on amd64
[gostls13.git] / 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         b := x&1 != 0
14         return c && b
15 }
16
17 func convertNeq0W(x uint16, c bool) bool {
18         // amd64:"ANDL\t[$]1",-"SETNE"
19         b := x&1 != 0
20         return c && b
21 }
22
23 func convertNeq0L(x uint32, c bool) bool {
24         // amd64:"ANDL\t[$]1",-"SETB"
25         b := x&1 != 0
26         return c && b
27 }
28
29 func convertNeq0Q(x uint64, c bool) bool {
30         // amd64:"ANDQ\t[$]1",-"SETB"
31         b := x&1 != 0
32         return c && b
33 }