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.
13 // This file contains codegen tests related to boolean simplifications/optimizations.
15 func convertNeq0B(x uint8, c bool) bool {
16 // amd64:"ANDL\t[$]1",-"SETNE"
17 // ppc64x:"RLDICL",-"CMPW",-"ISEL"
22 func convertNeq0W(x uint16, c bool) bool {
23 // amd64:"ANDL\t[$]1",-"SETNE"
24 // ppc64x:"RLDICL",-"CMPW",-"ISEL"
29 func convertNeq0L(x uint32, c bool) bool {
30 // amd64:"ANDL\t[$]1",-"SETB"
31 // ppc64x:"RLDICL",-"CMPW",-"ISEL"
36 func convertNeq0Q(x uint64, c bool) bool {
37 // amd64:"ANDL\t[$]1",-"SETB"
38 // ppc64x:"RLDICL",-"CMP",-"ISEL"
43 func convertNeqBool32(x uint32) bool {
44 // ppc64x:"RLDICL",-"CMPW",-"ISEL"
48 func convertEqBool32(x uint32) bool {
49 // ppc64x:"RLDICL",-"CMPW","XOR",-"ISEL"
53 func convertNeqBool64(x uint64) bool {
54 // ppc64x:"RLDICL",-"CMP",-"ISEL"
58 func convertEqBool64(x uint64) bool {
59 // ppc64x:"RLDICL","XOR",-"CMP",-"ISEL"
63 func TestSetEq64(x uint64, y uint64) bool {
64 // ppc64x/power10:"SETBC\tCR0EQ",-"ISEL"
65 // ppc64x/power9:"CMP","ISEL",-"SETBC\tCR0EQ"
66 // ppc64x/power8:"CMP","ISEL",-"SETBC\tCR0EQ"
70 func TestSetNeq64(x uint64, y uint64) bool {
71 // ppc64x/power10:"SETBCR\tCR0EQ",-"ISEL"
72 // ppc64x/power9:"CMP","ISEL",-"SETBCR\tCR0EQ"
73 // ppc64x/power8:"CMP","ISEL",-"SETBCR\tCR0EQ"
77 func TestSetLt64(x uint64, y uint64) bool {
78 // ppc64x/power10:"SETBC\tCR0GT",-"ISEL"
79 // ppc64x/power9:"CMP","ISEL",-"SETBC\tCR0GT"
80 // ppc64x/power8:"CMP","ISEL",-"SETBC\tCR0GT"
84 func TestSetLe64(x uint64, y uint64) bool {
85 // ppc64x/power10:"SETBCR\tCR0LT",-"ISEL"
86 // ppc64x/power9:"CMP","ISEL",-"SETBCR\tCR0LT"
87 // ppc64x/power8:"CMP","ISEL",-"SETBCR\tCR0LT"
91 func TestSetGt64(x uint64, y uint64) bool {
92 // ppc64x/power10:"SETBC\tCR0LT",-"ISEL"
93 // ppc64x/power9:"CMP","ISEL",-"SETBC\tCR0LT"
94 // ppc64x/power8:"CMP","ISEL",-"SETBC\tCR0LT"
98 func TestSetGe64(x uint64, y uint64) bool {
99 // ppc64x/power10:"SETBCR\tCR0GT",-"ISEL"
100 // ppc64x/power9:"CMP","ISEL",-"SETBCR\tCR0GT"
101 // ppc64x/power8:"CMP","ISEL",-"SETBCR\tCR0GT"
105 func TestSetLtFp64(x float64, y float64) bool {
106 // ppc64x/power10:"SETBC\tCR0LT",-"ISEL"
107 // ppc64x/power9:"FCMP","ISEL",-"SETBC\tCR0LT"
108 // ppc64x/power8:"FCMP","ISEL",-"SETBC\tCR0LT"
112 func TestSetLeFp64(x float64, y float64) bool {
113 // ppc64x/power10:"SETBC\tCR0LT","SETBC\tCR0EQ","OR",-"ISEL",-"ISEL"
114 // ppc64x/power9:"ISEL","ISEL",-"SETBC\tCR0LT",-"SETBC\tCR0EQ","OR"
115 // ppc64x/power8:"ISEL","ISEL",-"SETBC\tCR0LT",-"SETBC\tCR0EQ","OR"
119 func TestSetGtFp64(x float64, y float64) bool {
120 // ppc64x/power10:"SETBC\tCR0LT",-"ISEL"
121 // ppc64x/power9:"FCMP","ISEL",-"SETBC\tCR0LT"
122 // ppc64x/power8:"FCMP","ISEL",-"SETBC\tCR0LT"
126 func TestSetGeFp64(x float64, y float64) bool {
127 // ppc64x/power10:"SETBC\tCR0LT","SETBC\tCR0EQ","OR",-"ISEL",-"ISEL"
128 // ppc64x/power9:"ISEL","ISEL",-"SETBC\tCR0LT",-"SETBC\tCR0EQ","OR"
129 // ppc64x/power8:"ISEL","ISEL",-"SETBC\tCR0LT",-"SETBC\tCR0EQ","OR"
133 func TestSetInvEq64(x uint64, y uint64) bool {
134 // ppc64x/power10:"SETBCR\tCR0EQ",-"ISEL"
135 // ppc64x/power9:"CMP","ISEL",-"SETBCR\tCR0EQ"
136 // ppc64x/power8:"CMP","ISEL",-"SETBCR\tCR0EQ"
140 func TestSetInvNeq64(x uint64, y uint64) bool {
141 // ppc64x/power10:"SETBC\tCR0EQ",-"ISEL"
142 // ppc64x/power9:"CMP","ISEL",-"SETBC\tCR0EQ"
143 // ppc64x/power8:"CMP","ISEL",-"SETBC\tCR0EQ"
147 func TestSetInvLt64(x uint64, y uint64) bool {
148 // ppc64x/power10:"SETBCR\tCR0GT",-"ISEL"
149 // ppc64x/power9:"CMP","ISEL",-"SETBCR\tCR0GT"
150 // ppc64x/power8:"CMP","ISEL",-"SETBCR\tCR0GT"
154 func TestSetInvLe64(x uint64, y uint64) bool {
155 // ppc64x/power10:"SETBC\tCR0LT",-"ISEL"
156 // ppc64x/power9:"CMP","ISEL",-"SETBC\tCR0LT"
157 // ppc64x/power8:"CMP","ISEL",-"SETBC\tCR0LT"
161 func TestSetInvGt64(x uint64, y uint64) bool {
162 // ppc64x/power10:"SETBCR\tCR0LT",-"ISEL"
163 // ppc64x/power9:"CMP","ISEL",-"SETBCR\tCR0LT"
164 // ppc64x/power8:"CMP","ISEL",-"SETBCR\tCR0LT"
168 func TestSetInvGe64(x uint64, y uint64) bool {
169 // ppc64x/power10:"SETBC\tCR0GT",-"ISEL"
170 // ppc64x/power9:"CMP","ISEL",-"SETBC\tCR0GT"
171 // ppc64x/power8:"CMP","ISEL",-"SETBC\tCR0GT"
176 func TestSetInvEqFp64(x float64, y float64) bool {
177 // ppc64x/power10:"SETBCR\tCR0EQ",-"ISEL"
178 // ppc64x/power9:"FCMP","ISEL",-"SETBCR\tCR0EQ"
179 // ppc64x/power8:"FCMP","ISEL",-"SETBCR\tCR0EQ"
183 func TestSetInvNeqFp64(x float64, y float64) bool {
184 // ppc64x/power10:"SETBC\tCR0EQ",-"ISEL"
185 // ppc64x/power9:"FCMP","ISEL",-"SETBC\tCR0EQ"
186 // ppc64x/power8:"FCMP","ISEL",-"SETBC\tCR0EQ"
190 func TestSetInvLtFp64(x float64, y float64) bool {
191 // ppc64x/power10:"SETBCR\tCR0LT",-"ISEL"
192 // ppc64x/power9:"FCMP","ISEL",-"SETBCR\tCR0LT"
193 // ppc64x/power8:"FCMP","ISEL",-"SETBCR\tCR0LT"
197 func TestSetInvLeFp64(x float64, y float64) bool {
198 // ppc64x/power10:"SETBC\tCR0LT",-"ISEL"
199 // ppc64x/power9:"FCMP","ISEL",-"SETBC\tCR0LT"
200 // ppc64x/power8:"FCMP","ISEL",-"SETBC\tCR0LT"
204 func TestSetInvGtFp64(x float64, y float64) bool {
205 // ppc64x/power10:"SETBCR\tCR0LT",-"ISEL"
206 // ppc64x/power9:"FCMP","ISEL",-"SETBCR\tCR0LT"
207 // ppc64x/power8:"FCMP","ISEL",-"SETBCR\tCR0LT"
211 func TestSetInvGeFp64(x float64, y float64) bool {
212 // ppc64x/power10:"SETBC\tCR0LT",-"ISEL"
213 // ppc64x/power9:"FCMP","ISEL",-"SETBC\tCR0LT"
214 // ppc64x/power8:"FCMP","ISEL",-"SETBC\tCR0LT"
218 func TestLogicalCompareZero(x *[64]uint64) {
219 // ppc64x:"ANDCC",^"AND"
224 // ppc64x:"ANDCC",^"AND"
229 // ppc64x:"ANDNCC",^"ANDN"
234 // ppc64x:"ORCC",^"OR"
239 // ppc64x:"SUBCC",^"SUB"
244 // ppc64x:"NORCC",^"NOR"
249 // ppc64x:"XORCC",^"XOR"
254 // ppc64x:"ADDCC",^"ADD"
259 // ppc64x:"NEGCC",^"NEG"
264 // ppc64x:"CNTLZDCC",^"CNTLZD"
265 b = uint64(bits.LeadingZeros64(x[12]))
270 // ppc64x:"ADDCCC\t[$]4,"
271 c := int64(x[12]) + 4