1// asmcheck 2 3// Copyright 2019 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 7package codegen 8 9//go:noinline 10func dummy() {} 11 12// Signed 64-bit compare-and-branch. 13func si64(x, y chan int64) { 14 // s390x:"CGRJ\t[$](2|4), R[0-9]+, R[0-9]+, " 15 for <-x < <-y { 16 dummy() 17 } 18 19 // s390x:"CL?GRJ\t[$]8, R[0-9]+, R[0-9]+, " 20 for <-x == <-y { 21 dummy() 22 } 23} 24 25// Signed 64-bit compare-and-branch with 8-bit immediate. 26func si64x8(doNotOptimize int64) { 27 // take in doNotOptimize as an argument to avoid the loops being rewritten to count down 28 // s390x:"CGIJ\t[$]12, R[0-9]+, [$]127, " 29 for i := doNotOptimize; i < 128; i++ { 30 dummy() 31 } 32 33 // s390x:"CGIJ\t[$]10, R[0-9]+, [$]-128, " 34 for i := doNotOptimize; i > -129; i-- { 35 dummy() 36 } 37 38 // s390x:"CGIJ\t[$]2, R[0-9]+, [$]127, " 39 for i := doNotOptimize; i >= 128; i++ { 40 dummy() 41 } 42 43 // s390x:"CGIJ\t[$]4, R[0-9]+, [$]-128, " 44 for i := doNotOptimize; i <= -129; i-- { 45 dummy() 46 } 47} 48 49// Unsigned 64-bit compare-and-branch. 50func ui64(x, y chan uint64) { 51 // s390x:"CLGRJ\t[$](2|4), R[0-9]+, R[0-9]+, " 52 for <-x > <-y { 53 dummy() 54 } 55 56 // s390x:"CL?GRJ\t[$]6, R[0-9]+, R[0-9]+, " 57 for <-x != <-y { 58 dummy() 59 } 60} 61 62// Unsigned 64-bit comparison with 8-bit immediate. 63func ui64x8() { 64 // s390x:"CLGIJ\t[$]4, R[0-9]+, [$]128, " 65 for i := uint64(0); i < 128; i++ { 66 dummy() 67 } 68 69 // s390x:"CLGIJ\t[$]12, R[0-9]+, [$]255, " 70 for i := uint64(0); i < 256; i++ { 71 dummy() 72 } 73 74 // s390x:"CLGIJ\t[$]2, R[0-9]+, [$]255, " 75 for i := uint64(257); i >= 256; i-- { 76 dummy() 77 } 78 79 // s390x:"CLGIJ\t[$]2, R[0-9]+, [$]0, " 80 for i := uint64(1024); i > 0; i-- { 81 dummy() 82 } 83} 84 85// Signed 32-bit compare-and-branch. 86func si32(x, y chan int32) { 87 // s390x:"CRJ\t[$](2|4), R[0-9]+, R[0-9]+, " 88 for <-x < <-y { 89 dummy() 90 } 91 92 // s390x:"CL?RJ\t[$]8, R[0-9]+, R[0-9]+, " 93 for <-x == <-y { 94 dummy() 95 } 96} 97 98// Signed 32-bit compare-and-branch with 8-bit immediate. 99func si32x8(doNotOptimize int32) { 100 // take in doNotOptimize as an argument to avoid the loops being rewritten to count down 101 // s390x:"CIJ\t[$]12, R[0-9]+, [$]127, " 102 for i := doNotOptimize; i < 128; i++ { 103 dummy() 104 } 105 106 // s390x:"CIJ\t[$]10, R[0-9]+, [$]-128, " 107 for i := doNotOptimize; i > -129; i-- { 108 dummy() 109 } 110 111 // s390x:"CIJ\t[$]2, R[0-9]+, [$]127, " 112 for i := doNotOptimize; i >= 128; i++ { 113 dummy() 114 } 115 116 // s390x:"CIJ\t[$]4, R[0-9]+, [$]-128, " 117 for i := doNotOptimize; i <= -129; i-- { 118 dummy() 119 } 120} 121 122// Unsigned 32-bit compare-and-branch. 123func ui32(x, y chan uint32) { 124 // s390x:"CLRJ\t[$](2|4), R[0-9]+, R[0-9]+, " 125 for <-x > <-y { 126 dummy() 127 } 128 129 // s390x:"CL?RJ\t[$]6, R[0-9]+, R[0-9]+, " 130 for <-x != <-y { 131 dummy() 132 } 133} 134 135// Unsigned 32-bit comparison with 8-bit immediate. 136func ui32x8() { 137 // s390x:"CLIJ\t[$]4, R[0-9]+, [$]128, " 138 for i := uint32(0); i < 128; i++ { 139 dummy() 140 } 141 142 // s390x:"CLIJ\t[$]12, R[0-9]+, [$]255, " 143 for i := uint32(0); i < 256; i++ { 144 dummy() 145 } 146 147 // s390x:"CLIJ\t[$]2, R[0-9]+, [$]255, " 148 for i := uint32(257); i >= 256; i-- { 149 dummy() 150 } 151 152 // s390x:"CLIJ\t[$]2, R[0-9]+, [$]0, " 153 for i := uint32(1024); i > 0; i-- { 154 dummy() 155 } 156} 157 158// Signed 64-bit comparison with unsigned 8-bit immediate. 159func si64xu8(x chan int64) { 160 // s390x:"CLGIJ\t[$]8, R[0-9]+, [$]128, " 161 for <-x == 128 { 162 dummy() 163 } 164 165 // s390x:"CLGIJ\t[$]6, R[0-9]+, [$]255, " 166 for <-x != 255 { 167 dummy() 168 } 169} 170 171// Signed 32-bit comparison with unsigned 8-bit immediate. 172func si32xu8(x chan int32) { 173 // s390x:"CLIJ\t[$]8, R[0-9]+, [$]255, " 174 for <-x == 255 { 175 dummy() 176 } 177 178 // s390x:"CLIJ\t[$]6, R[0-9]+, [$]128, " 179 for <-x != 128 { 180 dummy() 181 } 182} 183 184// Unsigned 64-bit comparison with signed 8-bit immediate. 185func ui64xu8(x chan uint64) { 186 // s390x:"CGIJ\t[$]8, R[0-9]+, [$]-1, " 187 for <-x == ^uint64(0) { 188 dummy() 189 } 190 191 // s390x:"CGIJ\t[$]6, R[0-9]+, [$]-128, " 192 for <-x != ^uint64(127) { 193 dummy() 194 } 195} 196 197// Unsigned 32-bit comparison with signed 8-bit immediate. 198func ui32xu8(x chan uint32) { 199 // s390x:"CIJ\t[$]8, R[0-9]+, [$]-128, " 200 for <-x == ^uint32(127) { 201 dummy() 202 } 203 204 // s390x:"CIJ\t[$]6, R[0-9]+, [$]-1, " 205 for <-x != ^uint32(0) { 206 dummy() 207 } 208} 209 210// Signed 64-bit comparison with 1/-1 to comparison with 0. 211func si64x0(x chan int64) { 212 // riscv64:"BGTZ" 213 for <-x >= 1 { 214 dummy() 215 } 216 217 // riscv64:"BLEZ" 218 for <-x < 1 { 219 dummy() 220 } 221 222 // riscv64:"BLTZ" 223 for <-x <= -1 { 224 dummy() 225 } 226 227 // riscv64:"BGEZ" 228 for <-x > -1 { 229 dummy() 230 } 231} 232 233// Unsigned 64-bit comparison with 1 to comparison with 0. 234func ui64x0(x chan uint64) { 235 // riscv64:"BNEZ" 236 for <-x >= 1 { 237 dummy() 238 } 239 240 // riscv64:"BEQZ" 241 for <-x < 1 { 242 dummy() 243 } 244} 245