github.com/slayercat/go@v0.0.0-20170428012452-c51559813f61/src/cmd/compile/internal/ssa/gen/ARM.rules (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 (AddPtr x y) -> (ADD x y) 6 (Add32 x y) -> (ADD x y) 7 (Add16 x y) -> (ADD x y) 8 (Add8 x y) -> (ADD x y) 9 (Add32F x y) -> (ADDF x y) 10 (Add64F x y) -> (ADDD x y) 11 12 (Add32carry x y) -> (ADDS x y) 13 (Add32withcarry x y c) -> (ADC x y c) 14 15 (SubPtr x y) -> (SUB x y) 16 (Sub32 x y) -> (SUB x y) 17 (Sub16 x y) -> (SUB x y) 18 (Sub8 x y) -> (SUB x y) 19 (Sub32F x y) -> (SUBF x y) 20 (Sub64F x y) -> (SUBD x y) 21 22 (Sub32carry x y) -> (SUBS x y) 23 (Sub32withcarry x y c) -> (SBC x y c) 24 25 (Mul32 x y) -> (MUL x y) 26 (Mul16 x y) -> (MUL x y) 27 (Mul8 x y) -> (MUL x y) 28 (Mul32F x y) -> (MULF x y) 29 (Mul64F x y) -> (MULD x y) 30 31 (Hmul32 x y) -> (HMUL x y) 32 (Hmul32u x y) -> (HMULU x y) 33 34 (Mul32uhilo x y) -> (MULLU x y) 35 36 (Div32 x y) -> 37 (SUB (XOR <types.UInt32> // negate the result if one operand is negative 38 (Select0 <types.UInt32> (CALLudiv 39 (SUB <types.UInt32> (XOR x <types.UInt32> (Signmask x)) (Signmask x)) // negate x if negative 40 (SUB <types.UInt32> (XOR y <types.UInt32> (Signmask y)) (Signmask y)))) // negate y if negative 41 (Signmask (XOR <types.UInt32> x y))) (Signmask (XOR <types.UInt32> x y))) 42 (Div32u x y) -> (Select0 <types.UInt32> (CALLudiv x y)) 43 (Div16 x y) -> (Div32 (SignExt16to32 x) (SignExt16to32 y)) 44 (Div16u x y) -> (Div32u (ZeroExt16to32 x) (ZeroExt16to32 y)) 45 (Div8 x y) -> (Div32 (SignExt8to32 x) (SignExt8to32 y)) 46 (Div8u x y) -> (Div32u (ZeroExt8to32 x) (ZeroExt8to32 y)) 47 (Div32F x y) -> (DIVF x y) 48 (Div64F x y) -> (DIVD x y) 49 50 (Mod32 x y) -> 51 (SUB (XOR <types.UInt32> // negate the result if x is negative 52 (Select1 <types.UInt32> (CALLudiv 53 (SUB <types.UInt32> (XOR <types.UInt32> x (Signmask x)) (Signmask x)) // negate x if negative 54 (SUB <types.UInt32> (XOR <types.UInt32> y (Signmask y)) (Signmask y)))) // negate y if negative 55 (Signmask x)) (Signmask x)) 56 (Mod32u x y) -> (Select1 <types.UInt32> (CALLudiv x y)) 57 (Mod16 x y) -> (Mod32 (SignExt16to32 x) (SignExt16to32 y)) 58 (Mod16u x y) -> (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y)) 59 (Mod8 x y) -> (Mod32 (SignExt8to32 x) (SignExt8to32 y)) 60 (Mod8u x y) -> (Mod32u (ZeroExt8to32 x) (ZeroExt8to32 y)) 61 62 // (x + y) / 2 with x>=y -> (x - y) / 2 + y 63 (Avg32u <t> x y) -> (ADD (SRLconst <t> (SUB <t> x y) [1]) y) 64 65 (And32 x y) -> (AND x y) 66 (And16 x y) -> (AND x y) 67 (And8 x y) -> (AND x y) 68 69 (Or32 x y) -> (OR x y) 70 (Or16 x y) -> (OR x y) 71 (Or8 x y) -> (OR x y) 72 73 (Xor32 x y) -> (XOR x y) 74 (Xor16 x y) -> (XOR x y) 75 (Xor8 x y) -> (XOR x y) 76 77 // unary ops 78 (Neg32 x) -> (RSBconst [0] x) 79 (Neg16 x) -> (RSBconst [0] x) 80 (Neg8 x) -> (RSBconst [0] x) 81 (Neg32F x) -> (NEGF x) 82 (Neg64F x) -> (NEGD x) 83 84 (Com32 x) -> (MVN x) 85 (Com16 x) -> (MVN x) 86 (Com8 x) -> (MVN x) 87 88 (Sqrt x) -> (SQRTD x) 89 90 // count trailing zero for ARMv5 and ARMv6 91 // 32 - CLZ(x&-x - 1) 92 (Ctz32 <t> x) && objabi.GOARM<=6 -> (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1]))) 93 94 // count trailing zero for ARMv7 95 (Ctz32 <t> x) && objabi.GOARM==7 -> (CLZ <t> (RBIT <t> x)) 96 97 // bit length 98 (BitLen32 <t> x) -> (RSBconst [32] (CLZ <t> x)) 99 100 // byte swap for ARMv5 101 // let (a, b, c, d) be the bytes of x from high to low 102 // t1 = x right rotate 16 bits -- (c, d, a, b ) 103 // t2 = x ^ t1 -- (a^c, b^d, a^c, b^d) 104 // t3 = t2 &^ 0xff0000 -- (a^c, 0, a^c, b^d) 105 // t4 = t3 >> 8 -- (0, a^c, 0, a^c) 106 // t5 = x right rotate 8 bits -- (d, a, b, c ) 107 // result = t4 ^ t5 -- (d, c, b, a ) 108 // using shifted ops this can be done in 4 instructions. 109 (Bswap32 <t> x) && objabi.GOARM==5 -> 110 (XOR <t> 111 (SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8]) 112 (SRRconst <t> x [8])) 113 114 // byte swap for ARMv6 and above 115 (Bswap32 x) && objabi.GOARM>=6 -> (REV x) 116 117 // boolean ops -- booleans are represented with 0=false, 1=true 118 (AndB x y) -> (AND x y) 119 (OrB x y) -> (OR x y) 120 (EqB x y) -> (XORconst [1] (XOR <types.Bool> x y)) 121 (NeqB x y) -> (XOR x y) 122 (Not x) -> (XORconst [1] x) 123 124 // shifts 125 // hardware instruction uses only the low byte of the shift 126 // we compare to 256 to ensure Go semantics for large shifts 127 (Lsh32x32 x y) -> (CMOVWHSconst (SLL <x.Type> x y) (CMPconst [256] y) [0]) 128 (Lsh32x16 x y) -> (CMOVWHSconst (SLL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) 129 (Lsh32x8 x y) -> (SLL x (ZeroExt8to32 y)) 130 131 (Lsh16x32 x y) -> (CMOVWHSconst (SLL <x.Type> x y) (CMPconst [256] y) [0]) 132 (Lsh16x16 x y) -> (CMOVWHSconst (SLL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) 133 (Lsh16x8 x y) -> (SLL x (ZeroExt8to32 y)) 134 135 (Lsh8x32 x y) -> (CMOVWHSconst (SLL <x.Type> x y) (CMPconst [256] y) [0]) 136 (Lsh8x16 x y) -> (CMOVWHSconst (SLL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) 137 (Lsh8x8 x y) -> (SLL x (ZeroExt8to32 y)) 138 139 (Rsh32Ux32 x y) -> (CMOVWHSconst (SRL <x.Type> x y) (CMPconst [256] y) [0]) 140 (Rsh32Ux16 x y) -> (CMOVWHSconst (SRL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) 141 (Rsh32Ux8 x y) -> (SRL x (ZeroExt8to32 y)) 142 143 (Rsh16Ux32 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt16to32 x) y) (CMPconst [256] y) [0]) 144 (Rsh16Ux16 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt16to32 x) (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) 145 (Rsh16Ux8 x y) -> (SRL (ZeroExt16to32 x) (ZeroExt8to32 y)) 146 147 (Rsh8Ux32 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt8to32 x) y) (CMPconst [256] y) [0]) 148 (Rsh8Ux16 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt8to32 x) (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0]) 149 (Rsh8Ux8 x y) -> (SRL (ZeroExt8to32 x) (ZeroExt8to32 y)) 150 151 (Rsh32x32 x y) -> (SRAcond x y (CMPconst [256] y)) 152 (Rsh32x16 x y) -> (SRAcond x (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y))) 153 (Rsh32x8 x y) -> (SRA x (ZeroExt8to32 y)) 154 155 (Rsh16x32 x y) -> (SRAcond (SignExt16to32 x) y (CMPconst [256] y)) 156 (Rsh16x16 x y) -> (SRAcond (SignExt16to32 x) (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y))) 157 (Rsh16x8 x y) -> (SRA (SignExt16to32 x) (ZeroExt8to32 y)) 158 159 (Rsh8x32 x y) -> (SRAcond (SignExt8to32 x) y (CMPconst [256] y)) 160 (Rsh8x16 x y) -> (SRAcond (SignExt8to32 x) (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y))) 161 (Rsh8x8 x y) -> (SRA (SignExt8to32 x) (ZeroExt8to32 y)) 162 163 // constant shifts 164 // generic opt rewrites all constant shifts to shift by Const64 165 (Lsh32x64 x (Const64 [c])) && uint64(c) < 32 -> (SLLconst x [c]) 166 (Rsh32x64 x (Const64 [c])) && uint64(c) < 32 -> (SRAconst x [c]) 167 (Rsh32Ux64 x (Const64 [c])) && uint64(c) < 32 -> (SRLconst x [c]) 168 (Lsh16x64 x (Const64 [c])) && uint64(c) < 16 -> (SLLconst x [c]) 169 (Rsh16x64 x (Const64 [c])) && uint64(c) < 16 -> (SRAconst (SLLconst <types.UInt32> x [16]) [c+16]) 170 (Rsh16Ux64 x (Const64 [c])) && uint64(c) < 16 -> (SRLconst (SLLconst <types.UInt32> x [16]) [c+16]) 171 (Lsh8x64 x (Const64 [c])) && uint64(c) < 8 -> (SLLconst x [c]) 172 (Rsh8x64 x (Const64 [c])) && uint64(c) < 8 -> (SRAconst (SLLconst <types.UInt32> x [24]) [c+24]) 173 (Rsh8Ux64 x (Const64 [c])) && uint64(c) < 8 -> (SRLconst (SLLconst <types.UInt32> x [24]) [c+24]) 174 175 // large constant shifts 176 (Lsh32x64 _ (Const64 [c])) && uint64(c) >= 32 -> (Const32 [0]) 177 (Rsh32Ux64 _ (Const64 [c])) && uint64(c) >= 32 -> (Const32 [0]) 178 (Lsh16x64 _ (Const64 [c])) && uint64(c) >= 16 -> (Const16 [0]) 179 (Rsh16Ux64 _ (Const64 [c])) && uint64(c) >= 16 -> (Const16 [0]) 180 (Lsh8x64 _ (Const64 [c])) && uint64(c) >= 8 -> (Const8 [0]) 181 (Rsh8Ux64 _ (Const64 [c])) && uint64(c) >= 8 -> (Const8 [0]) 182 183 // large constant signed right shift, we leave the sign bit 184 (Rsh32x64 x (Const64 [c])) && uint64(c) >= 32 -> (SRAconst x [31]) 185 (Rsh16x64 x (Const64 [c])) && uint64(c) >= 16 -> (SRAconst (SLLconst <types.UInt32> x [16]) [31]) 186 (Rsh8x64 x (Const64 [c])) && uint64(c) >= 8 -> (SRAconst (SLLconst <types.UInt32> x [24]) [31]) 187 188 // constants 189 (Const8 [val]) -> (MOVWconst [val]) 190 (Const16 [val]) -> (MOVWconst [val]) 191 (Const32 [val]) -> (MOVWconst [val]) 192 (Const32F [val]) -> (MOVFconst [val]) 193 (Const64F [val]) -> (MOVDconst [val]) 194 (ConstNil) -> (MOVWconst [0]) 195 (ConstBool [b]) -> (MOVWconst [b]) 196 197 // truncations 198 // Because we ignore high parts of registers, truncates are just copies. 199 (Trunc16to8 x) -> x 200 (Trunc32to8 x) -> x 201 (Trunc32to16 x) -> x 202 203 // Zero-/Sign-extensions 204 (ZeroExt8to16 x) -> (MOVBUreg x) 205 (ZeroExt8to32 x) -> (MOVBUreg x) 206 (ZeroExt16to32 x) -> (MOVHUreg x) 207 208 (SignExt8to16 x) -> (MOVBreg x) 209 (SignExt8to32 x) -> (MOVBreg x) 210 (SignExt16to32 x) -> (MOVHreg x) 211 212 (Signmask x) -> (SRAconst x [31]) 213 (Zeromask x) -> (SRAconst (RSBshiftRL <types.Int32> x x [1]) [31]) // sign bit of uint32(x)>>1 - x 214 (Slicemask <t> x) -> (SRAconst (RSBconst <t> [0] x) [31]) 215 216 // float <-> int conversion 217 (Cvt32to32F x) -> (MOVWF x) 218 (Cvt32to64F x) -> (MOVWD x) 219 (Cvt32Uto32F x) -> (MOVWUF x) 220 (Cvt32Uto64F x) -> (MOVWUD x) 221 (Cvt32Fto32 x) -> (MOVFW x) 222 (Cvt64Fto32 x) -> (MOVDW x) 223 (Cvt32Fto32U x) -> (MOVFWU x) 224 (Cvt64Fto32U x) -> (MOVDWU x) 225 (Cvt32Fto64F x) -> (MOVFD x) 226 (Cvt64Fto32F x) -> (MOVDF x) 227 228 (Round32F x) -> x 229 (Round64F x) -> x 230 231 // comparisons 232 (Eq8 x y) -> (Equal (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) 233 (Eq16 x y) -> (Equal (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) 234 (Eq32 x y) -> (Equal (CMP x y)) 235 (EqPtr x y) -> (Equal (CMP x y)) 236 (Eq32F x y) -> (Equal (CMPF x y)) 237 (Eq64F x y) -> (Equal (CMPD x y)) 238 239 (Neq8 x y) -> (NotEqual (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) 240 (Neq16 x y) -> (NotEqual (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) 241 (Neq32 x y) -> (NotEqual (CMP x y)) 242 (NeqPtr x y) -> (NotEqual (CMP x y)) 243 (Neq32F x y) -> (NotEqual (CMPF x y)) 244 (Neq64F x y) -> (NotEqual (CMPD x y)) 245 246 (Less8 x y) -> (LessThan (CMP (SignExt8to32 x) (SignExt8to32 y))) 247 (Less16 x y) -> (LessThan (CMP (SignExt16to32 x) (SignExt16to32 y))) 248 (Less32 x y) -> (LessThan (CMP x y)) 249 (Less32F x y) -> (GreaterThan (CMPF y x)) // reverse operands to work around NaN 250 (Less64F x y) -> (GreaterThan (CMPD y x)) // reverse operands to work around NaN 251 252 (Less8U x y) -> (LessThanU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) 253 (Less16U x y) -> (LessThanU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) 254 (Less32U x y) -> (LessThanU (CMP x y)) 255 256 (Leq8 x y) -> (LessEqual (CMP (SignExt8to32 x) (SignExt8to32 y))) 257 (Leq16 x y) -> (LessEqual (CMP (SignExt16to32 x) (SignExt16to32 y))) 258 (Leq32 x y) -> (LessEqual (CMP x y)) 259 (Leq32F x y) -> (GreaterEqual (CMPF y x)) // reverse operands to work around NaN 260 (Leq64F x y) -> (GreaterEqual (CMPD y x)) // reverse operands to work around NaN 261 262 (Leq8U x y) -> (LessEqualU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) 263 (Leq16U x y) -> (LessEqualU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) 264 (Leq32U x y) -> (LessEqualU (CMP x y)) 265 266 (Greater8 x y) -> (GreaterThan (CMP (SignExt8to32 x) (SignExt8to32 y))) 267 (Greater16 x y) -> (GreaterThan (CMP (SignExt16to32 x) (SignExt16to32 y))) 268 (Greater32 x y) -> (GreaterThan (CMP x y)) 269 (Greater32F x y) -> (GreaterThan (CMPF x y)) 270 (Greater64F x y) -> (GreaterThan (CMPD x y)) 271 272 (Greater8U x y) -> (GreaterThanU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) 273 (Greater16U x y) -> (GreaterThanU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) 274 (Greater32U x y) -> (GreaterThanU (CMP x y)) 275 276 (Geq8 x y) -> (GreaterEqual (CMP (SignExt8to32 x) (SignExt8to32 y))) 277 (Geq16 x y) -> (GreaterEqual (CMP (SignExt16to32 x) (SignExt16to32 y))) 278 (Geq32 x y) -> (GreaterEqual (CMP x y)) 279 (Geq32F x y) -> (GreaterEqual (CMPF x y)) 280 (Geq64F x y) -> (GreaterEqual (CMPD x y)) 281 282 (Geq8U x y) -> (GreaterEqualU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y))) 283 (Geq16U x y) -> (GreaterEqualU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y))) 284 (Geq32U x y) -> (GreaterEqualU (CMP x y)) 285 286 (OffPtr [off] ptr:(SP)) -> (MOVWaddr [off] ptr) 287 (OffPtr [off] ptr) -> (ADDconst [off] ptr) 288 289 (Addr {sym} base) -> (MOVWaddr {sym} base) 290 291 // loads 292 (Load <t> ptr mem) && t.IsBoolean() -> (MOVBUload ptr mem) 293 (Load <t> ptr mem) && (is8BitInt(t) && isSigned(t)) -> (MOVBload ptr mem) 294 (Load <t> ptr mem) && (is8BitInt(t) && !isSigned(t)) -> (MOVBUload ptr mem) 295 (Load <t> ptr mem) && (is16BitInt(t) && isSigned(t)) -> (MOVHload ptr mem) 296 (Load <t> ptr mem) && (is16BitInt(t) && !isSigned(t)) -> (MOVHUload ptr mem) 297 (Load <t> ptr mem) && (is32BitInt(t) || isPtr(t)) -> (MOVWload ptr mem) 298 (Load <t> ptr mem) && is32BitFloat(t) -> (MOVFload ptr mem) 299 (Load <t> ptr mem) && is64BitFloat(t) -> (MOVDload ptr mem) 300 301 // stores 302 (Store {t} ptr val mem) && t.(Type).Size() == 1 -> (MOVBstore ptr val mem) 303 (Store {t} ptr val mem) && t.(Type).Size() == 2 -> (MOVHstore ptr val mem) 304 (Store {t} ptr val mem) && t.(Type).Size() == 4 && !is32BitFloat(val.Type) -> (MOVWstore ptr val mem) 305 (Store {t} ptr val mem) && t.(Type).Size() == 4 && is32BitFloat(val.Type) -> (MOVFstore ptr val mem) 306 (Store {t} ptr val mem) && t.(Type).Size() == 8 && is64BitFloat(val.Type) -> (MOVDstore ptr val mem) 307 308 // zero instructions 309 (Zero [0] _ mem) -> mem 310 (Zero [1] ptr mem) -> (MOVBstore ptr (MOVWconst [0]) mem) 311 (Zero [2] {t} ptr mem) && t.(Type).Alignment()%2 == 0 -> 312 (MOVHstore ptr (MOVWconst [0]) mem) 313 (Zero [2] ptr mem) -> 314 (MOVBstore [1] ptr (MOVWconst [0]) 315 (MOVBstore [0] ptr (MOVWconst [0]) mem)) 316 (Zero [4] {t} ptr mem) && t.(Type).Alignment()%4 == 0 -> 317 (MOVWstore ptr (MOVWconst [0]) mem) 318 (Zero [4] {t} ptr mem) && t.(Type).Alignment()%2 == 0 -> 319 (MOVHstore [2] ptr (MOVWconst [0]) 320 (MOVHstore [0] ptr (MOVWconst [0]) mem)) 321 (Zero [4] ptr mem) -> 322 (MOVBstore [3] ptr (MOVWconst [0]) 323 (MOVBstore [2] ptr (MOVWconst [0]) 324 (MOVBstore [1] ptr (MOVWconst [0]) 325 (MOVBstore [0] ptr (MOVWconst [0]) mem)))) 326 327 (Zero [3] ptr mem) -> 328 (MOVBstore [2] ptr (MOVWconst [0]) 329 (MOVBstore [1] ptr (MOVWconst [0]) 330 (MOVBstore [0] ptr (MOVWconst [0]) mem))) 331 332 // Medium zeroing uses a duff device 333 // 4 and 128 are magic constants, see runtime/mkduff.go 334 (Zero [s] {t} ptr mem) 335 && s%4 == 0 && s > 4 && s <= 512 336 && t.(Type).Alignment()%4 == 0 && !config.noDuffDevice -> 337 (DUFFZERO [4 * (128 - int64(s/4))] ptr (MOVWconst [0]) mem) 338 339 // Large zeroing uses a loop 340 (Zero [s] {t} ptr mem) 341 && (s > 512 || config.noDuffDevice) || t.(Type).Alignment()%4 != 0 -> 342 (LoweredZero [t.(Type).Alignment()] 343 ptr 344 (ADDconst <ptr.Type> ptr [s-moveSize(t.(Type).Alignment(), config)]) 345 (MOVWconst [0]) 346 mem) 347 348 // moves 349 (Move [0] _ _ mem) -> mem 350 (Move [1] dst src mem) -> (MOVBstore dst (MOVBUload src mem) mem) 351 (Move [2] {t} dst src mem) && t.(Type).Alignment()%2 == 0 -> 352 (MOVHstore dst (MOVHUload src mem) mem) 353 (Move [2] dst src mem) -> 354 (MOVBstore [1] dst (MOVBUload [1] src mem) 355 (MOVBstore dst (MOVBUload src mem) mem)) 356 (Move [4] {t} dst src mem) && t.(Type).Alignment()%4 == 0 -> 357 (MOVWstore dst (MOVWload src mem) mem) 358 (Move [4] {t} dst src mem) && t.(Type).Alignment()%2 == 0 -> 359 (MOVHstore [2] dst (MOVHUload [2] src mem) 360 (MOVHstore dst (MOVHUload src mem) mem)) 361 (Move [4] dst src mem) -> 362 (MOVBstore [3] dst (MOVBUload [3] src mem) 363 (MOVBstore [2] dst (MOVBUload [2] src mem) 364 (MOVBstore [1] dst (MOVBUload [1] src mem) 365 (MOVBstore dst (MOVBUload src mem) mem)))) 366 367 (Move [3] dst src mem) -> 368 (MOVBstore [2] dst (MOVBUload [2] src mem) 369 (MOVBstore [1] dst (MOVBUload [1] src mem) 370 (MOVBstore dst (MOVBUload src mem) mem))) 371 372 // Medium move uses a duff device 373 // 8 and 128 are magic constants, see runtime/mkduff.go 374 (Move [s] {t} dst src mem) 375 && s%4 == 0 && s > 4 && s <= 512 376 && t.(Type).Alignment()%4 == 0 && !config.noDuffDevice -> 377 (DUFFCOPY [8 * (128 - int64(s/4))] dst src mem) 378 379 // Large move uses a loop 380 (Move [s] {t} dst src mem) 381 && (s > 512 || config.noDuffDevice) || t.(Type).Alignment()%4 != 0 -> 382 (LoweredMove [t.(Type).Alignment()] 383 dst 384 src 385 (ADDconst <src.Type> src [s-moveSize(t.(Type).Alignment(), config)]) 386 mem) 387 388 // calls 389 (StaticCall [argwid] {target} mem) -> (CALLstatic [argwid] {target} mem) 390 (ClosureCall [argwid] entry closure mem) -> (CALLclosure [argwid] entry closure mem) 391 (InterCall [argwid] entry mem) -> (CALLinter [argwid] entry mem) 392 393 // checks 394 (NilCheck ptr mem) -> (LoweredNilCheck ptr mem) 395 (IsNonNil ptr) -> (NotEqual (CMPconst [0] ptr)) 396 (IsInBounds idx len) -> (LessThanU (CMP idx len)) 397 (IsSliceInBounds idx len) -> (LessEqualU (CMP idx len)) 398 399 // pseudo-ops 400 (GetClosurePtr) -> (LoweredGetClosurePtr) 401 (Convert x mem) -> (MOVWconvert x mem) 402 403 // Absorb pseudo-ops into blocks. 404 (If (Equal cc) yes no) -> (EQ cc yes no) 405 (If (NotEqual cc) yes no) -> (NE cc yes no) 406 (If (LessThan cc) yes no) -> (LT cc yes no) 407 (If (LessThanU cc) yes no) -> (ULT cc yes no) 408 (If (LessEqual cc) yes no) -> (LE cc yes no) 409 (If (LessEqualU cc) yes no) -> (ULE cc yes no) 410 (If (GreaterThan cc) yes no) -> (GT cc yes no) 411 (If (GreaterThanU cc) yes no) -> (UGT cc yes no) 412 (If (GreaterEqual cc) yes no) -> (GE cc yes no) 413 (If (GreaterEqualU cc) yes no) -> (UGE cc yes no) 414 415 (If cond yes no) -> (NE (CMPconst [0] cond) yes no) 416 417 // Absorb boolean tests into block 418 (NE (CMPconst [0] (Equal cc)) yes no) -> (EQ cc yes no) 419 (NE (CMPconst [0] (NotEqual cc)) yes no) -> (NE cc yes no) 420 (NE (CMPconst [0] (LessThan cc)) yes no) -> (LT cc yes no) 421 (NE (CMPconst [0] (LessThanU cc)) yes no) -> (ULT cc yes no) 422 (NE (CMPconst [0] (LessEqual cc)) yes no) -> (LE cc yes no) 423 (NE (CMPconst [0] (LessEqualU cc)) yes no) -> (ULE cc yes no) 424 (NE (CMPconst [0] (GreaterThan cc)) yes no) -> (GT cc yes no) 425 (NE (CMPconst [0] (GreaterThanU cc)) yes no) -> (UGT cc yes no) 426 (NE (CMPconst [0] (GreaterEqual cc)) yes no) -> (GE cc yes no) 427 (NE (CMPconst [0] (GreaterEqualU cc)) yes no) -> (UGE cc yes no) 428 429 // Optimizations 430 431 // fold offset into address 432 (ADDconst [off1] (MOVWaddr [off2] {sym} ptr)) -> (MOVWaddr [off1+off2] {sym} ptr) 433 434 // fold address into load/store 435 (MOVBload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVBload [off1+off2] {sym} ptr mem) 436 (MOVBUload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVBUload [off1+off2] {sym} ptr mem) 437 (MOVHload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVHload [off1+off2] {sym} ptr mem) 438 (MOVHUload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVHUload [off1+off2] {sym} ptr mem) 439 (MOVWload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVWload [off1+off2] {sym} ptr mem) 440 (MOVFload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVFload [off1+off2] {sym} ptr mem) 441 (MOVDload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVDload [off1+off2] {sym} ptr mem) 442 443 (MOVBstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVBstore [off1+off2] {sym} ptr val mem) 444 (MOVHstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVHstore [off1+off2] {sym} ptr val mem) 445 (MOVWstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVWstore [off1+off2] {sym} ptr val mem) 446 (MOVFstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVFstore [off1+off2] {sym} ptr val mem) 447 (MOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVDstore [off1+off2] {sym} ptr val mem) 448 449 (MOVBload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) -> 450 (MOVBload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 451 (MOVBUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) -> 452 (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 453 (MOVHload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) -> 454 (MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 455 (MOVHUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) -> 456 (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 457 (MOVWload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) -> 458 (MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 459 (MOVFload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) -> 460 (MOVFload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 461 (MOVDload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) -> 462 (MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 463 464 (MOVBstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) -> 465 (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 466 (MOVHstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) -> 467 (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 468 (MOVWstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) -> 469 (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 470 (MOVFstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) -> 471 (MOVFstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 472 (MOVDstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) -> 473 (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 474 475 // replace load from same location as preceding store with copy 476 (MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) && isSigned(x.Type) -> x 477 (MOVBUload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) && !isSigned(x.Type) -> x 478 (MOVHload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) && isSigned(x.Type) -> x 479 (MOVHUload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) && !isSigned(x.Type) -> x 480 (MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x 481 (MOVFload [off] {sym} ptr (MOVFstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x 482 (MOVDload [off] {sym} ptr (MOVDstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x 483 484 (MOVWloadidx ptr idx (MOVWstoreidx ptr2 idx x _)) && isSamePtr(ptr, ptr2) -> x 485 (MOVWloadshiftLL ptr idx [c] (MOVWstoreshiftLL ptr2 idx [d] x _)) && c==d && isSamePtr(ptr, ptr2) -> x 486 (MOVWloadshiftRL ptr idx [c] (MOVWstoreshiftRL ptr2 idx [d] x _)) && c==d && isSamePtr(ptr, ptr2) -> x 487 (MOVWloadshiftRA ptr idx [c] (MOVWstoreshiftRA ptr2 idx [d] x _)) && c==d && isSamePtr(ptr, ptr2) -> x 488 489 // fold constant into arithmatic ops 490 (ADD x (MOVWconst [c])) -> (ADDconst [c] x) 491 (SUB (MOVWconst [c]) x) -> (RSBconst [c] x) 492 (SUB x (MOVWconst [c])) -> (SUBconst [c] x) 493 (RSB (MOVWconst [c]) x) -> (SUBconst [c] x) 494 (RSB x (MOVWconst [c])) -> (RSBconst [c] x) 495 496 (ADDS x (MOVWconst [c])) -> (ADDSconst [c] x) 497 (SUBS x (MOVWconst [c])) -> (SUBSconst [c] x) 498 499 (ADC (MOVWconst [c]) x flags) -> (ADCconst [c] x flags) 500 (ADC x (MOVWconst [c]) flags) -> (ADCconst [c] x flags) 501 (SBC (MOVWconst [c]) x flags) -> (RSCconst [c] x flags) 502 (SBC x (MOVWconst [c]) flags) -> (SBCconst [c] x flags) 503 504 (AND x (MOVWconst [c])) -> (ANDconst [c] x) 505 (OR x (MOVWconst [c])) -> (ORconst [c] x) 506 (XOR x (MOVWconst [c])) -> (XORconst [c] x) 507 (BIC x (MOVWconst [c])) -> (BICconst [c] x) 508 509 (SLL x (MOVWconst [c])) -> (SLLconst x [c&31]) // Note: I don't think we ever generate bad constant shifts (i.e. c>=32) 510 (SRL x (MOVWconst [c])) -> (SRLconst x [c&31]) 511 (SRA x (MOVWconst [c])) -> (SRAconst x [c&31]) 512 513 (CMP x (MOVWconst [c])) -> (CMPconst [c] x) 514 (CMP (MOVWconst [c]) x) -> (InvertFlags (CMPconst [c] x)) 515 516 // don't extend after proper load 517 // MOVWreg instruction is not emitted if src and dst registers are same, but it ensures the type. 518 (MOVBreg x:(MOVBload _ _)) -> (MOVWreg x) 519 (MOVBUreg x:(MOVBUload _ _)) -> (MOVWreg x) 520 (MOVHreg x:(MOVBload _ _)) -> (MOVWreg x) 521 (MOVHreg x:(MOVBUload _ _)) -> (MOVWreg x) 522 (MOVHreg x:(MOVHload _ _)) -> (MOVWreg x) 523 (MOVHUreg x:(MOVBUload _ _)) -> (MOVWreg x) 524 (MOVHUreg x:(MOVHUload _ _)) -> (MOVWreg x) 525 526 // fold extensions and ANDs together 527 (MOVBUreg (ANDconst [c] x)) -> (ANDconst [c&0xff] x) 528 (MOVHUreg (ANDconst [c] x)) -> (ANDconst [c&0xffff] x) 529 (MOVBreg (ANDconst [c] x)) && c & 0x80 == 0 -> (ANDconst [c&0x7f] x) 530 (MOVHreg (ANDconst [c] x)) && c & 0x8000 == 0 -> (ANDconst [c&0x7fff] x) 531 532 // fold double extensions 533 (MOVBreg x:(MOVBreg _)) -> (MOVWreg x) 534 (MOVBUreg x:(MOVBUreg _)) -> (MOVWreg x) 535 (MOVHreg x:(MOVBreg _)) -> (MOVWreg x) 536 (MOVHreg x:(MOVBUreg _)) -> (MOVWreg x) 537 (MOVHreg x:(MOVHreg _)) -> (MOVWreg x) 538 (MOVHUreg x:(MOVBUreg _)) -> (MOVWreg x) 539 (MOVHUreg x:(MOVHUreg _)) -> (MOVWreg x) 540 541 // don't extend before store 542 (MOVBstore [off] {sym} ptr (MOVBreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 543 (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 544 (MOVBstore [off] {sym} ptr (MOVHreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 545 (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 546 (MOVHstore [off] {sym} ptr (MOVHreg x) mem) -> (MOVHstore [off] {sym} ptr x mem) 547 (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) -> (MOVHstore [off] {sym} ptr x mem) 548 549 // if a register move has only 1 use, just use the same register without emitting instruction 550 // MOVWnop doesn't emit instruction, only for ensuring the type. 551 (MOVWreg x) && x.Uses == 1 -> (MOVWnop x) 552 553 // mul by constant 554 (MUL x (MOVWconst [c])) && int32(c) == -1 -> (RSBconst [0] x) 555 (MUL _ (MOVWconst [0])) -> (MOVWconst [0]) 556 (MUL x (MOVWconst [1])) -> x 557 (MUL x (MOVWconst [c])) && isPowerOfTwo(c) -> (SLLconst [log2(c)] x) 558 (MUL x (MOVWconst [c])) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (ADDshiftLL x x [log2(c-1)]) 559 (MUL x (MOVWconst [c])) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (RSBshiftLL x x [log2(c+1)]) 560 (MUL x (MOVWconst [c])) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (SLLconst [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) 561 (MUL x (MOVWconst [c])) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (SLLconst [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) 562 (MUL x (MOVWconst [c])) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (SLLconst [log2(c/7)] (RSBshiftLL <x.Type> x x [3])) 563 (MUL x (MOVWconst [c])) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (SLLconst [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) 564 565 (MULA x (MOVWconst [c]) a) && int32(c) == -1 -> (SUB a x) 566 (MULA _ (MOVWconst [0]) a) -> a 567 (MULA x (MOVWconst [1]) a) -> (ADD x a) 568 (MULA x (MOVWconst [c]) a) && isPowerOfTwo(c) -> (ADD (SLLconst <x.Type> [log2(c)] x) a) 569 (MULA x (MOVWconst [c]) a) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (ADD (ADDshiftLL <x.Type> x x [log2(c-1)]) a) 570 (MULA x (MOVWconst [c]) a) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (ADD (RSBshiftLL <x.Type> x x [log2(c+1)]) a) 571 (MULA x (MOVWconst [c]) a) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) a) 572 (MULA x (MOVWconst [c]) a) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) a) 573 (MULA x (MOVWconst [c]) a) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/7)] (RSBshiftLL <x.Type> x x [3])) a) 574 (MULA x (MOVWconst [c]) a) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) a) 575 576 (MULA (MOVWconst [c]) x a) && int32(c) == -1 -> (SUB a x) 577 (MULA (MOVWconst [0]) _ a) -> a 578 (MULA (MOVWconst [1]) x a) -> (ADD x a) 579 (MULA (MOVWconst [c]) x a) && isPowerOfTwo(c) -> (ADD (SLLconst <x.Type> [log2(c)] x) a) 580 (MULA (MOVWconst [c]) x a) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (ADD (ADDshiftLL <x.Type> x x [log2(c-1)]) a) 581 (MULA (MOVWconst [c]) x a) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (ADD (RSBshiftLL <x.Type> x x [log2(c+1)]) a) 582 (MULA (MOVWconst [c]) x a) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) a) 583 (MULA (MOVWconst [c]) x a) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) a) 584 (MULA (MOVWconst [c]) x a) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/7)] (RSBshiftLL <x.Type> x x [3])) a) 585 (MULA (MOVWconst [c]) x a) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) a) 586 587 // div by constant 588 (Select0 (CALLudiv x (MOVWconst [1]))) -> x 589 (Select1 (CALLudiv _ (MOVWconst [1]))) -> (MOVWconst [0]) 590 (Select0 (CALLudiv x (MOVWconst [c]))) && isPowerOfTwo(c) -> (SRLconst [log2(c)] x) 591 (Select1 (CALLudiv x (MOVWconst [c]))) && isPowerOfTwo(c) -> (ANDconst [c-1] x) 592 593 // constant comparisons 594 (CMPconst (MOVWconst [x]) [y]) && int32(x)==int32(y) -> (FlagEQ) 595 (CMPconst (MOVWconst [x]) [y]) && int32(x)<int32(y) && uint32(x)<uint32(y) -> (FlagLT_ULT) 596 (CMPconst (MOVWconst [x]) [y]) && int32(x)<int32(y) && uint32(x)>uint32(y) -> (FlagLT_UGT) 597 (CMPconst (MOVWconst [x]) [y]) && int32(x)>int32(y) && uint32(x)<uint32(y) -> (FlagGT_ULT) 598 (CMPconst (MOVWconst [x]) [y]) && int32(x)>int32(y) && uint32(x)>uint32(y) -> (FlagGT_UGT) 599 600 // other known comparisons 601 (CMPconst (MOVBUreg _) [c]) && 0xff < c -> (FlagLT_ULT) 602 (CMPconst (MOVHUreg _) [c]) && 0xffff < c -> (FlagLT_ULT) 603 (CMPconst (ANDconst _ [m]) [n]) && 0 <= int32(m) && int32(m) < int32(n) -> (FlagLT_ULT) 604 (CMPconst (SRLconst _ [c]) [n]) && 0 <= n && 0 < c && c <= 32 && (1<<uint32(32-c)) <= uint32(n) -> (FlagLT_ULT) 605 606 // absorb flag constants into branches 607 (EQ (FlagEQ) yes no) -> (First nil yes no) 608 (EQ (FlagLT_ULT) yes no) -> (First nil no yes) 609 (EQ (FlagLT_UGT) yes no) -> (First nil no yes) 610 (EQ (FlagGT_ULT) yes no) -> (First nil no yes) 611 (EQ (FlagGT_UGT) yes no) -> (First nil no yes) 612 613 (NE (FlagEQ) yes no) -> (First nil no yes) 614 (NE (FlagLT_ULT) yes no) -> (First nil yes no) 615 (NE (FlagLT_UGT) yes no) -> (First nil yes no) 616 (NE (FlagGT_ULT) yes no) -> (First nil yes no) 617 (NE (FlagGT_UGT) yes no) -> (First nil yes no) 618 619 (LT (FlagEQ) yes no) -> (First nil no yes) 620 (LT (FlagLT_ULT) yes no) -> (First nil yes no) 621 (LT (FlagLT_UGT) yes no) -> (First nil yes no) 622 (LT (FlagGT_ULT) yes no) -> (First nil no yes) 623 (LT (FlagGT_UGT) yes no) -> (First nil no yes) 624 625 (LE (FlagEQ) yes no) -> (First nil yes no) 626 (LE (FlagLT_ULT) yes no) -> (First nil yes no) 627 (LE (FlagLT_UGT) yes no) -> (First nil yes no) 628 (LE (FlagGT_ULT) yes no) -> (First nil no yes) 629 (LE (FlagGT_UGT) yes no) -> (First nil no yes) 630 631 (GT (FlagEQ) yes no) -> (First nil no yes) 632 (GT (FlagLT_ULT) yes no) -> (First nil no yes) 633 (GT (FlagLT_UGT) yes no) -> (First nil no yes) 634 (GT (FlagGT_ULT) yes no) -> (First nil yes no) 635 (GT (FlagGT_UGT) yes no) -> (First nil yes no) 636 637 (GE (FlagEQ) yes no) -> (First nil yes no) 638 (GE (FlagLT_ULT) yes no) -> (First nil no yes) 639 (GE (FlagLT_UGT) yes no) -> (First nil no yes) 640 (GE (FlagGT_ULT) yes no) -> (First nil yes no) 641 (GE (FlagGT_UGT) yes no) -> (First nil yes no) 642 643 (ULT (FlagEQ) yes no) -> (First nil no yes) 644 (ULT (FlagLT_ULT) yes no) -> (First nil yes no) 645 (ULT (FlagLT_UGT) yes no) -> (First nil no yes) 646 (ULT (FlagGT_ULT) yes no) -> (First nil yes no) 647 (ULT (FlagGT_UGT) yes no) -> (First nil no yes) 648 649 (ULE (FlagEQ) yes no) -> (First nil yes no) 650 (ULE (FlagLT_ULT) yes no) -> (First nil yes no) 651 (ULE (FlagLT_UGT) yes no) -> (First nil no yes) 652 (ULE (FlagGT_ULT) yes no) -> (First nil yes no) 653 (ULE (FlagGT_UGT) yes no) -> (First nil no yes) 654 655 (UGT (FlagEQ) yes no) -> (First nil no yes) 656 (UGT (FlagLT_ULT) yes no) -> (First nil no yes) 657 (UGT (FlagLT_UGT) yes no) -> (First nil yes no) 658 (UGT (FlagGT_ULT) yes no) -> (First nil no yes) 659 (UGT (FlagGT_UGT) yes no) -> (First nil yes no) 660 661 (UGE (FlagEQ) yes no) -> (First nil yes no) 662 (UGE (FlagLT_ULT) yes no) -> (First nil no yes) 663 (UGE (FlagLT_UGT) yes no) -> (First nil yes no) 664 (UGE (FlagGT_ULT) yes no) -> (First nil no yes) 665 (UGE (FlagGT_UGT) yes no) -> (First nil yes no) 666 667 // absorb InvertFlags into branches 668 (LT (InvertFlags cmp) yes no) -> (GT cmp yes no) 669 (GT (InvertFlags cmp) yes no) -> (LT cmp yes no) 670 (LE (InvertFlags cmp) yes no) -> (GE cmp yes no) 671 (GE (InvertFlags cmp) yes no) -> (LE cmp yes no) 672 (ULT (InvertFlags cmp) yes no) -> (UGT cmp yes no) 673 (UGT (InvertFlags cmp) yes no) -> (ULT cmp yes no) 674 (ULE (InvertFlags cmp) yes no) -> (UGE cmp yes no) 675 (UGE (InvertFlags cmp) yes no) -> (ULE cmp yes no) 676 (EQ (InvertFlags cmp) yes no) -> (EQ cmp yes no) 677 (NE (InvertFlags cmp) yes no) -> (NE cmp yes no) 678 679 // absorb flag constants into boolean values 680 (Equal (FlagEQ)) -> (MOVWconst [1]) 681 (Equal (FlagLT_ULT)) -> (MOVWconst [0]) 682 (Equal (FlagLT_UGT)) -> (MOVWconst [0]) 683 (Equal (FlagGT_ULT)) -> (MOVWconst [0]) 684 (Equal (FlagGT_UGT)) -> (MOVWconst [0]) 685 686 (NotEqual (FlagEQ)) -> (MOVWconst [0]) 687 (NotEqual (FlagLT_ULT)) -> (MOVWconst [1]) 688 (NotEqual (FlagLT_UGT)) -> (MOVWconst [1]) 689 (NotEqual (FlagGT_ULT)) -> (MOVWconst [1]) 690 (NotEqual (FlagGT_UGT)) -> (MOVWconst [1]) 691 692 (LessThan (FlagEQ)) -> (MOVWconst [0]) 693 (LessThan (FlagLT_ULT)) -> (MOVWconst [1]) 694 (LessThan (FlagLT_UGT)) -> (MOVWconst [1]) 695 (LessThan (FlagGT_ULT)) -> (MOVWconst [0]) 696 (LessThan (FlagGT_UGT)) -> (MOVWconst [0]) 697 698 (LessThanU (FlagEQ)) -> (MOVWconst [0]) 699 (LessThanU (FlagLT_ULT)) -> (MOVWconst [1]) 700 (LessThanU (FlagLT_UGT)) -> (MOVWconst [0]) 701 (LessThanU (FlagGT_ULT)) -> (MOVWconst [1]) 702 (LessThanU (FlagGT_UGT)) -> (MOVWconst [0]) 703 704 (LessEqual (FlagEQ)) -> (MOVWconst [1]) 705 (LessEqual (FlagLT_ULT)) -> (MOVWconst [1]) 706 (LessEqual (FlagLT_UGT)) -> (MOVWconst [1]) 707 (LessEqual (FlagGT_ULT)) -> (MOVWconst [0]) 708 (LessEqual (FlagGT_UGT)) -> (MOVWconst [0]) 709 710 (LessEqualU (FlagEQ)) -> (MOVWconst [1]) 711 (LessEqualU (FlagLT_ULT)) -> (MOVWconst [1]) 712 (LessEqualU (FlagLT_UGT)) -> (MOVWconst [0]) 713 (LessEqualU (FlagGT_ULT)) -> (MOVWconst [1]) 714 (LessEqualU (FlagGT_UGT)) -> (MOVWconst [0]) 715 716 (GreaterThan (FlagEQ)) -> (MOVWconst [0]) 717 (GreaterThan (FlagLT_ULT)) -> (MOVWconst [0]) 718 (GreaterThan (FlagLT_UGT)) -> (MOVWconst [0]) 719 (GreaterThan (FlagGT_ULT)) -> (MOVWconst [1]) 720 (GreaterThan (FlagGT_UGT)) -> (MOVWconst [1]) 721 722 (GreaterThanU (FlagEQ)) -> (MOVWconst [0]) 723 (GreaterThanU (FlagLT_ULT)) -> (MOVWconst [0]) 724 (GreaterThanU (FlagLT_UGT)) -> (MOVWconst [1]) 725 (GreaterThanU (FlagGT_ULT)) -> (MOVWconst [0]) 726 (GreaterThanU (FlagGT_UGT)) -> (MOVWconst [1]) 727 728 (GreaterEqual (FlagEQ)) -> (MOVWconst [1]) 729 (GreaterEqual (FlagLT_ULT)) -> (MOVWconst [0]) 730 (GreaterEqual (FlagLT_UGT)) -> (MOVWconst [0]) 731 (GreaterEqual (FlagGT_ULT)) -> (MOVWconst [1]) 732 (GreaterEqual (FlagGT_UGT)) -> (MOVWconst [1]) 733 734 (GreaterEqualU (FlagEQ)) -> (MOVWconst [1]) 735 (GreaterEqualU (FlagLT_ULT)) -> (MOVWconst [0]) 736 (GreaterEqualU (FlagLT_UGT)) -> (MOVWconst [1]) 737 (GreaterEqualU (FlagGT_ULT)) -> (MOVWconst [0]) 738 (GreaterEqualU (FlagGT_UGT)) -> (MOVWconst [1]) 739 740 // absorb InvertFlags into boolean values 741 (Equal (InvertFlags x)) -> (Equal x) 742 (NotEqual (InvertFlags x)) -> (NotEqual x) 743 (LessThan (InvertFlags x)) -> (GreaterThan x) 744 (LessThanU (InvertFlags x)) -> (GreaterThanU x) 745 (GreaterThan (InvertFlags x)) -> (LessThan x) 746 (GreaterThanU (InvertFlags x)) -> (LessThanU x) 747 (LessEqual (InvertFlags x)) -> (GreaterEqual x) 748 (LessEqualU (InvertFlags x)) -> (GreaterEqualU x) 749 (GreaterEqual (InvertFlags x)) -> (LessEqual x) 750 (GreaterEqualU (InvertFlags x)) -> (LessEqualU x) 751 752 // absorb flag constants into conditional instructions 753 (CMOVWLSconst _ (FlagEQ) [c]) -> (MOVWconst [c]) 754 (CMOVWLSconst _ (FlagLT_ULT) [c]) -> (MOVWconst [c]) 755 (CMOVWLSconst x (FlagLT_UGT)) -> x 756 (CMOVWLSconst _ (FlagGT_ULT) [c]) -> (MOVWconst [c]) 757 (CMOVWLSconst x (FlagGT_UGT)) -> x 758 759 (CMOVWHSconst _ (FlagEQ) [c]) -> (MOVWconst [c]) 760 (CMOVWHSconst x (FlagLT_ULT)) -> x 761 (CMOVWHSconst _ (FlagLT_UGT) [c]) -> (MOVWconst [c]) 762 (CMOVWHSconst x (FlagGT_ULT)) -> x 763 (CMOVWHSconst _ (FlagGT_UGT) [c]) -> (MOVWconst [c]) 764 765 (CMOVWLSconst x (InvertFlags flags) [c]) -> (CMOVWHSconst x flags [c]) 766 (CMOVWHSconst x (InvertFlags flags) [c]) -> (CMOVWLSconst x flags [c]) 767 768 (SRAcond x _ (FlagEQ)) -> (SRAconst x [31]) 769 (SRAcond x y (FlagLT_ULT)) -> (SRA x y) 770 (SRAcond x _ (FlagLT_UGT)) -> (SRAconst x [31]) 771 (SRAcond x y (FlagGT_ULT)) -> (SRA x y) 772 (SRAcond x _ (FlagGT_UGT)) -> (SRAconst x [31]) 773 774 // remove redundant *const ops 775 (ADDconst [0] x) -> x 776 (SUBconst [0] x) -> x 777 (ANDconst [0] _) -> (MOVWconst [0]) 778 (ANDconst [c] x) && int32(c)==-1 -> x 779 (ORconst [0] x) -> x 780 (ORconst [c] _) && int32(c)==-1 -> (MOVWconst [-1]) 781 (XORconst [0] x) -> x 782 (BICconst [0] x) -> x 783 (BICconst [c] _) && int32(c)==-1 -> (MOVWconst [0]) 784 785 // generic constant folding 786 (ADDconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(c+d))]) 787 (ADDconst [c] (ADDconst [d] x)) -> (ADDconst [int64(int32(c+d))] x) 788 (ADDconst [c] (SUBconst [d] x)) -> (ADDconst [int64(int32(c-d))] x) 789 (ADDconst [c] (RSBconst [d] x)) -> (RSBconst [int64(int32(c+d))] x) 790 (ADCconst [c] (ADDconst [d] x) flags) -> (ADCconst [int64(int32(c+d))] x flags) 791 (ADCconst [c] (SUBconst [d] x) flags) -> (ADCconst [int64(int32(c-d))] x flags) 792 (SUBconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(d-c))]) 793 (SUBconst [c] (SUBconst [d] x)) -> (ADDconst [int64(int32(-c-d))] x) 794 (SUBconst [c] (ADDconst [d] x)) -> (ADDconst [int64(int32(-c+d))] x) 795 (SUBconst [c] (RSBconst [d] x)) -> (RSBconst [int64(int32(-c+d))] x) 796 (SBCconst [c] (ADDconst [d] x) flags) -> (SBCconst [int64(int32(c-d))] x flags) 797 (SBCconst [c] (SUBconst [d] x) flags) -> (SBCconst [int64(int32(c+d))] x flags) 798 (RSBconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(c-d))]) 799 (RSBconst [c] (RSBconst [d] x)) -> (ADDconst [int64(int32(c-d))] x) 800 (RSBconst [c] (ADDconst [d] x)) -> (RSBconst [int64(int32(c-d))] x) 801 (RSBconst [c] (SUBconst [d] x)) -> (RSBconst [int64(int32(c+d))] x) 802 (RSCconst [c] (ADDconst [d] x) flags) -> (RSCconst [int64(int32(c-d))] x flags) 803 (RSCconst [c] (SUBconst [d] x) flags) -> (RSCconst [int64(int32(c+d))] x flags) 804 (SLLconst [c] (MOVWconst [d])) -> (MOVWconst [int64(uint32(d)<<uint64(c))]) 805 (SRLconst [c] (MOVWconst [d])) -> (MOVWconst [int64(uint32(d)>>uint64(c))]) 806 (SRAconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(d)>>uint64(c))]) 807 (MUL (MOVWconst [c]) (MOVWconst [d])) -> (MOVWconst [int64(int32(c*d))]) 808 (MULA (MOVWconst [c]) (MOVWconst [d]) a) -> (ADDconst [int64(int32(c*d))] a) 809 (Select0 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(uint32(c)/uint32(d))]) 810 (Select1 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(uint32(c)%uint32(d))]) 811 (ANDconst [c] (MOVWconst [d])) -> (MOVWconst [c&d]) 812 (ANDconst [c] (ANDconst [d] x)) -> (ANDconst [c&d] x) 813 (ORconst [c] (MOVWconst [d])) -> (MOVWconst [c|d]) 814 (ORconst [c] (ORconst [d] x)) -> (ORconst [c|d] x) 815 (XORconst [c] (MOVWconst [d])) -> (MOVWconst [c^d]) 816 (XORconst [c] (XORconst [d] x)) -> (XORconst [c^d] x) 817 (BICconst [c] (MOVWconst [d])) -> (MOVWconst [d&^c]) 818 (MVN (MOVWconst [c])) -> (MOVWconst [^c]) 819 (MOVBreg (MOVWconst [c])) -> (MOVWconst [int64(int8(c))]) 820 (MOVBUreg (MOVWconst [c])) -> (MOVWconst [int64(uint8(c))]) 821 (MOVHreg (MOVWconst [c])) -> (MOVWconst [int64(int16(c))]) 822 (MOVHUreg (MOVWconst [c])) -> (MOVWconst [int64(uint16(c))]) 823 (MOVWreg (MOVWconst [c])) -> (MOVWconst [c]) 824 825 // absorb shifts into ops 826 (ADD x (SLLconst [c] y)) -> (ADDshiftLL x y [c]) 827 (ADD x (SRLconst [c] y)) -> (ADDshiftRL x y [c]) 828 (ADD x (SRAconst [c] y)) -> (ADDshiftRA x y [c]) 829 (ADD x (SLL y z)) -> (ADDshiftLLreg x y z) 830 (ADD x (SRL y z)) -> (ADDshiftRLreg x y z) 831 (ADD x (SRA y z)) -> (ADDshiftRAreg x y z) 832 (ADC x (SLLconst [c] y) flags) -> (ADCshiftLL x y [c] flags) 833 (ADC (SLLconst [c] y) x flags) -> (ADCshiftLL x y [c] flags) 834 (ADC x (SRLconst [c] y) flags) -> (ADCshiftRL x y [c] flags) 835 (ADC (SRLconst [c] y) x flags) -> (ADCshiftRL x y [c] flags) 836 (ADC x (SRAconst [c] y) flags) -> (ADCshiftRA x y [c] flags) 837 (ADC (SRAconst [c] y) x flags) -> (ADCshiftRA x y [c] flags) 838 (ADC x (SLL y z) flags) -> (ADCshiftLLreg x y z flags) 839 (ADC (SLL y z) x flags) -> (ADCshiftLLreg x y z flags) 840 (ADC x (SRL y z) flags) -> (ADCshiftRLreg x y z flags) 841 (ADC (SRL y z) x flags) -> (ADCshiftRLreg x y z flags) 842 (ADC x (SRA y z) flags) -> (ADCshiftRAreg x y z flags) 843 (ADC (SRA y z) x flags) -> (ADCshiftRAreg x y z flags) 844 (ADDS x (SLLconst [c] y)) -> (ADDSshiftLL x y [c]) 845 (ADDS x (SRLconst [c] y)) -> (ADDSshiftRL x y [c]) 846 (ADDS x (SRAconst [c] y)) -> (ADDSshiftRA x y [c]) 847 (ADDS x (SLL y z)) -> (ADDSshiftLLreg x y z) 848 (ADDS x (SRL y z)) -> (ADDSshiftRLreg x y z) 849 (ADDS x (SRA y z)) -> (ADDSshiftRAreg x y z) 850 (SUB x (SLLconst [c] y)) -> (SUBshiftLL x y [c]) 851 (SUB (SLLconst [c] y) x) -> (RSBshiftLL x y [c]) 852 (SUB x (SRLconst [c] y)) -> (SUBshiftRL x y [c]) 853 (SUB (SRLconst [c] y) x) -> (RSBshiftRL x y [c]) 854 (SUB x (SRAconst [c] y)) -> (SUBshiftRA x y [c]) 855 (SUB (SRAconst [c] y) x) -> (RSBshiftRA x y [c]) 856 (SUB x (SLL y z)) -> (SUBshiftLLreg x y z) 857 (SUB (SLL y z) x) -> (RSBshiftLLreg x y z) 858 (SUB x (SRL y z)) -> (SUBshiftRLreg x y z) 859 (SUB (SRL y z) x) -> (RSBshiftRLreg x y z) 860 (SUB x (SRA y z)) -> (SUBshiftRAreg x y z) 861 (SUB (SRA y z) x) -> (RSBshiftRAreg x y z) 862 (SBC x (SLLconst [c] y) flags) -> (SBCshiftLL x y [c] flags) 863 (SBC (SLLconst [c] y) x flags) -> (RSCshiftLL x y [c] flags) 864 (SBC x (SRLconst [c] y) flags) -> (SBCshiftRL x y [c] flags) 865 (SBC (SRLconst [c] y) x flags) -> (RSCshiftRL x y [c] flags) 866 (SBC x (SRAconst [c] y) flags) -> (SBCshiftRA x y [c] flags) 867 (SBC (SRAconst [c] y) x flags) -> (RSCshiftRA x y [c] flags) 868 (SBC x (SLL y z) flags) -> (SBCshiftLLreg x y z flags) 869 (SBC (SLL y z) x flags) -> (RSCshiftLLreg x y z flags) 870 (SBC x (SRL y z) flags) -> (SBCshiftRLreg x y z flags) 871 (SBC (SRL y z) x flags) -> (RSCshiftRLreg x y z flags) 872 (SBC x (SRA y z) flags) -> (SBCshiftRAreg x y z flags) 873 (SBC (SRA y z) x flags) -> (RSCshiftRAreg x y z flags) 874 (SUBS x (SLLconst [c] y)) -> (SUBSshiftLL x y [c]) 875 (SUBS (SLLconst [c] y) x) -> (RSBSshiftLL x y [c]) 876 (SUBS x (SRLconst [c] y)) -> (SUBSshiftRL x y [c]) 877 (SUBS (SRLconst [c] y) x) -> (RSBSshiftRL x y [c]) 878 (SUBS x (SRAconst [c] y)) -> (SUBSshiftRA x y [c]) 879 (SUBS (SRAconst [c] y) x) -> (RSBSshiftRA x y [c]) 880 (SUBS x (SLL y z)) -> (SUBSshiftLLreg x y z) 881 (SUBS (SLL y z) x) -> (RSBSshiftLLreg x y z) 882 (SUBS x (SRL y z)) -> (SUBSshiftRLreg x y z) 883 (SUBS (SRL y z) x) -> (RSBSshiftRLreg x y z) 884 (SUBS x (SRA y z)) -> (SUBSshiftRAreg x y z) 885 (SUBS (SRA y z) x) -> (RSBSshiftRAreg x y z) 886 (RSB x (SLLconst [c] y)) -> (RSBshiftLL x y [c]) 887 (RSB (SLLconst [c] y) x) -> (SUBshiftLL x y [c]) 888 (RSB x (SRLconst [c] y)) -> (RSBshiftRL x y [c]) 889 (RSB (SRLconst [c] y) x) -> (SUBshiftRL x y [c]) 890 (RSB x (SRAconst [c] y)) -> (RSBshiftRA x y [c]) 891 (RSB (SRAconst [c] y) x) -> (SUBshiftRA x y [c]) 892 (RSB x (SLL y z)) -> (RSBshiftLLreg x y z) 893 (RSB (SLL y z) x) -> (SUBshiftLLreg x y z) 894 (RSB x (SRL y z)) -> (RSBshiftRLreg x y z) 895 (RSB (SRL y z) x) -> (SUBshiftRLreg x y z) 896 (RSB x (SRA y z)) -> (RSBshiftRAreg x y z) 897 (RSB (SRA y z) x) -> (SUBshiftRAreg x y z) 898 (AND x (SLLconst [c] y)) -> (ANDshiftLL x y [c]) 899 (AND x (SRLconst [c] y)) -> (ANDshiftRL x y [c]) 900 (AND x (SRAconst [c] y)) -> (ANDshiftRA x y [c]) 901 (AND x (SLL y z)) -> (ANDshiftLLreg x y z) 902 (AND x (SRL y z)) -> (ANDshiftRLreg x y z) 903 (AND x (SRA y z)) -> (ANDshiftRAreg x y z) 904 (OR x (SLLconst [c] y)) -> (ORshiftLL x y [c]) 905 (OR x (SRLconst [c] y)) -> (ORshiftRL x y [c]) 906 (OR x (SRAconst [c] y)) -> (ORshiftRA x y [c]) 907 (OR x (SLL y z)) -> (ORshiftLLreg x y z) 908 (OR x (SRL y z)) -> (ORshiftRLreg x y z) 909 (OR x (SRA y z)) -> (ORshiftRAreg x y z) 910 (XOR x (SLLconst [c] y)) -> (XORshiftLL x y [c]) 911 (XOR x (SRLconst [c] y)) -> (XORshiftRL x y [c]) 912 (XOR x (SRAconst [c] y)) -> (XORshiftRA x y [c]) 913 (XOR x (SRRconst [c] y)) -> (XORshiftRR x y [c]) 914 (XOR x (SLL y z)) -> (XORshiftLLreg x y z) 915 (XOR x (SRL y z)) -> (XORshiftRLreg x y z) 916 (XOR x (SRA y z)) -> (XORshiftRAreg x y z) 917 (BIC x (SLLconst [c] y)) -> (BICshiftLL x y [c]) 918 (BIC x (SRLconst [c] y)) -> (BICshiftRL x y [c]) 919 (BIC x (SRAconst [c] y)) -> (BICshiftRA x y [c]) 920 (BIC x (SLL y z)) -> (BICshiftLLreg x y z) 921 (BIC x (SRL y z)) -> (BICshiftRLreg x y z) 922 (BIC x (SRA y z)) -> (BICshiftRAreg x y z) 923 (MVN (SLLconst [c] x)) -> (MVNshiftLL x [c]) 924 (MVN (SRLconst [c] x)) -> (MVNshiftRL x [c]) 925 (MVN (SRAconst [c] x)) -> (MVNshiftRA x [c]) 926 (MVN (SLL x y)) -> (MVNshiftLLreg x y) 927 (MVN (SRL x y)) -> (MVNshiftRLreg x y) 928 (MVN (SRA x y)) -> (MVNshiftRAreg x y) 929 930 (CMP x (SLLconst [c] y)) -> (CMPshiftLL x y [c]) 931 (CMP (SLLconst [c] y) x) -> (InvertFlags (CMPshiftLL x y [c])) 932 (CMP x (SRLconst [c] y)) -> (CMPshiftRL x y [c]) 933 (CMP (SRLconst [c] y) x) -> (InvertFlags (CMPshiftRL x y [c])) 934 (CMP x (SRAconst [c] y)) -> (CMPshiftRA x y [c]) 935 (CMP (SRAconst [c] y) x) -> (InvertFlags (CMPshiftRA x y [c])) 936 (CMP x (SLL y z)) -> (CMPshiftLLreg x y z) 937 (CMP (SLL y z) x) -> (InvertFlags (CMPshiftLLreg x y z)) 938 (CMP x (SRL y z)) -> (CMPshiftRLreg x y z) 939 (CMP (SRL y z) x) -> (InvertFlags (CMPshiftRLreg x y z)) 940 (CMP x (SRA y z)) -> (CMPshiftRAreg x y z) 941 (CMP (SRA y z) x) -> (InvertFlags (CMPshiftRAreg x y z)) 942 943 // prefer *const ops to *shift ops 944 (ADDshiftLL (MOVWconst [c]) x [d]) -> (ADDconst [c] (SLLconst <x.Type> x [d])) 945 (ADDshiftRL (MOVWconst [c]) x [d]) -> (ADDconst [c] (SRLconst <x.Type> x [d])) 946 (ADDshiftRA (MOVWconst [c]) x [d]) -> (ADDconst [c] (SRAconst <x.Type> x [d])) 947 (ADCshiftLL (MOVWconst [c]) x [d] flags) -> (ADCconst [c] (SLLconst <x.Type> x [d]) flags) 948 (ADCshiftRL (MOVWconst [c]) x [d] flags) -> (ADCconst [c] (SRLconst <x.Type> x [d]) flags) 949 (ADCshiftRA (MOVWconst [c]) x [d] flags) -> (ADCconst [c] (SRAconst <x.Type> x [d]) flags) 950 (ADDSshiftLL (MOVWconst [c]) x [d]) -> (ADDSconst [c] (SLLconst <x.Type> x [d])) 951 (ADDSshiftRL (MOVWconst [c]) x [d]) -> (ADDSconst [c] (SRLconst <x.Type> x [d])) 952 (ADDSshiftRA (MOVWconst [c]) x [d]) -> (ADDSconst [c] (SRAconst <x.Type> x [d])) 953 (SUBshiftLL (MOVWconst [c]) x [d]) -> (RSBconst [c] (SLLconst <x.Type> x [d])) 954 (SUBshiftRL (MOVWconst [c]) x [d]) -> (RSBconst [c] (SRLconst <x.Type> x [d])) 955 (SUBshiftRA (MOVWconst [c]) x [d]) -> (RSBconst [c] (SRAconst <x.Type> x [d])) 956 (SBCshiftLL (MOVWconst [c]) x [d] flags) -> (RSCconst [c] (SLLconst <x.Type> x [d]) flags) 957 (SBCshiftRL (MOVWconst [c]) x [d] flags) -> (RSCconst [c] (SRLconst <x.Type> x [d]) flags) 958 (SBCshiftRA (MOVWconst [c]) x [d] flags) -> (RSCconst [c] (SRAconst <x.Type> x [d]) flags) 959 (SUBSshiftLL (MOVWconst [c]) x [d]) -> (RSBSconst [c] (SLLconst <x.Type> x [d])) 960 (SUBSshiftRL (MOVWconst [c]) x [d]) -> (RSBSconst [c] (SRLconst <x.Type> x [d])) 961 (SUBSshiftRA (MOVWconst [c]) x [d]) -> (RSBSconst [c] (SRAconst <x.Type> x [d])) 962 (RSBshiftLL (MOVWconst [c]) x [d]) -> (SUBconst [c] (SLLconst <x.Type> x [d])) 963 (RSBshiftRL (MOVWconst [c]) x [d]) -> (SUBconst [c] (SRLconst <x.Type> x [d])) 964 (RSBshiftRA (MOVWconst [c]) x [d]) -> (SUBconst [c] (SRAconst <x.Type> x [d])) 965 (RSCshiftLL (MOVWconst [c]) x [d] flags) -> (SBCconst [c] (SLLconst <x.Type> x [d]) flags) 966 (RSCshiftRL (MOVWconst [c]) x [d] flags) -> (SBCconst [c] (SRLconst <x.Type> x [d]) flags) 967 (RSCshiftRA (MOVWconst [c]) x [d] flags) -> (SBCconst [c] (SRAconst <x.Type> x [d]) flags) 968 (RSBSshiftLL (MOVWconst [c]) x [d]) -> (SUBSconst [c] (SLLconst <x.Type> x [d])) 969 (RSBSshiftRL (MOVWconst [c]) x [d]) -> (SUBSconst [c] (SRLconst <x.Type> x [d])) 970 (RSBSshiftRA (MOVWconst [c]) x [d]) -> (SUBSconst [c] (SRAconst <x.Type> x [d])) 971 (ANDshiftLL (MOVWconst [c]) x [d]) -> (ANDconst [c] (SLLconst <x.Type> x [d])) 972 (ANDshiftRL (MOVWconst [c]) x [d]) -> (ANDconst [c] (SRLconst <x.Type> x [d])) 973 (ANDshiftRA (MOVWconst [c]) x [d]) -> (ANDconst [c] (SRAconst <x.Type> x [d])) 974 (ORshiftLL (MOVWconst [c]) x [d]) -> (ORconst [c] (SLLconst <x.Type> x [d])) 975 (ORshiftRL (MOVWconst [c]) x [d]) -> (ORconst [c] (SRLconst <x.Type> x [d])) 976 (ORshiftRA (MOVWconst [c]) x [d]) -> (ORconst [c] (SRAconst <x.Type> x [d])) 977 (XORshiftLL (MOVWconst [c]) x [d]) -> (XORconst [c] (SLLconst <x.Type> x [d])) 978 (XORshiftRL (MOVWconst [c]) x [d]) -> (XORconst [c] (SRLconst <x.Type> x [d])) 979 (XORshiftRA (MOVWconst [c]) x [d]) -> (XORconst [c] (SRAconst <x.Type> x [d])) 980 (XORshiftRR (MOVWconst [c]) x [d]) -> (XORconst [c] (SRRconst <x.Type> x [d])) 981 (CMPshiftLL (MOVWconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SLLconst <x.Type> x [d]))) 982 (CMPshiftRL (MOVWconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SRLconst <x.Type> x [d]))) 983 (CMPshiftRA (MOVWconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SRAconst <x.Type> x [d]))) 984 985 (ADDshiftLLreg (MOVWconst [c]) x y) -> (ADDconst [c] (SLL <x.Type> x y)) 986 (ADDshiftRLreg (MOVWconst [c]) x y) -> (ADDconst [c] (SRL <x.Type> x y)) 987 (ADDshiftRAreg (MOVWconst [c]) x y) -> (ADDconst [c] (SRA <x.Type> x y)) 988 (ADCshiftLLreg (MOVWconst [c]) x y flags) -> (ADCconst [c] (SLL <x.Type> x y) flags) 989 (ADCshiftRLreg (MOVWconst [c]) x y flags) -> (ADCconst [c] (SRL <x.Type> x y) flags) 990 (ADCshiftRAreg (MOVWconst [c]) x y flags) -> (ADCconst [c] (SRA <x.Type> x y) flags) 991 (ADDSshiftLLreg (MOVWconst [c]) x y) -> (ADDSconst [c] (SLL <x.Type> x y)) 992 (ADDSshiftRLreg (MOVWconst [c]) x y) -> (ADDSconst [c] (SRL <x.Type> x y)) 993 (ADDSshiftRAreg (MOVWconst [c]) x y) -> (ADDSconst [c] (SRA <x.Type> x y)) 994 (SUBshiftLLreg (MOVWconst [c]) x y) -> (RSBconst [c] (SLL <x.Type> x y)) 995 (SUBshiftRLreg (MOVWconst [c]) x y) -> (RSBconst [c] (SRL <x.Type> x y)) 996 (SUBshiftRAreg (MOVWconst [c]) x y) -> (RSBconst [c] (SRA <x.Type> x y)) 997 (SBCshiftLLreg (MOVWconst [c]) x y flags) -> (RSCconst [c] (SLL <x.Type> x y) flags) 998 (SBCshiftRLreg (MOVWconst [c]) x y flags) -> (RSCconst [c] (SRL <x.Type> x y) flags) 999 (SBCshiftRAreg (MOVWconst [c]) x y flags) -> (RSCconst [c] (SRA <x.Type> x y) flags) 1000 (SUBSshiftLLreg (MOVWconst [c]) x y) -> (RSBSconst [c] (SLL <x.Type> x y)) 1001 (SUBSshiftRLreg (MOVWconst [c]) x y) -> (RSBSconst [c] (SRL <x.Type> x y)) 1002 (SUBSshiftRAreg (MOVWconst [c]) x y) -> (RSBSconst [c] (SRA <x.Type> x y)) 1003 (RSBshiftLLreg (MOVWconst [c]) x y) -> (SUBconst [c] (SLL <x.Type> x y)) 1004 (RSBshiftRLreg (MOVWconst [c]) x y) -> (SUBconst [c] (SRL <x.Type> x y)) 1005 (RSBshiftRAreg (MOVWconst [c]) x y) -> (SUBconst [c] (SRA <x.Type> x y)) 1006 (RSCshiftLLreg (MOVWconst [c]) x y flags) -> (SBCconst [c] (SLL <x.Type> x y) flags) 1007 (RSCshiftRLreg (MOVWconst [c]) x y flags) -> (SBCconst [c] (SRL <x.Type> x y) flags) 1008 (RSCshiftRAreg (MOVWconst [c]) x y flags) -> (SBCconst [c] (SRA <x.Type> x y) flags) 1009 (RSBSshiftLLreg (MOVWconst [c]) x y) -> (SUBSconst [c] (SLL <x.Type> x y)) 1010 (RSBSshiftRLreg (MOVWconst [c]) x y) -> (SUBSconst [c] (SRL <x.Type> x y)) 1011 (RSBSshiftRAreg (MOVWconst [c]) x y) -> (SUBSconst [c] (SRA <x.Type> x y)) 1012 (ANDshiftLLreg (MOVWconst [c]) x y) -> (ANDconst [c] (SLL <x.Type> x y)) 1013 (ANDshiftRLreg (MOVWconst [c]) x y) -> (ANDconst [c] (SRL <x.Type> x y)) 1014 (ANDshiftRAreg (MOVWconst [c]) x y) -> (ANDconst [c] (SRA <x.Type> x y)) 1015 (ORshiftLLreg (MOVWconst [c]) x y) -> (ORconst [c] (SLL <x.Type> x y)) 1016 (ORshiftRLreg (MOVWconst [c]) x y) -> (ORconst [c] (SRL <x.Type> x y)) 1017 (ORshiftRAreg (MOVWconst [c]) x y) -> (ORconst [c] (SRA <x.Type> x y)) 1018 (XORshiftLLreg (MOVWconst [c]) x y) -> (XORconst [c] (SLL <x.Type> x y)) 1019 (XORshiftRLreg (MOVWconst [c]) x y) -> (XORconst [c] (SRL <x.Type> x y)) 1020 (XORshiftRAreg (MOVWconst [c]) x y) -> (XORconst [c] (SRA <x.Type> x y)) 1021 (CMPshiftLLreg (MOVWconst [c]) x y) -> (InvertFlags (CMPconst [c] (SLL <x.Type> x y))) 1022 (CMPshiftRLreg (MOVWconst [c]) x y) -> (InvertFlags (CMPconst [c] (SRL <x.Type> x y))) 1023 (CMPshiftRAreg (MOVWconst [c]) x y) -> (InvertFlags (CMPconst [c] (SRA <x.Type> x y))) 1024 1025 // constant folding in *shift ops 1026 (ADDshiftLL x (MOVWconst [c]) [d]) -> (ADDconst x [int64(uint32(c)<<uint64(d))]) 1027 (ADDshiftRL x (MOVWconst [c]) [d]) -> (ADDconst x [int64(uint32(c)>>uint64(d))]) 1028 (ADDshiftRA x (MOVWconst [c]) [d]) -> (ADDconst x [int64(int32(c)>>uint64(d))]) 1029 (ADCshiftLL x (MOVWconst [c]) [d] flags) -> (ADCconst x [int64(uint32(c)<<uint64(d))] flags) 1030 (ADCshiftRL x (MOVWconst [c]) [d] flags) -> (ADCconst x [int64(uint32(c)>>uint64(d))] flags) 1031 (ADCshiftRA x (MOVWconst [c]) [d] flags) -> (ADCconst x [int64(int32(c)>>uint64(d))] flags) 1032 (ADDSshiftLL x (MOVWconst [c]) [d]) -> (ADDSconst x [int64(uint32(c)<<uint64(d))]) 1033 (ADDSshiftRL x (MOVWconst [c]) [d]) -> (ADDSconst x [int64(uint32(c)>>uint64(d))]) 1034 (ADDSshiftRA x (MOVWconst [c]) [d]) -> (ADDSconst x [int64(int32(c)>>uint64(d))]) 1035 (SUBshiftLL x (MOVWconst [c]) [d]) -> (SUBconst x [int64(uint32(c)<<uint64(d))]) 1036 (SUBshiftRL x (MOVWconst [c]) [d]) -> (SUBconst x [int64(uint32(c)>>uint64(d))]) 1037 (SUBshiftRA x (MOVWconst [c]) [d]) -> (SUBconst x [int64(int32(c)>>uint64(d))]) 1038 (SBCshiftLL x (MOVWconst [c]) [d] flags) -> (SBCconst x [int64(uint32(c)<<uint64(d))] flags) 1039 (SBCshiftRL x (MOVWconst [c]) [d] flags) -> (SBCconst x [int64(uint32(c)>>uint64(d))] flags) 1040 (SBCshiftRA x (MOVWconst [c]) [d] flags) -> (SBCconst x [int64(int32(c)>>uint64(d))] flags) 1041 (SUBSshiftLL x (MOVWconst [c]) [d]) -> (SUBSconst x [int64(uint32(c)<<uint64(d))]) 1042 (SUBSshiftRL x (MOVWconst [c]) [d]) -> (SUBSconst x [int64(uint32(c)>>uint64(d))]) 1043 (SUBSshiftRA x (MOVWconst [c]) [d]) -> (SUBSconst x [int64(int32(c)>>uint64(d))]) 1044 (RSBshiftLL x (MOVWconst [c]) [d]) -> (RSBconst x [int64(uint32(c)<<uint64(d))]) 1045 (RSBshiftRL x (MOVWconst [c]) [d]) -> (RSBconst x [int64(uint32(c)>>uint64(d))]) 1046 (RSBshiftRA x (MOVWconst [c]) [d]) -> (RSBconst x [int64(int32(c)>>uint64(d))]) 1047 (RSCshiftLL x (MOVWconst [c]) [d] flags) -> (RSCconst x [int64(uint32(c)<<uint64(d))] flags) 1048 (RSCshiftRL x (MOVWconst [c]) [d] flags) -> (RSCconst x [int64(uint32(c)>>uint64(d))] flags) 1049 (RSCshiftRA x (MOVWconst [c]) [d] flags) -> (RSCconst x [int64(int32(c)>>uint64(d))] flags) 1050 (RSBSshiftLL x (MOVWconst [c]) [d]) -> (RSBSconst x [int64(uint32(c)<<uint64(d))]) 1051 (RSBSshiftRL x (MOVWconst [c]) [d]) -> (RSBSconst x [int64(uint32(c)>>uint64(d))]) 1052 (RSBSshiftRA x (MOVWconst [c]) [d]) -> (RSBSconst x [int64(int32(c)>>uint64(d))]) 1053 (ANDshiftLL x (MOVWconst [c]) [d]) -> (ANDconst x [int64(uint32(c)<<uint64(d))]) 1054 (ANDshiftRL x (MOVWconst [c]) [d]) -> (ANDconst x [int64(uint32(c)>>uint64(d))]) 1055 (ANDshiftRA x (MOVWconst [c]) [d]) -> (ANDconst x [int64(int32(c)>>uint64(d))]) 1056 (ORshiftLL x (MOVWconst [c]) [d]) -> (ORconst x [int64(uint32(c)<<uint64(d))]) 1057 (ORshiftRL x (MOVWconst [c]) [d]) -> (ORconst x [int64(uint32(c)>>uint64(d))]) 1058 (ORshiftRA x (MOVWconst [c]) [d]) -> (ORconst x [int64(int32(c)>>uint64(d))]) 1059 (XORshiftLL x (MOVWconst [c]) [d]) -> (XORconst x [int64(uint32(c)<<uint64(d))]) 1060 (XORshiftRL x (MOVWconst [c]) [d]) -> (XORconst x [int64(uint32(c)>>uint64(d))]) 1061 (XORshiftRA x (MOVWconst [c]) [d]) -> (XORconst x [int64(int32(c)>>uint64(d))]) 1062 (XORshiftRR x (MOVWconst [c]) [d]) -> (XORconst x [int64(uint32(c)>>uint64(d)|uint32(c)<<uint64(32-d))]) 1063 (BICshiftLL x (MOVWconst [c]) [d]) -> (BICconst x [int64(uint32(c)<<uint64(d))]) 1064 (BICshiftRL x (MOVWconst [c]) [d]) -> (BICconst x [int64(uint32(c)>>uint64(d))]) 1065 (BICshiftRA x (MOVWconst [c]) [d]) -> (BICconst x [int64(int32(c)>>uint64(d))]) 1066 (MVNshiftLL (MOVWconst [c]) [d]) -> (MOVWconst [^int64(uint32(c)<<uint64(d))]) 1067 (MVNshiftRL (MOVWconst [c]) [d]) -> (MOVWconst [^int64(uint32(c)>>uint64(d))]) 1068 (MVNshiftRA (MOVWconst [c]) [d]) -> (MOVWconst [^int64(int32(c)>>uint64(d))]) 1069 (CMPshiftLL x (MOVWconst [c]) [d]) -> (CMPconst x [int64(uint32(c)<<uint64(d))]) 1070 (CMPshiftRL x (MOVWconst [c]) [d]) -> (CMPconst x [int64(uint32(c)>>uint64(d))]) 1071 (CMPshiftRA x (MOVWconst [c]) [d]) -> (CMPconst x [int64(int32(c)>>uint64(d))]) 1072 1073 (ADDshiftLLreg x y (MOVWconst [c])) -> (ADDshiftLL x y [c]) 1074 (ADDshiftRLreg x y (MOVWconst [c])) -> (ADDshiftRL x y [c]) 1075 (ADDshiftRAreg x y (MOVWconst [c])) -> (ADDshiftRA x y [c]) 1076 (ADCshiftLLreg x y (MOVWconst [c]) flags) -> (ADCshiftLL x y [c] flags) 1077 (ADCshiftRLreg x y (MOVWconst [c]) flags) -> (ADCshiftRL x y [c] flags) 1078 (ADCshiftRAreg x y (MOVWconst [c]) flags) -> (ADCshiftRA x y [c] flags) 1079 (ADDSshiftLLreg x y (MOVWconst [c])) -> (ADDSshiftLL x y [c]) 1080 (ADDSshiftRLreg x y (MOVWconst [c])) -> (ADDSshiftRL x y [c]) 1081 (ADDSshiftRAreg x y (MOVWconst [c])) -> (ADDSshiftRA x y [c]) 1082 (SUBshiftLLreg x y (MOVWconst [c])) -> (SUBshiftLL x y [c]) 1083 (SUBshiftRLreg x y (MOVWconst [c])) -> (SUBshiftRL x y [c]) 1084 (SUBshiftRAreg x y (MOVWconst [c])) -> (SUBshiftRA x y [c]) 1085 (SBCshiftLLreg x y (MOVWconst [c]) flags) -> (SBCshiftLL x y [c] flags) 1086 (SBCshiftRLreg x y (MOVWconst [c]) flags) -> (SBCshiftRL x y [c] flags) 1087 (SBCshiftRAreg x y (MOVWconst [c]) flags) -> (SBCshiftRA x y [c] flags) 1088 (SUBSshiftLLreg x y (MOVWconst [c])) -> (SUBSshiftLL x y [c]) 1089 (SUBSshiftRLreg x y (MOVWconst [c])) -> (SUBSshiftRL x y [c]) 1090 (SUBSshiftRAreg x y (MOVWconst [c])) -> (SUBSshiftRA x y [c]) 1091 (RSBshiftLLreg x y (MOVWconst [c])) -> (RSBshiftLL x y [c]) 1092 (RSBshiftRLreg x y (MOVWconst [c])) -> (RSBshiftRL x y [c]) 1093 (RSBshiftRAreg x y (MOVWconst [c])) -> (RSBshiftRA x y [c]) 1094 (RSCshiftLLreg x y (MOVWconst [c]) flags) -> (RSCshiftLL x y [c] flags) 1095 (RSCshiftRLreg x y (MOVWconst [c]) flags) -> (RSCshiftRL x y [c] flags) 1096 (RSCshiftRAreg x y (MOVWconst [c]) flags) -> (RSCshiftRA x y [c] flags) 1097 (RSBSshiftLLreg x y (MOVWconst [c])) -> (RSBSshiftLL x y [c]) 1098 (RSBSshiftRLreg x y (MOVWconst [c])) -> (RSBSshiftRL x y [c]) 1099 (RSBSshiftRAreg x y (MOVWconst [c])) -> (RSBSshiftRA x y [c]) 1100 (ANDshiftLLreg x y (MOVWconst [c])) -> (ANDshiftLL x y [c]) 1101 (ANDshiftRLreg x y (MOVWconst [c])) -> (ANDshiftRL x y [c]) 1102 (ANDshiftRAreg x y (MOVWconst [c])) -> (ANDshiftRA x y [c]) 1103 (ORshiftLLreg x y (MOVWconst [c])) -> (ORshiftLL x y [c]) 1104 (ORshiftRLreg x y (MOVWconst [c])) -> (ORshiftRL x y [c]) 1105 (ORshiftRAreg x y (MOVWconst [c])) -> (ORshiftRA x y [c]) 1106 (XORshiftLLreg x y (MOVWconst [c])) -> (XORshiftLL x y [c]) 1107 (XORshiftRLreg x y (MOVWconst [c])) -> (XORshiftRL x y [c]) 1108 (XORshiftRAreg x y (MOVWconst [c])) -> (XORshiftRA x y [c]) 1109 (BICshiftLLreg x y (MOVWconst [c])) -> (BICshiftLL x y [c]) 1110 (BICshiftRLreg x y (MOVWconst [c])) -> (BICshiftRL x y [c]) 1111 (BICshiftRAreg x y (MOVWconst [c])) -> (BICshiftRA x y [c]) 1112 (MVNshiftLLreg x (MOVWconst [c])) -> (MVNshiftLL x [c]) 1113 (MVNshiftRLreg x (MOVWconst [c])) -> (MVNshiftRL x [c]) 1114 (MVNshiftRAreg x (MOVWconst [c])) -> (MVNshiftRA x [c]) 1115 (CMPshiftLLreg x y (MOVWconst [c])) -> (CMPshiftLL x y [c]) 1116 (CMPshiftRLreg x y (MOVWconst [c])) -> (CMPshiftRL x y [c]) 1117 (CMPshiftRAreg x y (MOVWconst [c])) -> (CMPshiftRA x y [c]) 1118 1119 // Generate rotates 1120 (ADDshiftLL [c] (SRLconst x [32-c]) x) -> (SRRconst [32-c] x) 1121 ( ORshiftLL [c] (SRLconst x [32-c]) x) -> (SRRconst [32-c] x) 1122 (XORshiftLL [c] (SRLconst x [32-c]) x) -> (SRRconst [32-c] x) 1123 (ADDshiftRL [c] (SLLconst x [32-c]) x) -> (SRRconst [ c] x) 1124 ( ORshiftRL [c] (SLLconst x [32-c]) x) -> (SRRconst [ c] x) 1125 (XORshiftRL [c] (SLLconst x [32-c]) x) -> (SRRconst [ c] x) 1126 1127 // use indexed loads and stores 1128 (MOVWload [0] {sym} (ADD ptr idx) mem) && sym == nil && !config.nacl -> (MOVWloadidx ptr idx mem) 1129 (MOVWstore [0] {sym} (ADD ptr idx) val mem) && sym == nil && !config.nacl -> (MOVWstoreidx ptr idx val mem) 1130 (MOVWload [0] {sym} (ADDshiftLL ptr idx [c]) mem) && sym == nil && !config.nacl -> (MOVWloadshiftLL ptr idx [c] mem) 1131 (MOVWload [0] {sym} (ADDshiftRL ptr idx [c]) mem) && sym == nil && !config.nacl -> (MOVWloadshiftRL ptr idx [c] mem) 1132 (MOVWload [0] {sym} (ADDshiftRA ptr idx [c]) mem) && sym == nil && !config.nacl -> (MOVWloadshiftRA ptr idx [c] mem) 1133 (MOVWstore [0] {sym} (ADDshiftLL ptr idx [c]) val mem) && sym == nil && !config.nacl -> (MOVWstoreshiftLL ptr idx [c] val mem) 1134 (MOVWstore [0] {sym} (ADDshiftRL ptr idx [c]) val mem) && sym == nil && !config.nacl -> (MOVWstoreshiftRL ptr idx [c] val mem) 1135 (MOVWstore [0] {sym} (ADDshiftRA ptr idx [c]) val mem) && sym == nil && !config.nacl -> (MOVWstoreshiftRA ptr idx [c] val mem) 1136 1137 // constant folding in indexed loads and stores 1138 (MOVWloadidx ptr (MOVWconst [c]) mem) -> (MOVWload [c] ptr mem) 1139 (MOVWloadidx (MOVWconst [c]) ptr mem) -> (MOVWload [c] ptr mem) 1140 1141 (MOVWstoreidx ptr (MOVWconst [c]) val mem) -> (MOVWstore [c] ptr val mem) 1142 (MOVWstoreidx (MOVWconst [c]) ptr val mem) -> (MOVWstore [c] ptr val mem) 1143 1144 (MOVWloadidx ptr (SLLconst idx [c]) mem) -> (MOVWloadshiftLL ptr idx [c] mem) 1145 (MOVWloadidx (SLLconst idx [c]) ptr mem) -> (MOVWloadshiftLL ptr idx [c] mem) 1146 (MOVWloadidx ptr (SRLconst idx [c]) mem) -> (MOVWloadshiftRL ptr idx [c] mem) 1147 (MOVWloadidx (SRLconst idx [c]) ptr mem) -> (MOVWloadshiftRL ptr idx [c] mem) 1148 (MOVWloadidx ptr (SRAconst idx [c]) mem) -> (MOVWloadshiftRA ptr idx [c] mem) 1149 (MOVWloadidx (SRAconst idx [c]) ptr mem) -> (MOVWloadshiftRA ptr idx [c] mem) 1150 1151 (MOVWstoreidx ptr (SLLconst idx [c]) val mem) -> (MOVWstoreshiftLL ptr idx [c] val mem) 1152 (MOVWstoreidx (SLLconst idx [c]) ptr val mem) -> (MOVWstoreshiftLL ptr idx [c] val mem) 1153 (MOVWstoreidx ptr (SRLconst idx [c]) val mem) -> (MOVWstoreshiftRL ptr idx [c] val mem) 1154 (MOVWstoreidx (SRLconst idx [c]) ptr val mem) -> (MOVWstoreshiftRL ptr idx [c] val mem) 1155 (MOVWstoreidx ptr (SRAconst idx [c]) val mem) -> (MOVWstoreshiftRA ptr idx [c] val mem) 1156 (MOVWstoreidx (SRAconst idx [c]) ptr val mem) -> (MOVWstoreshiftRA ptr idx [c] val mem) 1157 1158 (MOVWloadshiftLL ptr (MOVWconst [c]) [d] mem) -> (MOVWload [int64(uint32(c)<<uint64(d))] ptr mem) 1159 (MOVWloadshiftRL ptr (MOVWconst [c]) [d] mem) -> (MOVWload [int64(uint32(c)>>uint64(d))] ptr mem) 1160 (MOVWloadshiftRA ptr (MOVWconst [c]) [d] mem) -> (MOVWload [int64(int32(c)>>uint64(d))] ptr mem) 1161 1162 (MOVWstoreshiftLL ptr (MOVWconst [c]) [d] val mem) -> (MOVWstore [int64(uint32(c)<<uint64(d))] ptr val mem) 1163 (MOVWstoreshiftRL ptr (MOVWconst [c]) [d] val mem) -> (MOVWstore [int64(uint32(c)>>uint64(d))] ptr val mem) 1164 (MOVWstoreshiftRA ptr (MOVWconst [c]) [d] val mem) -> (MOVWstore [int64(int32(c)>>uint64(d))] ptr val mem) 1165 1166 // generic simplifications 1167 (ADD x (RSBconst [0] y)) -> (SUB x y) 1168 (ADD <t> (RSBconst [c] x) (RSBconst [d] y)) -> (RSBconst [c+d] (ADD <t> x y)) 1169 (SUB x x) -> (MOVWconst [0]) 1170 (RSB x x) -> (MOVWconst [0]) 1171 (AND x x) -> x 1172 (OR x x) -> x 1173 (XOR x x) -> (MOVWconst [0]) 1174 (BIC x x) -> (MOVWconst [0]) 1175 1176 (ADD (MUL x y) a) -> (MULA x y a) 1177 1178 (AND x (MVN y)) -> (BIC x y) 1179 1180 // simplification with *shift ops 1181 (SUBshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1182 (SUBshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1183 (SUBshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1184 (RSBshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1185 (RSBshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1186 (RSBshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1187 (ANDshiftLL x y:(SLLconst x [c]) [d]) && c==d -> y 1188 (ANDshiftRL x y:(SRLconst x [c]) [d]) && c==d -> y 1189 (ANDshiftRA x y:(SRAconst x [c]) [d]) && c==d -> y 1190 (ORshiftLL x y:(SLLconst x [c]) [d]) && c==d -> y 1191 (ORshiftRL x y:(SRLconst x [c]) [d]) && c==d -> y 1192 (ORshiftRA x y:(SRAconst x [c]) [d]) && c==d -> y 1193 (XORshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1194 (XORshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1195 (XORshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1196 (BICshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1197 (BICshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1198 (BICshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0]) 1199 (AND x (MVNshiftLL y [c])) -> (BICshiftLL x y [c]) 1200 (AND x (MVNshiftRL y [c])) -> (BICshiftRL x y [c]) 1201 (AND x (MVNshiftRA y [c])) -> (BICshiftRA x y [c]) 1202 1203 // floating point optimizations 1204 (CMPF x (MOVFconst [0])) -> (CMPF0 x) 1205 (CMPD x (MOVDconst [0])) -> (CMPD0 x)