github.com/karrick/go@v0.0.0-20170817181416-d5b0ec858b37/src/cmd/compile/internal/ssa/gen/ARM64.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 (Add64 x y) -> (ADD x y) 7 (Add32 x y) -> (ADD x y) 8 (Add16 x y) -> (ADD x y) 9 (Add8 x y) -> (ADD x y) 10 (Add32F x y) -> (FADDS x y) 11 (Add64F x y) -> (FADDD x y) 12 13 (SubPtr x y) -> (SUB x y) 14 (Sub64 x y) -> (SUB x y) 15 (Sub32 x y) -> (SUB x y) 16 (Sub16 x y) -> (SUB x y) 17 (Sub8 x y) -> (SUB x y) 18 (Sub32F x y) -> (FSUBS x y) 19 (Sub64F x y) -> (FSUBD x y) 20 21 (Mul64 x y) -> (MUL x y) 22 (Mul32 x y) -> (MULW x y) 23 (Mul16 x y) -> (MULW x y) 24 (Mul8 x y) -> (MULW x y) 25 (Mul32F x y) -> (FMULS x y) 26 (Mul64F x y) -> (FMULD x y) 27 28 (Hmul64 x y) -> (MULH x y) 29 (Hmul64u x y) -> (UMULH x y) 30 (Hmul32 x y) -> (SRAconst (MULL <typ.Int64> x y) [32]) 31 (Hmul32u x y) -> (SRAconst (UMULL <typ.UInt64> x y) [32]) 32 33 (Div64 x y) -> (DIV x y) 34 (Div64u x y) -> (UDIV x y) 35 (Div32 x y) -> (DIVW x y) 36 (Div32u x y) -> (UDIVW x y) 37 (Div16 x y) -> (DIVW (SignExt16to32 x) (SignExt16to32 y)) 38 (Div16u x y) -> (UDIVW (ZeroExt16to32 x) (ZeroExt16to32 y)) 39 (Div8 x y) -> (DIVW (SignExt8to32 x) (SignExt8to32 y)) 40 (Div8u x y) -> (UDIVW (ZeroExt8to32 x) (ZeroExt8to32 y)) 41 (Div32F x y) -> (FDIVS x y) 42 (Div64F x y) -> (FDIVD x y) 43 44 (Mod64 x y) -> (MOD x y) 45 (Mod64u x y) -> (UMOD x y) 46 (Mod32 x y) -> (MODW x y) 47 (Mod32u x y) -> (UMODW x y) 48 (Mod16 x y) -> (MODW (SignExt16to32 x) (SignExt16to32 y)) 49 (Mod16u x y) -> (UMODW (ZeroExt16to32 x) (ZeroExt16to32 y)) 50 (Mod8 x y) -> (MODW (SignExt8to32 x) (SignExt8to32 y)) 51 (Mod8u x y) -> (UMODW (ZeroExt8to32 x) (ZeroExt8to32 y)) 52 53 // (x + y) / 2 with x>=y -> (x - y) / 2 + y 54 (Avg64u <t> x y) -> (ADD (SRLconst <t> (SUB <t> x y) [1]) y) 55 56 (And64 x y) -> (AND x y) 57 (And32 x y) -> (AND x y) 58 (And16 x y) -> (AND x y) 59 (And8 x y) -> (AND x y) 60 61 (Or64 x y) -> (OR x y) 62 (Or32 x y) -> (OR x y) 63 (Or16 x y) -> (OR x y) 64 (Or8 x y) -> (OR x y) 65 66 (Xor64 x y) -> (XOR x y) 67 (Xor32 x y) -> (XOR x y) 68 (Xor16 x y) -> (XOR x y) 69 (Xor8 x y) -> (XOR x y) 70 71 // unary ops 72 (Neg64 x) -> (NEG x) 73 (Neg32 x) -> (NEG x) 74 (Neg16 x) -> (NEG x) 75 (Neg8 x) -> (NEG x) 76 (Neg32F x) -> (FNEGS x) 77 (Neg64F x) -> (FNEGD x) 78 79 (Com64 x) -> (MVN x) 80 (Com32 x) -> (MVN x) 81 (Com16 x) -> (MVN x) 82 (Com8 x) -> (MVN x) 83 84 (Sqrt x) -> (FSQRTD x) 85 86 (Ctz64 <t> x) -> (CLZ (RBIT <t> x)) 87 (Ctz32 <t> x) -> (CLZW (RBITW <t> x)) 88 89 (BitLen64 x) -> (SUB (MOVDconst [64]) (CLZ <typ.Int> x)) 90 91 (Bswap64 x) -> (REV x) 92 (Bswap32 x) -> (REVW x) 93 94 (BitRev64 x) -> (RBIT x) 95 (BitRev32 x) -> (RBITW x) 96 (BitRev16 x) -> (SRLconst [48] (RBIT <typ.UInt64> x)) 97 (BitRev8 x) -> (SRLconst [56] (RBIT <typ.UInt64> x)) 98 99 // boolean ops -- booleans are represented with 0=false, 1=true 100 (AndB x y) -> (AND x y) 101 (OrB x y) -> (OR x y) 102 (EqB x y) -> (XOR (MOVDconst [1]) (XOR <typ.Bool> x y)) 103 (NeqB x y) -> (XOR x y) 104 (Not x) -> (XOR (MOVDconst [1]) x) 105 106 // constant shifts 107 (Lsh64x64 x (MOVDconst [c])) && uint64(c) < 64 -> (SLLconst x [c]) 108 (Rsh64x64 x (MOVDconst [c])) && uint64(c) < 64 -> (SRAconst x [c]) 109 (Rsh64Ux64 x (MOVDconst [c])) && uint64(c) < 64 -> (SRLconst x [c]) 110 (Lsh32x64 x (MOVDconst [c])) && uint64(c) < 32 -> (SLLconst x [c]) 111 (Rsh32x64 x (MOVDconst [c])) && uint64(c) < 32 -> (SRAconst (SignExt32to64 x) [c]) 112 (Rsh32Ux64 x (MOVDconst [c])) && uint64(c) < 32 -> (SRLconst (ZeroExt32to64 x) [c]) 113 (Lsh16x64 x (MOVDconst [c])) && uint64(c) < 16 -> (SLLconst x [c]) 114 (Rsh16x64 x (MOVDconst [c])) && uint64(c) < 16 -> (SRAconst (SignExt16to64 x) [c]) 115 (Rsh16Ux64 x (MOVDconst [c])) && uint64(c) < 16 -> (SRLconst (ZeroExt16to64 x) [c]) 116 (Lsh8x64 x (MOVDconst [c])) && uint64(c) < 8 -> (SLLconst x [c]) 117 (Rsh8x64 x (MOVDconst [c])) && uint64(c) < 8 -> (SRAconst (SignExt8to64 x) [c]) 118 (Rsh8Ux64 x (MOVDconst [c])) && uint64(c) < 8 -> (SRLconst (ZeroExt8to64 x) [c]) 119 120 // large constant shifts 121 (Lsh64x64 _ (MOVDconst [c])) && uint64(c) >= 64 -> (MOVDconst [0]) 122 (Rsh64Ux64 _ (MOVDconst [c])) && uint64(c) >= 64 -> (MOVDconst [0]) 123 (Lsh32x64 _ (MOVDconst [c])) && uint64(c) >= 32 -> (MOVDconst [0]) 124 (Rsh32Ux64 _ (MOVDconst [c])) && uint64(c) >= 32 -> (MOVDconst [0]) 125 (Lsh16x64 _ (MOVDconst [c])) && uint64(c) >= 16 -> (MOVDconst [0]) 126 (Rsh16Ux64 _ (MOVDconst [c])) && uint64(c) >= 16 -> (MOVDconst [0]) 127 (Lsh8x64 _ (MOVDconst [c])) && uint64(c) >= 8 -> (MOVDconst [0]) 128 (Rsh8Ux64 _ (MOVDconst [c])) && uint64(c) >= 8 -> (MOVDconst [0]) 129 130 // large constant signed right shift, we leave the sign bit 131 (Rsh64x64 x (MOVDconst [c])) && uint64(c) >= 64 -> (SRAconst x [63]) 132 (Rsh32x64 x (MOVDconst [c])) && uint64(c) >= 32 -> (SRAconst (SignExt32to64 x) [63]) 133 (Rsh16x64 x (MOVDconst [c])) && uint64(c) >= 16 -> (SRAconst (SignExt16to64 x) [63]) 134 (Rsh8x64 x (MOVDconst [c])) && uint64(c) >= 8 -> (SRAconst (SignExt8to64 x) [63]) 135 136 // shifts 137 // hardware instruction uses only the low 6 bits of the shift 138 // we compare to 64 to ensure Go semantics for large shifts 139 (Lsh64x64 <t> x y) -> (CSELULT (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) 140 (Lsh64x32 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 141 (Lsh64x16 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 142 (Lsh64x8 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 143 144 (Lsh32x64 <t> x y) -> (CSELULT (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) 145 (Lsh32x32 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 146 (Lsh32x16 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 147 (Lsh32x8 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 148 149 (Lsh16x64 <t> x y) -> (CSELULT (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) 150 (Lsh16x32 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 151 (Lsh16x16 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 152 (Lsh16x8 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 153 154 (Lsh8x64 <t> x y) -> (CSELULT (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) 155 (Lsh8x32 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 156 (Lsh8x16 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 157 (Lsh8x8 <t> x y) -> (CSELULT (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 158 159 (Rsh64Ux64 <t> x y) -> (CSELULT (SRL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) 160 (Rsh64Ux32 <t> x y) -> (CSELULT (SRL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 161 (Rsh64Ux16 <t> x y) -> (CSELULT (SRL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 162 (Rsh64Ux8 <t> x y) -> (CSELULT (SRL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 163 164 (Rsh32Ux64 <t> x y) -> (CSELULT (SRL <t> (ZeroExt32to64 x) y) (Const64 <t> [0]) (CMPconst [64] y)) 165 (Rsh32Ux32 <t> x y) -> (CSELULT (SRL <t> (ZeroExt32to64 x) (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 166 (Rsh32Ux16 <t> x y) -> (CSELULT (SRL <t> (ZeroExt32to64 x) (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 167 (Rsh32Ux8 <t> x y) -> (CSELULT (SRL <t> (ZeroExt32to64 x) (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 168 169 (Rsh16Ux64 <t> x y) -> (CSELULT (SRL <t> (ZeroExt16to64 x) y) (Const64 <t> [0]) (CMPconst [64] y)) 170 (Rsh16Ux32 <t> x y) -> (CSELULT (SRL <t> (ZeroExt16to64 x) (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 171 (Rsh16Ux16 <t> x y) -> (CSELULT (SRL <t> (ZeroExt16to64 x) (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 172 (Rsh16Ux8 <t> x y) -> (CSELULT (SRL <t> (ZeroExt16to64 x) (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 173 174 (Rsh8Ux64 <t> x y) -> (CSELULT (SRL <t> (ZeroExt8to64 x) y) (Const64 <t> [0]) (CMPconst [64] y)) 175 (Rsh8Ux32 <t> x y) -> (CSELULT (SRL <t> (ZeroExt8to64 x) (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) 176 (Rsh8Ux16 <t> x y) -> (CSELULT (SRL <t> (ZeroExt8to64 x) (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) 177 (Rsh8Ux8 <t> x y) -> (CSELULT (SRL <t> (ZeroExt8to64 x) (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) 178 179 (Rsh64x64 x y) -> (SRA x (CSELULT <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) 180 (Rsh64x32 x y) -> (SRA x (CSELULT <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) 181 (Rsh64x16 x y) -> (SRA x (CSELULT <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) 182 (Rsh64x8 x y) -> (SRA x (CSELULT <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) 183 184 (Rsh32x64 x y) -> (SRA (SignExt32to64 x) (CSELULT <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) 185 (Rsh32x32 x y) -> (SRA (SignExt32to64 x) (CSELULT <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) 186 (Rsh32x16 x y) -> (SRA (SignExt32to64 x) (CSELULT <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) 187 (Rsh32x8 x y) -> (SRA (SignExt32to64 x) (CSELULT <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) 188 189 (Rsh16x64 x y) -> (SRA (SignExt16to64 x) (CSELULT <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) 190 (Rsh16x32 x y) -> (SRA (SignExt16to64 x) (CSELULT <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) 191 (Rsh16x16 x y) -> (SRA (SignExt16to64 x) (CSELULT <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) 192 (Rsh16x8 x y) -> (SRA (SignExt16to64 x) (CSELULT <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) 193 194 (Rsh8x64 x y) -> (SRA (SignExt8to64 x) (CSELULT <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) 195 (Rsh8x32 x y) -> (SRA (SignExt8to64 x) (CSELULT <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) 196 (Rsh8x16 x y) -> (SRA (SignExt8to64 x) (CSELULT <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) 197 (Rsh8x8 x y) -> (SRA (SignExt8to64 x) (CSELULT <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) 198 199 // constants 200 (Const64 [val]) -> (MOVDconst [val]) 201 (Const32 [val]) -> (MOVDconst [val]) 202 (Const16 [val]) -> (MOVDconst [val]) 203 (Const8 [val]) -> (MOVDconst [val]) 204 (Const32F [val]) -> (FMOVSconst [val]) 205 (Const64F [val]) -> (FMOVDconst [val]) 206 (ConstNil) -> (MOVDconst [0]) 207 (ConstBool [b]) -> (MOVDconst [b]) 208 209 (Slicemask <t> x) -> (SRAconst (NEG <t> x) [63]) 210 211 // truncations 212 // Because we ignore high parts of registers, truncates are just copies. 213 (Trunc16to8 x) -> x 214 (Trunc32to8 x) -> x 215 (Trunc32to16 x) -> x 216 (Trunc64to8 x) -> x 217 (Trunc64to16 x) -> x 218 (Trunc64to32 x) -> x 219 220 // Zero-/Sign-extensions 221 (ZeroExt8to16 x) -> (MOVBUreg x) 222 (ZeroExt8to32 x) -> (MOVBUreg x) 223 (ZeroExt16to32 x) -> (MOVHUreg x) 224 (ZeroExt8to64 x) -> (MOVBUreg x) 225 (ZeroExt16to64 x) -> (MOVHUreg x) 226 (ZeroExt32to64 x) -> (MOVWUreg x) 227 228 (SignExt8to16 x) -> (MOVBreg x) 229 (SignExt8to32 x) -> (MOVBreg x) 230 (SignExt16to32 x) -> (MOVHreg x) 231 (SignExt8to64 x) -> (MOVBreg x) 232 (SignExt16to64 x) -> (MOVHreg x) 233 (SignExt32to64 x) -> (MOVWreg x) 234 235 // float <-> int conversion 236 (Cvt32to32F x) -> (SCVTFWS x) 237 (Cvt32to64F x) -> (SCVTFWD x) 238 (Cvt64to32F x) -> (SCVTFS x) 239 (Cvt64to64F x) -> (SCVTFD x) 240 (Cvt32Uto32F x) -> (UCVTFWS x) 241 (Cvt32Uto64F x) -> (UCVTFWD x) 242 (Cvt64Uto32F x) -> (UCVTFS x) 243 (Cvt64Uto64F x) -> (UCVTFD x) 244 (Cvt32Fto32 x) -> (FCVTZSSW x) 245 (Cvt64Fto32 x) -> (FCVTZSDW x) 246 (Cvt32Fto64 x) -> (FCVTZSS x) 247 (Cvt64Fto64 x) -> (FCVTZSD x) 248 (Cvt32Fto32U x) -> (FCVTZUSW x) 249 (Cvt64Fto32U x) -> (FCVTZUDW x) 250 (Cvt32Fto64U x) -> (FCVTZUS x) 251 (Cvt64Fto64U x) -> (FCVTZUD x) 252 (Cvt32Fto64F x) -> (FCVTSD x) 253 (Cvt64Fto32F x) -> (FCVTDS x) 254 255 (Round32F x) -> x 256 (Round64F x) -> x 257 258 // comparisons 259 (Eq8 x y) -> (Equal (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) 260 (Eq16 x y) -> (Equal (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) 261 (Eq32 x y) -> (Equal (CMPW x y)) 262 (Eq64 x y) -> (Equal (CMP x y)) 263 (EqPtr x y) -> (Equal (CMP x y)) 264 (Eq32F x y) -> (Equal (FCMPS x y)) 265 (Eq64F x y) -> (Equal (FCMPD x y)) 266 267 (Neq8 x y) -> (NotEqual (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) 268 (Neq16 x y) -> (NotEqual (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) 269 (Neq32 x y) -> (NotEqual (CMPW x y)) 270 (Neq64 x y) -> (NotEqual (CMP x y)) 271 (NeqPtr x y) -> (NotEqual (CMP x y)) 272 (Neq32F x y) -> (NotEqual (FCMPS x y)) 273 (Neq64F x y) -> (NotEqual (FCMPD x y)) 274 275 (Less8 x y) -> (LessThan (CMPW (SignExt8to32 x) (SignExt8to32 y))) 276 (Less16 x y) -> (LessThan (CMPW (SignExt16to32 x) (SignExt16to32 y))) 277 (Less32 x y) -> (LessThan (CMPW x y)) 278 (Less64 x y) -> (LessThan (CMP x y)) 279 (Less32F x y) -> (GreaterThan (FCMPS y x)) // reverse operands to work around NaN 280 (Less64F x y) -> (GreaterThan (FCMPD y x)) // reverse operands to work around NaN 281 282 (Less8U x y) -> (LessThanU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) 283 (Less16U x y) -> (LessThanU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) 284 (Less32U x y) -> (LessThanU (CMPW x y)) 285 (Less64U x y) -> (LessThanU (CMP x y)) 286 287 (Leq8 x y) -> (LessEqual (CMPW (SignExt8to32 x) (SignExt8to32 y))) 288 (Leq16 x y) -> (LessEqual (CMPW (SignExt16to32 x) (SignExt16to32 y))) 289 (Leq32 x y) -> (LessEqual (CMPW x y)) 290 (Leq64 x y) -> (LessEqual (CMP x y)) 291 (Leq32F x y) -> (GreaterEqual (FCMPS y x)) // reverse operands to work around NaN 292 (Leq64F x y) -> (GreaterEqual (FCMPD y x)) // reverse operands to work around NaN 293 294 (Leq8U x y) -> (LessEqualU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) 295 (Leq16U x y) -> (LessEqualU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) 296 (Leq32U x y) -> (LessEqualU (CMPW x y)) 297 (Leq64U x y) -> (LessEqualU (CMP x y)) 298 299 (Greater8 x y) -> (GreaterThan (CMPW (SignExt8to32 x) (SignExt8to32 y))) 300 (Greater16 x y) -> (GreaterThan (CMPW (SignExt16to32 x) (SignExt16to32 y))) 301 (Greater32 x y) -> (GreaterThan (CMPW x y)) 302 (Greater64 x y) -> (GreaterThan (CMP x y)) 303 (Greater32F x y) -> (GreaterThan (FCMPS x y)) 304 (Greater64F x y) -> (GreaterThan (FCMPD x y)) 305 306 (Greater8U x y) -> (GreaterThanU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) 307 (Greater16U x y) -> (GreaterThanU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) 308 (Greater32U x y) -> (GreaterThanU (CMPW x y)) 309 (Greater64U x y) -> (GreaterThanU (CMP x y)) 310 311 (Geq8 x y) -> (GreaterEqual (CMPW (SignExt8to32 x) (SignExt8to32 y))) 312 (Geq16 x y) -> (GreaterEqual (CMPW (SignExt16to32 x) (SignExt16to32 y))) 313 (Geq32 x y) -> (GreaterEqual (CMPW x y)) 314 (Geq64 x y) -> (GreaterEqual (CMP x y)) 315 (Geq32F x y) -> (GreaterEqual (FCMPS x y)) 316 (Geq64F x y) -> (GreaterEqual (FCMPD x y)) 317 318 (Geq8U x y) -> (GreaterEqualU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) 319 (Geq16U x y) -> (GreaterEqualU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) 320 (Geq32U x y) -> (GreaterEqualU (CMPW x y)) 321 (Geq64U x y) -> (GreaterEqualU (CMP x y)) 322 323 (OffPtr [off] ptr:(SP)) -> (MOVDaddr [off] ptr) 324 (OffPtr [off] ptr) -> (ADDconst [off] ptr) 325 326 (Addr {sym} base) -> (MOVDaddr {sym} base) 327 328 // loads 329 (Load <t> ptr mem) && t.IsBoolean() -> (MOVBUload ptr mem) 330 (Load <t> ptr mem) && (is8BitInt(t) && isSigned(t)) -> (MOVBload ptr mem) 331 (Load <t> ptr mem) && (is8BitInt(t) && !isSigned(t)) -> (MOVBUload ptr mem) 332 (Load <t> ptr mem) && (is16BitInt(t) && isSigned(t)) -> (MOVHload ptr mem) 333 (Load <t> ptr mem) && (is16BitInt(t) && !isSigned(t)) -> (MOVHUload ptr mem) 334 (Load <t> ptr mem) && (is32BitInt(t) && isSigned(t)) -> (MOVWload ptr mem) 335 (Load <t> ptr mem) && (is32BitInt(t) && !isSigned(t)) -> (MOVWUload ptr mem) 336 (Load <t> ptr mem) && (is64BitInt(t) || isPtr(t)) -> (MOVDload ptr mem) 337 (Load <t> ptr mem) && is32BitFloat(t) -> (FMOVSload ptr mem) 338 (Load <t> ptr mem) && is64BitFloat(t) -> (FMOVDload ptr mem) 339 340 // stores 341 (Store {t} ptr val mem) && t.(*types.Type).Size() == 1 -> (MOVBstore ptr val mem) 342 (Store {t} ptr val mem) && t.(*types.Type).Size() == 2 -> (MOVHstore ptr val mem) 343 (Store {t} ptr val mem) && t.(*types.Type).Size() == 4 && !is32BitFloat(val.Type) -> (MOVWstore ptr val mem) 344 (Store {t} ptr val mem) && t.(*types.Type).Size() == 8 && !is64BitFloat(val.Type) -> (MOVDstore ptr val mem) 345 (Store {t} ptr val mem) && t.(*types.Type).Size() == 4 && is32BitFloat(val.Type) -> (FMOVSstore ptr val mem) 346 (Store {t} ptr val mem) && t.(*types.Type).Size() == 8 && is64BitFloat(val.Type) -> (FMOVDstore ptr val mem) 347 348 // zeroing 349 (Zero [0] _ mem) -> mem 350 (Zero [1] ptr mem) -> (MOVBstore ptr (MOVDconst [0]) mem) 351 (Zero [2] ptr mem) -> (MOVHstore ptr (MOVDconst [0]) mem) 352 (Zero [4] ptr mem) -> (MOVWstore ptr (MOVDconst [0]) mem) 353 (Zero [8] ptr mem) -> (MOVDstore ptr (MOVDconst [0]) mem) 354 355 (Zero [3] ptr mem) -> 356 (MOVBstore [2] ptr (MOVDconst [0]) 357 (MOVHstore ptr (MOVDconst [0]) mem)) 358 (Zero [5] ptr mem) -> 359 (MOVBstore [4] ptr (MOVDconst [0]) 360 (MOVWstore ptr (MOVDconst [0]) mem)) 361 (Zero [6] ptr mem) -> 362 (MOVHstore [4] ptr (MOVDconst [0]) 363 (MOVWstore ptr (MOVDconst [0]) mem)) 364 (Zero [7] ptr mem) -> 365 (MOVBstore [6] ptr (MOVDconst [0]) 366 (MOVHstore [4] ptr (MOVDconst [0]) 367 (MOVWstore ptr (MOVDconst [0]) mem))) 368 (Zero [12] ptr mem) -> 369 (MOVWstore [8] ptr (MOVDconst [0]) 370 (MOVDstore ptr (MOVDconst [0]) mem)) 371 (Zero [16] ptr mem) -> 372 (MOVDstore [8] ptr (MOVDconst [0]) 373 (MOVDstore ptr (MOVDconst [0]) mem)) 374 (Zero [24] ptr mem) -> 375 (MOVDstore [16] ptr (MOVDconst [0]) 376 (MOVDstore [8] ptr (MOVDconst [0]) 377 (MOVDstore ptr (MOVDconst [0]) mem))) 378 379 // strip off fractional word zeroing 380 (Zero [s] ptr mem) && s%8 != 0 && s > 8 -> 381 (Zero [s%8] 382 (OffPtr <ptr.Type> ptr [s-s%8]) 383 (Zero [s-s%8] ptr mem)) 384 385 // medium zeroing uses a duff device 386 // 4, 8, and 128 are magic constants, see runtime/mkduff.go 387 (Zero [s] ptr mem) 388 && s%8 == 0 && s > 24 && s <= 8*128 389 && !config.noDuffDevice -> 390 (DUFFZERO [4 * (128 - int64(s/8))] ptr mem) 391 392 // large zeroing uses a loop 393 (Zero [s] ptr mem) 394 && s%8 == 0 && (s > 8*128 || config.noDuffDevice) -> 395 (LoweredZero 396 ptr 397 (ADDconst <ptr.Type> [s-8] ptr) 398 mem) 399 400 // moves 401 (Move [0] _ _ mem) -> mem 402 (Move [1] dst src mem) -> (MOVBstore dst (MOVBUload src mem) mem) 403 (Move [2] dst src mem) -> (MOVHstore dst (MOVHUload src mem) mem) 404 (Move [4] dst src mem) -> (MOVWstore dst (MOVWUload src mem) mem) 405 (Move [8] dst src mem) -> (MOVDstore dst (MOVDload src mem) mem) 406 407 (Move [3] dst src mem) -> 408 (MOVBstore [2] dst (MOVBUload [2] src mem) 409 (MOVHstore dst (MOVHUload src mem) mem)) 410 (Move [5] dst src mem) -> 411 (MOVBstore [4] dst (MOVBUload [4] src mem) 412 (MOVWstore dst (MOVWUload src mem) mem)) 413 (Move [6] dst src mem) -> 414 (MOVHstore [4] dst (MOVHUload [4] src mem) 415 (MOVWstore dst (MOVWUload src mem) mem)) 416 (Move [7] dst src mem) -> 417 (MOVBstore [6] dst (MOVBUload [6] src mem) 418 (MOVHstore [4] dst (MOVHUload [4] src mem) 419 (MOVWstore dst (MOVWUload src mem) mem))) 420 (Move [12] dst src mem) -> 421 (MOVWstore [8] dst (MOVWUload [8] src mem) 422 (MOVDstore dst (MOVDload src mem) mem)) 423 (Move [16] dst src mem) -> 424 (MOVDstore [8] dst (MOVDload [8] src mem) 425 (MOVDstore dst (MOVDload src mem) mem)) 426 (Move [24] dst src mem) -> 427 (MOVDstore [16] dst (MOVDload [16] src mem) 428 (MOVDstore [8] dst (MOVDload [8] src mem) 429 (MOVDstore dst (MOVDload src mem) mem))) 430 431 // strip off fractional word move 432 (Move [s] dst src mem) && s%8 != 0 && s > 8 -> 433 (Move [s%8] 434 (OffPtr <dst.Type> dst [s-s%8]) 435 (OffPtr <src.Type> src [s-s%8]) 436 (Move [s-s%8] dst src mem)) 437 438 // medium move uses a duff device 439 // 8 and 128 are magic constants, see runtime/mkduff.go 440 (Move [s] dst src mem) 441 && s%8 == 0 && s > 24 && s <= 8*128 442 && !config.noDuffDevice -> 443 (DUFFCOPY [8 * (128 - int64(s/8))] dst src mem) 444 445 // large move uses a loop 446 (Move [s] dst src mem) 447 && s > 24 && s%8 == 0 -> 448 (LoweredMove 449 dst 450 src 451 (ADDconst <src.Type> src [s-8]) 452 mem) 453 454 // calls 455 (StaticCall [argwid] {target} mem) -> (CALLstatic [argwid] {target} mem) 456 (ClosureCall [argwid] entry closure mem) -> (CALLclosure [argwid] entry closure mem) 457 (InterCall [argwid] entry mem) -> (CALLinter [argwid] entry mem) 458 459 // checks 460 (NilCheck ptr mem) -> (LoweredNilCheck ptr mem) 461 (IsNonNil ptr) -> (NotEqual (CMPconst [0] ptr)) 462 (IsInBounds idx len) -> (LessThanU (CMP idx len)) 463 (IsSliceInBounds idx len) -> (LessEqualU (CMP idx len)) 464 465 // pseudo-ops 466 (GetClosurePtr) -> (LoweredGetClosurePtr) 467 (Convert x mem) -> (MOVDconvert x mem) 468 469 // Absorb pseudo-ops into blocks. 470 (If (Equal cc) yes no) -> (EQ cc yes no) 471 (If (NotEqual cc) yes no) -> (NE cc yes no) 472 (If (LessThan cc) yes no) -> (LT cc yes no) 473 (If (LessThanU cc) yes no) -> (ULT cc yes no) 474 (If (LessEqual cc) yes no) -> (LE cc yes no) 475 (If (LessEqualU cc) yes no) -> (ULE cc yes no) 476 (If (GreaterThan cc) yes no) -> (GT cc yes no) 477 (If (GreaterThanU cc) yes no) -> (UGT cc yes no) 478 (If (GreaterEqual cc) yes no) -> (GE cc yes no) 479 (If (GreaterEqualU cc) yes no) -> (UGE cc yes no) 480 481 (If cond yes no) -> (NZ cond yes no) 482 483 // atomic intrinsics 484 // Note: these ops do not accept offset. 485 (AtomicLoad32 ptr mem) -> (LDARW ptr mem) 486 (AtomicLoad64 ptr mem) -> (LDAR ptr mem) 487 (AtomicLoadPtr ptr mem) -> (LDAR ptr mem) 488 489 (AtomicStore32 ptr val mem) -> (STLRW ptr val mem) 490 (AtomicStore64 ptr val mem) -> (STLR ptr val mem) 491 (AtomicStorePtrNoWB ptr val mem) -> (STLR ptr val mem) 492 493 (AtomicExchange32 ptr val mem) -> (LoweredAtomicExchange32 ptr val mem) 494 (AtomicExchange64 ptr val mem) -> (LoweredAtomicExchange64 ptr val mem) 495 496 (AtomicAdd32 ptr val mem) -> (LoweredAtomicAdd32 ptr val mem) 497 (AtomicAdd64 ptr val mem) -> (LoweredAtomicAdd64 ptr val mem) 498 499 (AtomicCompareAndSwap32 ptr old new_ mem) -> (LoweredAtomicCas32 ptr old new_ mem) 500 (AtomicCompareAndSwap64 ptr old new_ mem) -> (LoweredAtomicCas64 ptr old new_ mem) 501 502 (AtomicAnd8 ptr val mem) -> (LoweredAtomicAnd8 ptr val mem) 503 (AtomicOr8 ptr val mem) -> (LoweredAtomicOr8 ptr val mem) 504 505 // Optimizations 506 507 // Absorb boolean tests into block 508 (NZ (Equal cc) yes no) -> (EQ cc yes no) 509 (NZ (NotEqual cc) yes no) -> (NE cc yes no) 510 (NZ (LessThan cc) yes no) -> (LT cc yes no) 511 (NZ (LessThanU cc) yes no) -> (ULT cc yes no) 512 (NZ (LessEqual cc) yes no) -> (LE cc yes no) 513 (NZ (LessEqualU cc) yes no) -> (ULE cc yes no) 514 (NZ (GreaterThan cc) yes no) -> (GT cc yes no) 515 (NZ (GreaterThanU cc) yes no) -> (UGT cc yes no) 516 (NZ (GreaterEqual cc) yes no) -> (GE cc yes no) 517 (NZ (GreaterEqualU cc) yes no) -> (UGE cc yes no) 518 519 (EQ (CMPconst [0] x) yes no) -> (Z x yes no) 520 (NE (CMPconst [0] x) yes no) -> (NZ x yes no) 521 (EQ (CMPWconst [0] x) yes no) -> (ZW x yes no) 522 (NE (CMPWconst [0] x) yes no) -> (NZW x yes no) 523 524 // Absorb bit-tests into block 525 (Z (ANDconst [c] x) yes no) && oneBit(c) -> (TBZ {ntz(c)} x yes no) 526 (NZ (ANDconst [c] x) yes no) && oneBit(c) -> (TBNZ {ntz(c)} x yes no) 527 (ZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBZ {ntz(int64(uint32(c)))} x yes no) 528 (NZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) -> (TBNZ {ntz(int64(uint32(c)))} x yes no) 529 530 // fold offset into address 531 (ADDconst [off1] (MOVDaddr [off2] {sym} ptr)) -> (MOVDaddr [off1+off2] {sym} ptr) 532 533 // fold address into load/store 534 (MOVBload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 535 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 536 (MOVBload [off1+off2] {sym} ptr mem) 537 (MOVBUload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 538 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 539 (MOVBUload [off1+off2] {sym} ptr mem) 540 (MOVHload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 541 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 542 (MOVHload [off1+off2] {sym} ptr mem) 543 (MOVHUload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 544 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 545 (MOVHUload [off1+off2] {sym} ptr mem) 546 (MOVWload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 547 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 548 (MOVWload [off1+off2] {sym} ptr mem) 549 (MOVWUload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 550 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 551 (MOVWUload [off1+off2] {sym} ptr mem) 552 (MOVDload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 553 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 554 (MOVDload [off1+off2] {sym} ptr mem) 555 (FMOVSload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 556 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 557 (FMOVSload [off1+off2] {sym} ptr mem) 558 (FMOVDload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 559 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 560 (FMOVDload [off1+off2] {sym} ptr mem) 561 562 (MOVBstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(off1+off2) 563 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 564 (MOVBstore [off1+off2] {sym} ptr val mem) 565 (MOVHstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(off1+off2) 566 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 567 (MOVHstore [off1+off2] {sym} ptr val mem) 568 (MOVWstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(off1+off2) 569 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 570 (MOVWstore [off1+off2] {sym} ptr val mem) 571 (MOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(off1+off2) 572 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 573 (MOVDstore [off1+off2] {sym} ptr val mem) 574 (FMOVSstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(off1+off2) 575 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 576 (FMOVSstore [off1+off2] {sym} ptr val mem) 577 (FMOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(off1+off2) 578 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 579 (FMOVDstore [off1+off2] {sym} ptr val mem) 580 (MOVBstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 581 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 582 (MOVBstorezero [off1+off2] {sym} ptr mem) 583 (MOVHstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 584 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 585 (MOVHstorezero [off1+off2] {sym} ptr mem) 586 (MOVWstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 587 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 588 (MOVWstorezero [off1+off2] {sym} ptr mem) 589 (MOVDstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(off1+off2) 590 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 591 (MOVDstorezero [off1+off2] {sym} ptr mem) 592 593 (MOVBload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 594 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 595 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 596 (MOVBload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 597 (MOVBUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 598 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 599 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 600 (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 601 (MOVHload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 602 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 603 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 604 (MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 605 (MOVHUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 606 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 607 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 608 (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 609 (MOVWload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 610 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 611 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 612 (MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 613 (MOVWUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 614 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 615 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 616 (MOVWUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 617 (MOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 618 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 619 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 620 (MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 621 (FMOVSload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 622 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 623 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 624 (FMOVSload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 625 (FMOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 626 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 627 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 628 (FMOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 629 630 (MOVBstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) 631 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 632 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 633 (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 634 (MOVHstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) 635 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 636 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 637 (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 638 (MOVWstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) 639 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 640 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 641 (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 642 (MOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) 643 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 644 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 645 (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 646 (FMOVSstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) 647 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 648 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 649 (FMOVSstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 650 (FMOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) 651 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 652 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 653 (FMOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) 654 (MOVBstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 655 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 656 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 657 (MOVBstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 658 (MOVHstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 659 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 660 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 661 (MOVHstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 662 (MOVWstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 663 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 664 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 665 (MOVWstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 666 (MOVDstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) 667 && canMergeSym(sym1,sym2) && is32Bit(off1+off2) 668 && (ptr.Op != OpSB || !config.ctxt.Flag_shared) -> 669 (MOVDstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) 670 671 // store zero 672 (MOVBstore [off] {sym} ptr (MOVDconst [0]) mem) -> (MOVBstorezero [off] {sym} ptr mem) 673 (MOVHstore [off] {sym} ptr (MOVDconst [0]) mem) -> (MOVHstorezero [off] {sym} ptr mem) 674 (MOVWstore [off] {sym} ptr (MOVDconst [0]) mem) -> (MOVWstorezero [off] {sym} ptr mem) 675 (MOVDstore [off] {sym} ptr (MOVDconst [0]) mem) -> (MOVDstorezero [off] {sym} ptr mem) 676 677 // replace load from same location as preceding store with zero/sign extension (or copy in case of full width) 678 // these seem to have bad interaction with other rules, resulting in slower code 679 //(MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVBreg x) 680 //(MOVBUload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVBUreg x) 681 //(MOVHload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVHreg x) 682 //(MOVHUload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVHUreg x) 683 //(MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVWreg x) 684 //(MOVWUload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVWUreg x) 685 //(MOVDload [off] {sym} ptr (MOVDstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x 686 //(FMOVSload [off] {sym} ptr (FMOVSstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x 687 //(FMOVDload [off] {sym} ptr (FMOVDstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x 688 689 (MOVBload [off] {sym} ptr (MOVBstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDconst [0]) 690 (MOVBUload [off] {sym} ptr (MOVBstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDconst [0]) 691 (MOVHload [off] {sym} ptr (MOVHstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDconst [0]) 692 (MOVHUload [off] {sym} ptr (MOVHstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDconst [0]) 693 (MOVWload [off] {sym} ptr (MOVWstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDconst [0]) 694 (MOVWUload [off] {sym} ptr (MOVWstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDconst [0]) 695 (MOVDload [off] {sym} ptr (MOVDstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDconst [0]) 696 697 // don't extend after proper load 698 (MOVBreg x:(MOVBload _ _)) -> (MOVDreg x) 699 (MOVBUreg x:(MOVBUload _ _)) -> (MOVDreg x) 700 (MOVHreg x:(MOVBload _ _)) -> (MOVDreg x) 701 (MOVHreg x:(MOVBUload _ _)) -> (MOVDreg x) 702 (MOVHreg x:(MOVHload _ _)) -> (MOVDreg x) 703 (MOVHUreg x:(MOVBUload _ _)) -> (MOVDreg x) 704 (MOVHUreg x:(MOVHUload _ _)) -> (MOVDreg x) 705 (MOVWreg x:(MOVBload _ _)) -> (MOVDreg x) 706 (MOVWreg x:(MOVBUload _ _)) -> (MOVDreg x) 707 (MOVWreg x:(MOVHload _ _)) -> (MOVDreg x) 708 (MOVWreg x:(MOVHUload _ _)) -> (MOVDreg x) 709 (MOVWreg x:(MOVWload _ _)) -> (MOVDreg x) 710 (MOVWUreg x:(MOVBUload _ _)) -> (MOVDreg x) 711 (MOVWUreg x:(MOVHUload _ _)) -> (MOVDreg x) 712 (MOVWUreg x:(MOVWUload _ _)) -> (MOVDreg x) 713 714 // fold double extensions 715 (MOVBreg x:(MOVBreg _)) -> (MOVDreg x) 716 (MOVBUreg x:(MOVBUreg _)) -> (MOVDreg x) 717 (MOVHreg x:(MOVBreg _)) -> (MOVDreg x) 718 (MOVHreg x:(MOVBUreg _)) -> (MOVDreg x) 719 (MOVHreg x:(MOVHreg _)) -> (MOVDreg x) 720 (MOVHUreg x:(MOVBUreg _)) -> (MOVDreg x) 721 (MOVHUreg x:(MOVHUreg _)) -> (MOVDreg x) 722 (MOVWreg x:(MOVBreg _)) -> (MOVDreg x) 723 (MOVWreg x:(MOVBUreg _)) -> (MOVDreg x) 724 (MOVWreg x:(MOVHreg _)) -> (MOVDreg x) 725 (MOVWreg x:(MOVHreg _)) -> (MOVDreg x) 726 (MOVWreg x:(MOVWreg _)) -> (MOVDreg x) 727 (MOVWUreg x:(MOVBUreg _)) -> (MOVDreg x) 728 (MOVWUreg x:(MOVHUreg _)) -> (MOVDreg x) 729 (MOVWUreg x:(MOVWUreg _)) -> (MOVDreg x) 730 731 // don't extend before store 732 (MOVBstore [off] {sym} ptr (MOVBreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 733 (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 734 (MOVBstore [off] {sym} ptr (MOVHreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 735 (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 736 (MOVBstore [off] {sym} ptr (MOVWreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 737 (MOVBstore [off] {sym} ptr (MOVWUreg x) mem) -> (MOVBstore [off] {sym} ptr x mem) 738 (MOVHstore [off] {sym} ptr (MOVHreg x) mem) -> (MOVHstore [off] {sym} ptr x mem) 739 (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) -> (MOVHstore [off] {sym} ptr x mem) 740 (MOVHstore [off] {sym} ptr (MOVWreg x) mem) -> (MOVHstore [off] {sym} ptr x mem) 741 (MOVHstore [off] {sym} ptr (MOVWUreg x) mem) -> (MOVHstore [off] {sym} ptr x mem) 742 (MOVWstore [off] {sym} ptr (MOVWreg x) mem) -> (MOVWstore [off] {sym} ptr x mem) 743 (MOVWstore [off] {sym} ptr (MOVWUreg x) mem) -> (MOVWstore [off] {sym} ptr x mem) 744 745 // if a register move has only 1 use, just use the same register without emitting instruction 746 // MOVDnop doesn't emit instruction, only for ensuring the type. 747 (MOVDreg x) && x.Uses == 1 -> (MOVDnop x) 748 749 // fold constant into arithmatic ops 750 (ADD x (MOVDconst [c])) -> (ADDconst [c] x) 751 (SUB x (MOVDconst [c])) -> (SUBconst [c] x) 752 (AND x (MOVDconst [c])) -> (ANDconst [c] x) 753 (OR x (MOVDconst [c])) -> (ORconst [c] x) 754 (XOR x (MOVDconst [c])) -> (XORconst [c] x) 755 (BIC x (MOVDconst [c])) -> (BICconst [c] x) 756 757 (SLL x (MOVDconst [c])) -> (SLLconst x [c&63]) // Note: I don't think we ever generate bad constant shifts (i.e. c>=64) 758 (SRL x (MOVDconst [c])) -> (SRLconst x [c&63]) 759 (SRA x (MOVDconst [c])) -> (SRAconst x [c&63]) 760 761 (CMP x (MOVDconst [c])) -> (CMPconst [c] x) 762 (CMP (MOVDconst [c]) x) -> (InvertFlags (CMPconst [c] x)) 763 (CMPW x (MOVDconst [c])) -> (CMPWconst [int64(int32(c))] x) 764 (CMPW (MOVDconst [c]) x) -> (InvertFlags (CMPWconst [int64(int32(c))] x)) 765 766 // mul by constant 767 (MUL x (MOVDconst [-1])) -> (NEG x) 768 (MUL _ (MOVDconst [0])) -> (MOVDconst [0]) 769 (MUL x (MOVDconst [1])) -> x 770 (MUL x (MOVDconst [c])) && isPowerOfTwo(c) -> (SLLconst [log2(c)] x) 771 (MUL x (MOVDconst [c])) && isPowerOfTwo(c-1) && c >= 3 -> (ADDshiftLL x x [log2(c-1)]) 772 (MUL x (MOVDconst [c])) && isPowerOfTwo(c+1) && c >= 7 -> (ADDshiftLL (NEG <x.Type> x) x [log2(c+1)]) 773 (MUL x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo(c/3) -> (SLLconst [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) 774 (MUL x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo(c/5) -> (SLLconst [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) 775 (MUL x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo(c/7) -> (SLLconst [log2(c/7)] (ADDshiftLL <x.Type> (NEG <x.Type> x) x [3])) 776 (MUL x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo(c/9) -> (SLLconst [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) 777 778 (MULW x (MOVDconst [c])) && int32(c)==-1 -> (NEG x) 779 (MULW _ (MOVDconst [c])) && int32(c)==0 -> (MOVDconst [0]) 780 (MULW x (MOVDconst [c])) && int32(c)==1 -> x 781 (MULW x (MOVDconst [c])) && isPowerOfTwo(c) -> (SLLconst [log2(c)] x) 782 (MULW x (MOVDconst [c])) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (ADDshiftLL x x [log2(c-1)]) 783 (MULW x (MOVDconst [c])) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (ADDshiftLL (NEG <x.Type> x) x [log2(c+1)]) 784 (MULW x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (SLLconst [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) 785 (MULW x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (SLLconst [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) 786 (MULW x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (SLLconst [log2(c/7)] (ADDshiftLL <x.Type> (NEG <x.Type> x) x [3])) 787 (MULW x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (SLLconst [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) 788 789 // div by constant 790 (UDIV x (MOVDconst [1])) -> x 791 (UDIV x (MOVDconst [c])) && isPowerOfTwo(c) -> (SRLconst [log2(c)] x) 792 (UDIVW x (MOVDconst [c])) && uint32(c)==1 -> x 793 (UDIVW x (MOVDconst [c])) && isPowerOfTwo(c) && is32Bit(c) -> (SRLconst [log2(c)] x) 794 (UMOD _ (MOVDconst [1])) -> (MOVDconst [0]) 795 (UMOD x (MOVDconst [c])) && isPowerOfTwo(c) -> (ANDconst [c-1] x) 796 (UMODW _ (MOVDconst [c])) && uint32(c)==1 -> (MOVDconst [0]) 797 (UMODW x (MOVDconst [c])) && isPowerOfTwo(c) && is32Bit(c) -> (ANDconst [c-1] x) 798 799 // generic simplifications 800 (ADD x (NEG y)) -> (SUB x y) 801 (SUB x x) -> (MOVDconst [0]) 802 (AND x x) -> x 803 (OR x x) -> x 804 (XOR x x) -> (MOVDconst [0]) 805 (BIC x x) -> (MOVDconst [0]) 806 (AND x (MVN y)) -> (BIC x y) 807 (CSELULT x (MOVDconst [0]) flag) -> (CSELULT0 x flag) 808 (SUB x (SUB y z)) -> (SUB (ADD <v.Type> x z) y) 809 (SUB (SUB x y) z) -> (SUB x (ADD <y.Type> y z)) 810 811 // remove redundant *const ops 812 (ADDconst [0] x) -> x 813 (SUBconst [0] x) -> x 814 (ANDconst [0] _) -> (MOVDconst [0]) 815 (ANDconst [-1] x) -> x 816 (ORconst [0] x) -> x 817 (ORconst [-1] _) -> (MOVDconst [-1]) 818 (XORconst [0] x) -> x 819 (XORconst [-1] x) -> (MVN x) 820 (BICconst [0] x) -> x 821 (BICconst [-1] _) -> (MOVDconst [0]) 822 823 // generic constant folding 824 (ADDconst [c] (MOVDconst [d])) -> (MOVDconst [c+d]) 825 (ADDconst [c] (ADDconst [d] x)) -> (ADDconst [c+d] x) 826 (ADDconst [c] (SUBconst [d] x)) -> (ADDconst [c-d] x) 827 (SUBconst [c] (MOVDconst [d])) -> (MOVDconst [d-c]) 828 (SUBconst [c] (SUBconst [d] x)) -> (ADDconst [-c-d] x) 829 (SUBconst [c] (ADDconst [d] x)) -> (ADDconst [-c+d] x) 830 (SLLconst [c] (MOVDconst [d])) -> (MOVDconst [int64(d)<<uint64(c)]) 831 (SRLconst [c] (MOVDconst [d])) -> (MOVDconst [int64(uint64(d)>>uint64(c))]) 832 (SRAconst [c] (MOVDconst [d])) -> (MOVDconst [int64(d)>>uint64(c)]) 833 (MUL (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [c*d]) 834 (MULW (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(int32(c)*int32(d))]) 835 (DIV (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(c)/int64(d)]) 836 (UDIV (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(uint64(c)/uint64(d))]) 837 (DIVW (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(int32(c)/int32(d))]) 838 (UDIVW (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(uint32(c)/uint32(d))]) 839 (MOD (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(c)%int64(d)]) 840 (UMOD (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(uint64(c)%uint64(d))]) 841 (MODW (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(int32(c)%int32(d))]) 842 (UMODW (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [int64(uint32(c)%uint32(d))]) 843 (ANDconst [c] (MOVDconst [d])) -> (MOVDconst [c&d]) 844 (ANDconst [c] (ANDconst [d] x)) -> (ANDconst [c&d] x) 845 (ORconst [c] (MOVDconst [d])) -> (MOVDconst [c|d]) 846 (ORconst [c] (ORconst [d] x)) -> (ORconst [c|d] x) 847 (XORconst [c] (MOVDconst [d])) -> (MOVDconst [c^d]) 848 (XORconst [c] (XORconst [d] x)) -> (XORconst [c^d] x) 849 (BICconst [c] (MOVDconst [d])) -> (MOVDconst [d&^c]) 850 (MVN (MOVDconst [c])) -> (MOVDconst [^c]) 851 (NEG (MOVDconst [c])) -> (MOVDconst [-c]) 852 (MOVBreg (MOVDconst [c])) -> (MOVDconst [int64(int8(c))]) 853 (MOVBUreg (MOVDconst [c])) -> (MOVDconst [int64(uint8(c))]) 854 (MOVHreg (MOVDconst [c])) -> (MOVDconst [int64(int16(c))]) 855 (MOVHUreg (MOVDconst [c])) -> (MOVDconst [int64(uint16(c))]) 856 (MOVWreg (MOVDconst [c])) -> (MOVDconst [int64(int32(c))]) 857 (MOVWUreg (MOVDconst [c])) -> (MOVDconst [int64(uint32(c))]) 858 (MOVDreg (MOVDconst [c])) -> (MOVDconst [c]) 859 860 // constant comparisons 861 (CMPconst (MOVDconst [x]) [y]) && x==y -> (FlagEQ) 862 (CMPconst (MOVDconst [x]) [y]) && int64(x)<int64(y) && uint64(x)<uint64(y) -> (FlagLT_ULT) 863 (CMPconst (MOVDconst [x]) [y]) && int64(x)<int64(y) && uint64(x)>uint64(y) -> (FlagLT_UGT) 864 (CMPconst (MOVDconst [x]) [y]) && int64(x)>int64(y) && uint64(x)<uint64(y) -> (FlagGT_ULT) 865 (CMPconst (MOVDconst [x]) [y]) && int64(x)>int64(y) && uint64(x)>uint64(y) -> (FlagGT_UGT) 866 (CMPWconst (MOVDconst [x]) [y]) && int32(x)==int32(y) -> (FlagEQ) 867 (CMPWconst (MOVDconst [x]) [y]) && int32(x)<int32(y) && uint32(x)<uint32(y) -> (FlagLT_ULT) 868 (CMPWconst (MOVDconst [x]) [y]) && int32(x)<int32(y) && uint32(x)>uint32(y) -> (FlagLT_UGT) 869 (CMPWconst (MOVDconst [x]) [y]) && int32(x)>int32(y) && uint32(x)<uint32(y) -> (FlagGT_ULT) 870 (CMPWconst (MOVDconst [x]) [y]) && int32(x)>int32(y) && uint32(x)>uint32(y) -> (FlagGT_UGT) 871 872 // other known comparisons 873 (CMPconst (MOVBUreg _) [c]) && 0xff < c -> (FlagLT_ULT) 874 (CMPconst (MOVHUreg _) [c]) && 0xffff < c -> (FlagLT_ULT) 875 (CMPconst (MOVWUreg _) [c]) && 0xffffffff < c -> (FlagLT_ULT) 876 (CMPconst (ANDconst _ [m]) [n]) && 0 <= m && m < n -> (FlagLT_ULT) 877 (CMPconst (SRLconst _ [c]) [n]) && 0 <= n && 0 < c && c <= 63 && (1<<uint64(64-c)) <= uint64(n) -> (FlagLT_ULT) 878 (CMPWconst (MOVBUreg _) [c]) && 0xff < int32(c) -> (FlagLT_ULT) 879 (CMPWconst (MOVHUreg _) [c]) && 0xffff < int32(c) -> (FlagLT_ULT) 880 881 // absorb flag constants into branches 882 (EQ (FlagEQ) yes no) -> (First nil yes no) 883 (EQ (FlagLT_ULT) yes no) -> (First nil no yes) 884 (EQ (FlagLT_UGT) yes no) -> (First nil no yes) 885 (EQ (FlagGT_ULT) yes no) -> (First nil no yes) 886 (EQ (FlagGT_UGT) yes no) -> (First nil no yes) 887 888 (NE (FlagEQ) yes no) -> (First nil no yes) 889 (NE (FlagLT_ULT) yes no) -> (First nil yes no) 890 (NE (FlagLT_UGT) yes no) -> (First nil yes no) 891 (NE (FlagGT_ULT) yes no) -> (First nil yes no) 892 (NE (FlagGT_UGT) yes no) -> (First nil yes no) 893 894 (LT (FlagEQ) yes no) -> (First nil no yes) 895 (LT (FlagLT_ULT) yes no) -> (First nil yes no) 896 (LT (FlagLT_UGT) yes no) -> (First nil yes no) 897 (LT (FlagGT_ULT) yes no) -> (First nil no yes) 898 (LT (FlagGT_UGT) yes no) -> (First nil no yes) 899 900 (LE (FlagEQ) yes no) -> (First nil yes no) 901 (LE (FlagLT_ULT) yes no) -> (First nil yes no) 902 (LE (FlagLT_UGT) yes no) -> (First nil yes no) 903 (LE (FlagGT_ULT) yes no) -> (First nil no yes) 904 (LE (FlagGT_UGT) yes no) -> (First nil no yes) 905 906 (GT (FlagEQ) yes no) -> (First nil no yes) 907 (GT (FlagLT_ULT) yes no) -> (First nil no yes) 908 (GT (FlagLT_UGT) yes no) -> (First nil no yes) 909 (GT (FlagGT_ULT) yes no) -> (First nil yes no) 910 (GT (FlagGT_UGT) yes no) -> (First nil yes no) 911 912 (GE (FlagEQ) yes no) -> (First nil yes no) 913 (GE (FlagLT_ULT) yes no) -> (First nil no yes) 914 (GE (FlagLT_UGT) yes no) -> (First nil no yes) 915 (GE (FlagGT_ULT) yes no) -> (First nil yes no) 916 (GE (FlagGT_UGT) yes no) -> (First nil yes no) 917 918 (ULT (FlagEQ) yes no) -> (First nil no yes) 919 (ULT (FlagLT_ULT) yes no) -> (First nil yes no) 920 (ULT (FlagLT_UGT) yes no) -> (First nil no yes) 921 (ULT (FlagGT_ULT) yes no) -> (First nil yes no) 922 (ULT (FlagGT_UGT) yes no) -> (First nil no yes) 923 924 (ULE (FlagEQ) yes no) -> (First nil yes no) 925 (ULE (FlagLT_ULT) yes no) -> (First nil yes no) 926 (ULE (FlagLT_UGT) yes no) -> (First nil no yes) 927 (ULE (FlagGT_ULT) yes no) -> (First nil yes no) 928 (ULE (FlagGT_UGT) yes no) -> (First nil no yes) 929 930 (UGT (FlagEQ) yes no) -> (First nil no yes) 931 (UGT (FlagLT_ULT) yes no) -> (First nil no yes) 932 (UGT (FlagLT_UGT) yes no) -> (First nil yes no) 933 (UGT (FlagGT_ULT) yes no) -> (First nil no yes) 934 (UGT (FlagGT_UGT) yes no) -> (First nil yes no) 935 936 (UGE (FlagEQ) yes no) -> (First nil yes no) 937 (UGE (FlagLT_ULT) yes no) -> (First nil no yes) 938 (UGE (FlagLT_UGT) yes no) -> (First nil yes no) 939 (UGE (FlagGT_ULT) yes no) -> (First nil no yes) 940 (UGE (FlagGT_UGT) yes no) -> (First nil yes no) 941 942 (Z (MOVDconst [0]) yes no) -> (First nil yes no) 943 (Z (MOVDconst [c]) yes no) && c != 0 -> (First nil no yes) 944 (NZ (MOVDconst [0]) yes no) -> (First nil no yes) 945 (NZ (MOVDconst [c]) yes no) && c != 0 -> (First nil yes no) 946 (ZW (MOVDconst [c]) yes no) && int32(c) == 0 -> (First nil yes no) 947 (ZW (MOVDconst [c]) yes no) && int32(c) != 0 -> (First nil no yes) 948 (NZW (MOVDconst [c]) yes no) && int32(c) == 0 -> (First nil no yes) 949 (NZW (MOVDconst [c]) yes no) && int32(c) != 0 -> (First nil yes no) 950 951 // absorb InvertFlags into branches 952 (LT (InvertFlags cmp) yes no) -> (GT cmp yes no) 953 (GT (InvertFlags cmp) yes no) -> (LT cmp yes no) 954 (LE (InvertFlags cmp) yes no) -> (GE cmp yes no) 955 (GE (InvertFlags cmp) yes no) -> (LE cmp yes no) 956 (ULT (InvertFlags cmp) yes no) -> (UGT cmp yes no) 957 (UGT (InvertFlags cmp) yes no) -> (ULT cmp yes no) 958 (ULE (InvertFlags cmp) yes no) -> (UGE cmp yes no) 959 (UGE (InvertFlags cmp) yes no) -> (ULE cmp yes no) 960 (EQ (InvertFlags cmp) yes no) -> (EQ cmp yes no) 961 (NE (InvertFlags cmp) yes no) -> (NE cmp yes no) 962 963 // absorb flag constants into boolean values 964 (Equal (FlagEQ)) -> (MOVDconst [1]) 965 (Equal (FlagLT_ULT)) -> (MOVDconst [0]) 966 (Equal (FlagLT_UGT)) -> (MOVDconst [0]) 967 (Equal (FlagGT_ULT)) -> (MOVDconst [0]) 968 (Equal (FlagGT_UGT)) -> (MOVDconst [0]) 969 970 (NotEqual (FlagEQ)) -> (MOVDconst [0]) 971 (NotEqual (FlagLT_ULT)) -> (MOVDconst [1]) 972 (NotEqual (FlagLT_UGT)) -> (MOVDconst [1]) 973 (NotEqual (FlagGT_ULT)) -> (MOVDconst [1]) 974 (NotEqual (FlagGT_UGT)) -> (MOVDconst [1]) 975 976 (LessThan (FlagEQ)) -> (MOVDconst [0]) 977 (LessThan (FlagLT_ULT)) -> (MOVDconst [1]) 978 (LessThan (FlagLT_UGT)) -> (MOVDconst [1]) 979 (LessThan (FlagGT_ULT)) -> (MOVDconst [0]) 980 (LessThan (FlagGT_UGT)) -> (MOVDconst [0]) 981 982 (LessThanU (FlagEQ)) -> (MOVDconst [0]) 983 (LessThanU (FlagLT_ULT)) -> (MOVDconst [1]) 984 (LessThanU (FlagLT_UGT)) -> (MOVDconst [0]) 985 (LessThanU (FlagGT_ULT)) -> (MOVDconst [1]) 986 (LessThanU (FlagGT_UGT)) -> (MOVDconst [0]) 987 988 (LessEqual (FlagEQ)) -> (MOVDconst [1]) 989 (LessEqual (FlagLT_ULT)) -> (MOVDconst [1]) 990 (LessEqual (FlagLT_UGT)) -> (MOVDconst [1]) 991 (LessEqual (FlagGT_ULT)) -> (MOVDconst [0]) 992 (LessEqual (FlagGT_UGT)) -> (MOVDconst [0]) 993 994 (LessEqualU (FlagEQ)) -> (MOVDconst [1]) 995 (LessEqualU (FlagLT_ULT)) -> (MOVDconst [1]) 996 (LessEqualU (FlagLT_UGT)) -> (MOVDconst [0]) 997 (LessEqualU (FlagGT_ULT)) -> (MOVDconst [1]) 998 (LessEqualU (FlagGT_UGT)) -> (MOVDconst [0]) 999 1000 (GreaterThan (FlagEQ)) -> (MOVDconst [0]) 1001 (GreaterThan (FlagLT_ULT)) -> (MOVDconst [0]) 1002 (GreaterThan (FlagLT_UGT)) -> (MOVDconst [0]) 1003 (GreaterThan (FlagGT_ULT)) -> (MOVDconst [1]) 1004 (GreaterThan (FlagGT_UGT)) -> (MOVDconst [1]) 1005 1006 (GreaterThanU (FlagEQ)) -> (MOVDconst [0]) 1007 (GreaterThanU (FlagLT_ULT)) -> (MOVDconst [0]) 1008 (GreaterThanU (FlagLT_UGT)) -> (MOVDconst [1]) 1009 (GreaterThanU (FlagGT_ULT)) -> (MOVDconst [0]) 1010 (GreaterThanU (FlagGT_UGT)) -> (MOVDconst [1]) 1011 1012 (GreaterEqual (FlagEQ)) -> (MOVDconst [1]) 1013 (GreaterEqual (FlagLT_ULT)) -> (MOVDconst [0]) 1014 (GreaterEqual (FlagLT_UGT)) -> (MOVDconst [0]) 1015 (GreaterEqual (FlagGT_ULT)) -> (MOVDconst [1]) 1016 (GreaterEqual (FlagGT_UGT)) -> (MOVDconst [1]) 1017 1018 (GreaterEqualU (FlagEQ)) -> (MOVDconst [1]) 1019 (GreaterEqualU (FlagLT_ULT)) -> (MOVDconst [0]) 1020 (GreaterEqualU (FlagLT_UGT)) -> (MOVDconst [1]) 1021 (GreaterEqualU (FlagGT_ULT)) -> (MOVDconst [0]) 1022 (GreaterEqualU (FlagGT_UGT)) -> (MOVDconst [1]) 1023 1024 // absorb InvertFlags into boolean values 1025 (Equal (InvertFlags x)) -> (Equal x) 1026 (NotEqual (InvertFlags x)) -> (NotEqual x) 1027 (LessThan (InvertFlags x)) -> (GreaterThan x) 1028 (LessThanU (InvertFlags x)) -> (GreaterThanU x) 1029 (GreaterThan (InvertFlags x)) -> (LessThan x) 1030 (GreaterThanU (InvertFlags x)) -> (LessThanU x) 1031 (LessEqual (InvertFlags x)) -> (GreaterEqual x) 1032 (LessEqualU (InvertFlags x)) -> (GreaterEqualU x) 1033 (GreaterEqual (InvertFlags x)) -> (LessEqual x) 1034 (GreaterEqualU (InvertFlags x)) -> (LessEqualU x) 1035 1036 // absorb flag constants into conditional instructions 1037 (CSELULT _ y (FlagEQ)) -> y 1038 (CSELULT x _ (FlagLT_ULT)) -> x 1039 (CSELULT _ y (FlagLT_UGT)) -> y 1040 (CSELULT x _ (FlagGT_ULT)) -> x 1041 (CSELULT _ y (FlagGT_UGT)) -> y 1042 (CSELULT0 _ (FlagEQ)) -> (MOVDconst [0]) 1043 (CSELULT0 x (FlagLT_ULT)) -> x 1044 (CSELULT0 _ (FlagLT_UGT)) -> (MOVDconst [0]) 1045 (CSELULT0 x (FlagGT_ULT)) -> x 1046 (CSELULT0 _ (FlagGT_UGT)) -> (MOVDconst [0]) 1047 1048 // absorb shifts into ops 1049 (ADD x (SLLconst [c] y)) -> (ADDshiftLL x y [c]) 1050 (ADD x (SRLconst [c] y)) -> (ADDshiftRL x y [c]) 1051 (ADD x (SRAconst [c] y)) -> (ADDshiftRA x y [c]) 1052 (SUB x (SLLconst [c] y)) -> (SUBshiftLL x y [c]) 1053 (SUB x (SRLconst [c] y)) -> (SUBshiftRL x y [c]) 1054 (SUB x (SRAconst [c] y)) -> (SUBshiftRA x y [c]) 1055 (AND x (SLLconst [c] y)) -> (ANDshiftLL x y [c]) 1056 (AND x (SRLconst [c] y)) -> (ANDshiftRL x y [c]) 1057 (AND x (SRAconst [c] y)) -> (ANDshiftRA x y [c]) 1058 (OR x (SLLconst [c] y)) -> (ORshiftLL x y [c]) // useful for combined load 1059 (OR x (SRLconst [c] y)) -> (ORshiftRL x y [c]) 1060 (OR x (SRAconst [c] y)) -> (ORshiftRA x y [c]) 1061 (XOR x (SLLconst [c] y)) -> (XORshiftLL x y [c]) 1062 (XOR x (SRLconst [c] y)) -> (XORshiftRL x y [c]) 1063 (XOR x (SRAconst [c] y)) -> (XORshiftRA x y [c]) 1064 (BIC x (SLLconst [c] y)) -> (BICshiftLL x y [c]) 1065 (BIC x (SRLconst [c] y)) -> (BICshiftRL x y [c]) 1066 (BIC x (SRAconst [c] y)) -> (BICshiftRA x y [c]) 1067 (CMP x (SLLconst [c] y)) -> (CMPshiftLL x y [c]) 1068 (CMP (SLLconst [c] y) x) -> (InvertFlags (CMPshiftLL x y [c])) 1069 (CMP x (SRLconst [c] y)) -> (CMPshiftRL x y [c]) 1070 (CMP (SRLconst [c] y) x) -> (InvertFlags (CMPshiftRL x y [c])) 1071 (CMP x (SRAconst [c] y)) -> (CMPshiftRA x y [c]) 1072 (CMP (SRAconst [c] y) x) -> (InvertFlags (CMPshiftRA x y [c])) 1073 1074 // prefer *const ops to *shift ops 1075 (ADDshiftLL (MOVDconst [c]) x [d]) -> (ADDconst [c] (SLLconst <x.Type> x [d])) 1076 (ADDshiftRL (MOVDconst [c]) x [d]) -> (ADDconst [c] (SRLconst <x.Type> x [d])) 1077 (ADDshiftRA (MOVDconst [c]) x [d]) -> (ADDconst [c] (SRAconst <x.Type> x [d])) 1078 (ANDshiftLL (MOVDconst [c]) x [d]) -> (ANDconst [c] (SLLconst <x.Type> x [d])) 1079 (ANDshiftRL (MOVDconst [c]) x [d]) -> (ANDconst [c] (SRLconst <x.Type> x [d])) 1080 (ANDshiftRA (MOVDconst [c]) x [d]) -> (ANDconst [c] (SRAconst <x.Type> x [d])) 1081 (ORshiftLL (MOVDconst [c]) x [d]) -> (ORconst [c] (SLLconst <x.Type> x [d])) 1082 (ORshiftRL (MOVDconst [c]) x [d]) -> (ORconst [c] (SRLconst <x.Type> x [d])) 1083 (ORshiftRA (MOVDconst [c]) x [d]) -> (ORconst [c] (SRAconst <x.Type> x [d])) 1084 (XORshiftLL (MOVDconst [c]) x [d]) -> (XORconst [c] (SLLconst <x.Type> x [d])) 1085 (XORshiftRL (MOVDconst [c]) x [d]) -> (XORconst [c] (SRLconst <x.Type> x [d])) 1086 (XORshiftRA (MOVDconst [c]) x [d]) -> (XORconst [c] (SRAconst <x.Type> x [d])) 1087 (CMPshiftLL (MOVDconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SLLconst <x.Type> x [d]))) 1088 (CMPshiftRL (MOVDconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SRLconst <x.Type> x [d]))) 1089 (CMPshiftRA (MOVDconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SRAconst <x.Type> x [d]))) 1090 1091 // constant folding in *shift ops 1092 (ADDshiftLL x (MOVDconst [c]) [d]) -> (ADDconst x [int64(uint64(c)<<uint64(d))]) 1093 (ADDshiftRL x (MOVDconst [c]) [d]) -> (ADDconst x [int64(uint64(c)>>uint64(d))]) 1094 (ADDshiftRA x (MOVDconst [c]) [d]) -> (ADDconst x [int64(int64(c)>>uint64(d))]) 1095 (SUBshiftLL x (MOVDconst [c]) [d]) -> (SUBconst x [int64(uint64(c)<<uint64(d))]) 1096 (SUBshiftRL x (MOVDconst [c]) [d]) -> (SUBconst x [int64(uint64(c)>>uint64(d))]) 1097 (SUBshiftRA x (MOVDconst [c]) [d]) -> (SUBconst x [int64(int64(c)>>uint64(d))]) 1098 (ANDshiftLL x (MOVDconst [c]) [d]) -> (ANDconst x [int64(uint64(c)<<uint64(d))]) 1099 (ANDshiftRL x (MOVDconst [c]) [d]) -> (ANDconst x [int64(uint64(c)>>uint64(d))]) 1100 (ANDshiftRA x (MOVDconst [c]) [d]) -> (ANDconst x [int64(int64(c)>>uint64(d))]) 1101 (ORshiftLL x (MOVDconst [c]) [d]) -> (ORconst x [int64(uint64(c)<<uint64(d))]) 1102 (ORshiftRL x (MOVDconst [c]) [d]) -> (ORconst x [int64(uint64(c)>>uint64(d))]) 1103 (ORshiftRA x (MOVDconst [c]) [d]) -> (ORconst x [int64(int64(c)>>uint64(d))]) 1104 (XORshiftLL x (MOVDconst [c]) [d]) -> (XORconst x [int64(uint64(c)<<uint64(d))]) 1105 (XORshiftRL x (MOVDconst [c]) [d]) -> (XORconst x [int64(uint64(c)>>uint64(d))]) 1106 (XORshiftRA x (MOVDconst [c]) [d]) -> (XORconst x [int64(int64(c)>>uint64(d))]) 1107 (BICshiftLL x (MOVDconst [c]) [d]) -> (BICconst x [int64(uint64(c)<<uint64(d))]) 1108 (BICshiftRL x (MOVDconst [c]) [d]) -> (BICconst x [int64(uint64(c)>>uint64(d))]) 1109 (BICshiftRA x (MOVDconst [c]) [d]) -> (BICconst x [int64(int64(c)>>uint64(d))]) 1110 (CMPshiftLL x (MOVDconst [c]) [d]) -> (CMPconst x [int64(uint64(c)<<uint64(d))]) 1111 (CMPshiftRL x (MOVDconst [c]) [d]) -> (CMPconst x [int64(uint64(c)>>uint64(d))]) 1112 (CMPshiftRA x (MOVDconst [c]) [d]) -> (CMPconst x [int64(int64(c)>>uint64(d))]) 1113 1114 // simplification with *shift ops 1115 (SUBshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1116 (SUBshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1117 (SUBshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1118 (ANDshiftLL x y:(SLLconst x [c]) [d]) && c==d -> y 1119 (ANDshiftRL x y:(SRLconst x [c]) [d]) && c==d -> y 1120 (ANDshiftRA x y:(SRAconst x [c]) [d]) && c==d -> y 1121 (ORshiftLL x y:(SLLconst x [c]) [d]) && c==d -> y 1122 (ORshiftRL x y:(SRLconst x [c]) [d]) && c==d -> y 1123 (ORshiftRA x y:(SRAconst x [c]) [d]) && c==d -> y 1124 (XORshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1125 (XORshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1126 (XORshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1127 (BICshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1128 (BICshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1129 (BICshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVDconst [0]) 1130 1131 // Generate rotates 1132 (ADDshiftLL [c] (SRLconst x [64-c]) x) -> (RORconst [64-c] x) 1133 ( ORshiftLL [c] (SRLconst x [64-c]) x) -> (RORconst [64-c] x) 1134 (XORshiftLL [c] (SRLconst x [64-c]) x) -> (RORconst [64-c] x) 1135 (ADDshiftRL [c] (SLLconst x [64-c]) x) -> (RORconst [ c] x) 1136 ( ORshiftRL [c] (SLLconst x [64-c]) x) -> (RORconst [ c] x) 1137 (XORshiftRL [c] (SLLconst x [64-c]) x) -> (RORconst [ c] x) 1138 1139 (ADDshiftLL <t> [c] (SRLconst (MOVWUreg x) [32-c]) x) && c < 32 && t.Size() == 4 -> (RORWconst [32-c] x) 1140 ( ORshiftLL <t> [c] (SRLconst (MOVWUreg x) [32-c]) x) && c < 32 && t.Size() == 4 -> (RORWconst [32-c] x) 1141 (XORshiftLL <t> [c] (SRLconst (MOVWUreg x) [32-c]) x) && c < 32 && t.Size() == 4 -> (RORWconst [32-c] x) 1142 (ADDshiftRL <t> [c] (SLLconst x [32-c]) (MOVWUreg x)) && c < 32 && t.Size() == 4 -> (RORWconst [ c] x) 1143 ( ORshiftRL <t> [c] (SLLconst x [32-c]) (MOVWUreg x)) && c < 32 && t.Size() == 4 -> (RORWconst [ c] x) 1144 (XORshiftRL <t> [c] (SLLconst x [32-c]) (MOVWUreg x)) && c < 32 && t.Size() == 4 -> (RORWconst [ c] x) 1145 1146 // Generic rules rewrite certain AND to a pair of shifts. 1147 // However, on ARM64 the bitmask can fit into an instruction. 1148 // Rewrite it back to AND. 1149 (SRLconst [c] (SLLconst [c] x)) && 0 < c && c < 64 -> (ANDconst [1<<uint(64-c)-1] x) // mask out high bits 1150 (SLLconst [c] (SRLconst [c] x)) && 0 < c && c < 64 -> (ANDconst [^(1<<uint(c)-1)] x) // mask out low bits 1151 1152 // do combined loads 1153 // little endian loads 1154 // b[0] | b[1]<<8 -> load 16-bit 1155 (ORshiftLL <t> [8] 1156 y0:(MOVDnop x0:(MOVBUload [i0] {s} p mem)) 1157 y1:(MOVDnop x1:(MOVBUload [i1] {s} p mem))) 1158 && i1 == i0+1 1159 && x0.Uses == 1 && x1.Uses == 1 1160 && y0.Uses == 1 && y1.Uses == 1 1161 && mergePoint(b,x0,x1) != nil 1162 && clobber(x0) && clobber(x1) 1163 && clobber(y0) && clobber(y1) 1164 -> @mergePoint(b,x0,x1) (MOVHUload <t> {s} (OffPtr <p.Type> [i0] p) mem) 1165 1166 // b[0] | b[1]<<8 | b[2]<<16 | b[3]<<24 -> load 32-bit 1167 (ORshiftLL <t> [24] o0:(ORshiftLL [16] 1168 x0:(MOVHUload [i0] {s} p mem) 1169 y1:(MOVDnop x1:(MOVBUload [i2] {s} p mem))) 1170 y2:(MOVDnop x2:(MOVBUload [i3] {s} p mem))) 1171 && i2 == i0+2 1172 && i3 == i0+3 1173 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 1174 && y1.Uses == 1 && y2.Uses == 1 1175 && o0.Uses == 1 1176 && mergePoint(b,x0,x1,x2) != nil 1177 && clobber(x0) && clobber(x1) && clobber(x2) 1178 && clobber(y1) && clobber(y2) 1179 && clobber(o0) 1180 -> @mergePoint(b,x0,x1,x2) (MOVWUload <t> {s} (OffPtr <p.Type> [i0] p) mem) 1181 1182 // b[0] | b[1]<<8 | b[2]<<16 | b[3]<<24 | b[4]<<32 | b[5]<<40 | b[6]<<48 | b[7]<<56 -> load 64-bit 1183 (ORshiftLL <t> [56] o0:(ORshiftLL [48] o1:(ORshiftLL [40] o2:(ORshiftLL [32] 1184 x0:(MOVWUload [i0] {s} p mem) 1185 y1:(MOVDnop x1:(MOVBUload [i4] {s} p mem))) 1186 y2:(MOVDnop x2:(MOVBUload [i5] {s} p mem))) 1187 y3:(MOVDnop x3:(MOVBUload [i6] {s} p mem))) 1188 y4:(MOVDnop x4:(MOVBUload [i7] {s} p mem))) 1189 && i4 == i0+4 1190 && i5 == i0+5 1191 && i6 == i0+6 1192 && i7 == i0+7 1193 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && x3.Uses == 1 && x4.Uses == 1 1194 && y1.Uses == 1 && y2.Uses == 1 && y3.Uses == 1 && y4.Uses == 1 1195 && o0.Uses == 1 && o1.Uses == 1 && o2.Uses == 1 1196 && mergePoint(b,x0,x1,x2,x3,x4) != nil 1197 && clobber(x0) && clobber(x1) && clobber(x2) && clobber(x3) && clobber(x4) 1198 && clobber(y1) && clobber(y2) && clobber(y3) && clobber(y4) 1199 && clobber(o0) && clobber(o1) && clobber(o2) 1200 -> @mergePoint(b,x0,x1,x2,x3,x4) (MOVDload <t> {s} (OffPtr <p.Type> [i0] p) mem) 1201 1202 // b[3]<<24 | b[2]<<16 | b[1]<<8 | b[0] -> load 32-bit 1203 (OR <t> o0:(ORshiftLL [8] o1:(ORshiftLL [16] s0:(SLLconst [24] 1204 y0:(MOVDnop x0:(MOVBUload [i3] {s} p mem))) 1205 y1:(MOVDnop x1:(MOVBUload [i2] {s} p mem))) 1206 y2:(MOVDnop x2:(MOVBUload [i1] {s} p mem))) 1207 y3:(MOVDnop x3:(MOVBUload [i0] {s} p mem))) 1208 && i1 == i0+1 1209 && i2 == i0+2 1210 && i3 == i0+3 1211 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && x3.Uses == 1 1212 && y0.Uses == 1 && y1.Uses == 1 && y2.Uses == 1 && y3.Uses == 1 1213 && o0.Uses == 1 && o1.Uses == 1 && s0.Uses == 1 1214 && mergePoint(b,x0,x1,x2,x3) != nil 1215 && clobber(x0) && clobber(x1) && clobber(x2) && clobber(x3) 1216 && clobber(y0) && clobber(y1) && clobber(y2) && clobber(y3) 1217 && clobber(o0) && clobber(o1) && clobber(s0) 1218 -> @mergePoint(b,x0,x1,x2,x3) (MOVWUload <t> {s} (OffPtr <p.Type> [i0] p) mem) 1219 1220 // b[7]<<56 | b[6]<<48 | b[5]<<40 | b[4]<<32 | b[3]<<24 | b[2]<<16 | b[1]<<8 | b[0] -> load 64-bit, reverse 1221 (OR <t> o0:(ORshiftLL [8] o1:(ORshiftLL [16] o2:(ORshiftLL [24] o3:(ORshiftLL [32] o4:(ORshiftLL [40] o5:(ORshiftLL [48] s0:(SLLconst [56] 1222 y0:(MOVDnop x0:(MOVBUload [i7] {s} p mem))) 1223 y1:(MOVDnop x1:(MOVBUload [i6] {s} p mem))) 1224 y2:(MOVDnop x2:(MOVBUload [i5] {s} p mem))) 1225 y3:(MOVDnop x3:(MOVBUload [i4] {s} p mem))) 1226 y4:(MOVDnop x4:(MOVBUload [i3] {s} p mem))) 1227 y5:(MOVDnop x5:(MOVBUload [i2] {s} p mem))) 1228 y6:(MOVDnop x6:(MOVBUload [i1] {s} p mem))) 1229 y7:(MOVDnop x7:(MOVBUload [i0] {s} p mem))) 1230 && i1 == i0+1 1231 && i2 == i0+2 1232 && i3 == i0+3 1233 && i4 == i0+4 1234 && i5 == i0+5 1235 && i6 == i0+6 1236 && i7 == i0+7 1237 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && x3.Uses == 1 1238 && x4.Uses == 1 && x5.Uses == 1 && x6.Uses == 1 && x7.Uses == 1 1239 && y0.Uses == 1 && y1.Uses == 1 && y2.Uses == 1 && y3.Uses == 1 1240 && y4.Uses == 1 && y5.Uses == 1 && y6.Uses == 1 && y7.Uses == 1 1241 && o0.Uses == 1 && o1.Uses == 1 && o2.Uses == 1 && o3.Uses == 1 1242 && o4.Uses == 1 && o5.Uses == 1 && s0.Uses == 1 1243 && mergePoint(b,x0,x1,x2,x3,x4,x5,x6,x7) != nil 1244 && clobber(x0) && clobber(x1) && clobber(x2) && clobber(x3) 1245 && clobber(x4) && clobber(x5) && clobber(x6) && clobber(x7) 1246 && clobber(y0) && clobber(y1) && clobber(y2) && clobber(y3) 1247 && clobber(y4) && clobber(y5) && clobber(y6) && clobber(y7) 1248 && clobber(o0) && clobber(o1) && clobber(o2) && clobber(o3) 1249 && clobber(o4) && clobber(o5) && clobber(s0) 1250 -> @mergePoint(b,x0,x1,x2,x3,x4,x5,x6,x7) (REV <t> (MOVDload <t> {s} (OffPtr <p.Type> [i0] p) mem)) 1251 1252 // big endian loads 1253 // b[1] | b[0]<<8 -> load 16-bit, reverse 1254 (ORshiftLL <t> [8] 1255 y0:(MOVDnop x0:(MOVBUload [i1] {s} p mem)) 1256 y1:(MOVDnop x1:(MOVBUload [i0] {s} p mem))) 1257 && i1 == i0+1 1258 && x0.Uses == 1 && x1.Uses == 1 1259 && y0.Uses == 1 && y1.Uses == 1 1260 && mergePoint(b,x0,x1) != nil 1261 && clobber(x0) && clobber(x1) 1262 && clobber(y0) && clobber(y1) 1263 -> @mergePoint(b,x0,x1) (REV16W <t> (MOVHUload <t> [i0] {s} p mem)) 1264 1265 // b[3] | b[2]<<8 | b[1]<<16 | b[0]<<24 -> load 32-bit, reverse 1266 (ORshiftLL <t> [24] o0:(ORshiftLL [16] 1267 y0:(REV16W x0:(MOVHUload [i2] {s} p mem)) 1268 y1:(MOVDnop x1:(MOVBUload [i1] {s} p mem))) 1269 y2:(MOVDnop x2:(MOVBUload [i0] {s} p mem))) 1270 && i1 == i0+1 1271 && i2 == i0+2 1272 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 1273 && y0.Uses == 1 && y1.Uses == 1 && y2.Uses == 1 1274 && o0.Uses == 1 1275 && mergePoint(b,x0,x1,x2) != nil 1276 && clobber(x0) && clobber(x1) && clobber(x2) 1277 && clobber(y0) && clobber(y1) && clobber(y2) 1278 && clobber(o0) 1279 -> @mergePoint(b,x0,x1,x2) (REVW <t> (MOVWUload <t> {s} (OffPtr <p.Type> [i0] p) mem)) 1280 1281 // b[7] | b[6]<<8 | b[5]<<16 | b[4]<<24 | b[3]<<32 | b[2]<<40 | b[1]<<48 | b[0]<<56 -> load 64-bit, reverse 1282 (ORshiftLL <t> [56] o0:(ORshiftLL [48] o1:(ORshiftLL [40] o2:(ORshiftLL [32] 1283 y0:(REVW x0:(MOVWUload [i4] {s} p mem)) 1284 y1:(MOVDnop x1:(MOVBUload [i3] {s} p mem))) 1285 y2:(MOVDnop x2:(MOVBUload [i2] {s} p mem))) 1286 y3:(MOVDnop x3:(MOVBUload [i1] {s} p mem))) 1287 y4:(MOVDnop x4:(MOVBUload [i0] {s} p mem))) 1288 && i1 == i0+1 1289 && i2 == i0+2 1290 && i3 == i0+3 1291 && i4 == i0+4 1292 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && x3.Uses == 1 && x4.Uses == 1 1293 && y0.Uses == 1 && y1.Uses == 1 && y2.Uses == 1 && y3.Uses == 1 && y4.Uses == 1 1294 && o0.Uses == 1 && o1.Uses == 1 && o2.Uses == 1 1295 && mergePoint(b,x0,x1,x2,x3,x4) != nil 1296 && clobber(x0) && clobber(x1) && clobber(x2) && clobber(x3) && clobber(x4) 1297 && clobber(y0) && clobber(y1) && clobber(y2) && clobber(y3) && clobber(y4) 1298 && clobber(o0) && clobber(o1) && clobber(o2) 1299 -> @mergePoint(b,x0,x1,x2,x3,x4) (REV <t> (MOVDload <t> {s} (OffPtr <p.Type> [i0] p) mem)) 1300 1301 // b[0]<<24 | b[1]<<16 | b[2]<<8 | b[3] -> load 32-bit, reverse 1302 (OR <t> o0:(ORshiftLL [8] o1:(ORshiftLL [16] s0:(SLLconst [24] 1303 y0:(MOVDnop x0:(MOVBUload [i0] {s} p mem))) 1304 y1:(MOVDnop x1:(MOVBUload [i1] {s} p mem))) 1305 y2:(MOVDnop x2:(MOVBUload [i2] {s} p mem))) 1306 y3:(MOVDnop x3:(MOVBUload [i3] {s} p mem))) 1307 && i1 == i0+1 1308 && i2 == i0+2 1309 && i3 == i0+3 1310 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && x3.Uses == 1 1311 && y0.Uses == 1 && y1.Uses == 1 && y2.Uses == 1 && y3.Uses == 1 1312 && o0.Uses == 1 && o1.Uses == 1 && s0.Uses == 1 1313 && mergePoint(b,x0,x1,x2,x3) != nil 1314 && clobber(x0) && clobber(x1) && clobber(x2) && clobber(x3) 1315 && clobber(y0) && clobber(y1) && clobber(y2) && clobber(y3) 1316 && clobber(o0) && clobber(o1) && clobber(s0) 1317 -> @mergePoint(b,x0,x1,x2,x3) (REVW <t> (MOVWUload <t> {s} (OffPtr <p.Type> [i0] p) mem)) 1318 1319 // b[0]<<56 | b[1]<<48 | b[2]<<40 | b[3]<<32 | b[4]<<24 | b[5]<<16 | b[6]<<8 | b[7] -> load 64-bit, reverse 1320 (OR <t> o0:(ORshiftLL [8] o1:(ORshiftLL [16] o2:(ORshiftLL [24] o3:(ORshiftLL [32] o4:(ORshiftLL [40] o5:(ORshiftLL [48] s0:(SLLconst [56] 1321 y0:(MOVDnop x0:(MOVBUload [i0] {s} p mem))) 1322 y1:(MOVDnop x1:(MOVBUload [i1] {s} p mem))) 1323 y2:(MOVDnop x2:(MOVBUload [i2] {s} p mem))) 1324 y3:(MOVDnop x3:(MOVBUload [i3] {s} p mem))) 1325 y4:(MOVDnop x4:(MOVBUload [i4] {s} p mem))) 1326 y5:(MOVDnop x5:(MOVBUload [i5] {s} p mem))) 1327 y6:(MOVDnop x6:(MOVBUload [i6] {s} p mem))) 1328 y7:(MOVDnop x7:(MOVBUload [i7] {s} p mem))) 1329 && i1 == i0+1 1330 && i2 == i0+2 1331 && i3 == i0+3 1332 && i4 == i0+4 1333 && i5 == i0+5 1334 && i6 == i0+6 1335 && i7 == i0+7 1336 && x0.Uses == 1 && x1.Uses == 1 && x2.Uses == 1 && x3.Uses == 1 1337 && x4.Uses == 1 && x5.Uses == 1 && x6.Uses == 1 && x7.Uses == 1 1338 && y0.Uses == 1 && y1.Uses == 1 && y2.Uses == 1 && y3.Uses == 1 1339 && y4.Uses == 1 && y5.Uses == 1 && y6.Uses == 1 && y7.Uses == 1 1340 && o0.Uses == 1 && o1.Uses == 1 && o2.Uses == 1 && o3.Uses == 1 1341 && o4.Uses == 1 && o5.Uses == 1 && s0.Uses == 1 1342 && mergePoint(b,x0,x1,x2,x3,x4,x5,x6,x7) != nil 1343 && clobber(x0) && clobber(x1) && clobber(x2) && clobber(x3) 1344 && clobber(x4) && clobber(x5) && clobber(x6) && clobber(x7) 1345 && clobber(y0) && clobber(y1) && clobber(y2) && clobber(y3) 1346 && clobber(y4) && clobber(y5) && clobber(y6) && clobber(y7) 1347 && clobber(o0) && clobber(o1) && clobber(o2) && clobber(o3) 1348 && clobber(o4) && clobber(o5) && clobber(s0) 1349 -> @mergePoint(b,x0,x1,x2,x3,x4,x5,x6,x7) (REV <t> (MOVDload <t> {s} (OffPtr <p.Type> [i0] p) mem))