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