github.com/sanprasirt/go@v0.0.0-20170607001320-a027466e4b6d/src/cmd/compile/internal/ssa/gen/S390X.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  // Lowering arithmetic
     6  (Add64  x y) -> (ADD  x y)
     7  (AddPtr x y) -> (ADD  x y)
     8  (Add32  x y) -> (ADDW  x y)
     9  (Add16  x y) -> (ADDW  x y)
    10  (Add8   x y) -> (ADDW  x y)
    11  (Add32F x y) -> (FADDS x y)
    12  (Add64F x y) -> (FADD x y)
    13  
    14  (Sub64  x y) -> (SUB  x y)
    15  (SubPtr x y) -> (SUB  x y)
    16  (Sub32  x y) -> (SUBW  x y)
    17  (Sub16  x y) -> (SUBW  x y)
    18  (Sub8   x y) -> (SUBW  x y)
    19  (Sub32F x y) -> (FSUBS x y)
    20  (Sub64F x y) -> (FSUB x y)
    21  
    22  (Mul64  x y) -> (MULLD  x y)
    23  (Mul32  x y) -> (MULLW  x y)
    24  (Mul16  x y) -> (MULLW  x y)
    25  (Mul8   x y) -> (MULLW  x y)
    26  (Mul32F x y) -> (FMULS x y)
    27  (Mul64F x y) -> (FMUL x y)
    28  
    29  (Div32F x y) -> (FDIVS x y)
    30  (Div64F x y) -> (FDIV x y)
    31  
    32  (Div64  x y) -> (DIVD  x y)
    33  (Div64u x y) -> (DIVDU x y)
    34  // DIVW/DIVWU has a 64-bit dividend and a 32-bit divisor,
    35  // so a sign/zero extension of the dividend is required.
    36  (Div32  x y) -> (DIVW  (MOVWreg x) y)
    37  (Div32u x y) -> (DIVWU (MOVWZreg x) y)
    38  (Div16  x y) -> (DIVW  (MOVHreg x) (MOVHreg y))
    39  (Div16u x y) -> (DIVWU (MOVHZreg x) (MOVHZreg y))
    40  (Div8   x y) -> (DIVW  (MOVBreg x) (MOVBreg y))
    41  (Div8u  x y) -> (DIVWU (MOVBZreg x) (MOVBZreg y))
    42  
    43  (Hmul64  x y) -> (MULHD  x y)
    44  (Hmul64u x y) -> (MULHDU x y)
    45  (Hmul32  x y) -> (SRDconst [32] (MULLD (MOVWreg x) (MOVWreg y)))
    46  (Hmul32u x y) -> (SRDconst [32] (MULLD (MOVWZreg x) (MOVWZreg y)))
    47  
    48  (Mod64  x y) -> (MODD  x y)
    49  (Mod64u x y) -> (MODDU x y)
    50  // MODW/MODWU has a 64-bit dividend and a 32-bit divisor,
    51  // so a sign/zero extension of the dividend is required.
    52  (Mod32  x y) -> (MODW  (MOVWreg x) y)
    53  (Mod32u x y) -> (MODWU (MOVWZreg x) y)
    54  (Mod16  x y) -> (MODW  (MOVHreg x) (MOVHreg y))
    55  (Mod16u x y) -> (MODWU (MOVHZreg x) (MOVHZreg y))
    56  (Mod8   x y) -> (MODW  (MOVBreg x) (MOVBreg y))
    57  (Mod8u  x y) -> (MODWU (MOVBZreg x) (MOVBZreg y))
    58  
    59  // (x + y) / 2 with x>=y -> (x - y) / 2 + y
    60  (Avg64u <t> x y) -> (ADD (SRDconst <t> (SUB <t> x y) [1]) y)
    61  
    62  (And64 x y) -> (AND x y)
    63  (And32 x y) -> (ANDW x y)
    64  (And16 x y) -> (ANDW x y)
    65  (And8  x y) -> (ANDW x y)
    66  
    67  (Or64 x y) -> (OR x y)
    68  (Or32 x y) -> (ORW x y)
    69  (Or16 x y) -> (ORW x y)
    70  (Or8  x y) -> (ORW x y)
    71  
    72  (Xor64 x y) -> (XOR x y)
    73  (Xor32 x y) -> (XORW x y)
    74  (Xor16 x y) -> (XORW x y)
    75  (Xor8  x y) -> (XORW x y)
    76  
    77  (Neg64  x) -> (NEG x)
    78  (Neg32  x) -> (NEGW x)
    79  (Neg16  x) -> (NEGW (MOVHreg x))
    80  (Neg8   x) -> (NEGW (MOVBreg x))
    81  (Neg32F x) -> (FNEGS x)
    82  (Neg64F x) -> (FNEG x)
    83  
    84  (Com64 x) -> (NOT x)
    85  (Com32 x) -> (NOTW x)
    86  (Com16 x) -> (NOTW x)
    87  (Com8  x) -> (NOTW x)
    88  (NOT x) && true -> (XOR (MOVDconst [-1]) x)
    89  (NOTW x) && true -> (XORWconst [-1] x)
    90  
    91  // Lowering boolean ops
    92  (AndB x y) -> (ANDW x y)
    93  (OrB x y) -> (ORW x y)
    94  (Not x) -> (XORWconst [1] x)
    95  
    96  // Lowering pointer arithmetic
    97  (OffPtr [off] ptr:(SP)) -> (MOVDaddr [off] ptr)
    98  (OffPtr [off] ptr) && is32Bit(off) -> (ADDconst [off] ptr)
    99  (OffPtr [off] ptr) -> (ADD (MOVDconst [off]) ptr)
   100  
   101  // Ctz(x) = 64 - findLeftmostOne((x-1)&^x)
   102  (Ctz64 <t> x) -> (SUB (MOVDconst [64]) (FLOGR (AND <t> (SUBconst <t> [1] x) (NOT <t> x))))
   103  (Ctz32 <t> x) -> (SUB (MOVDconst [64]) (FLOGR (MOVWZreg (ANDW <t> (SUBWconst <t> [1] x) (NOTW <t> x)))))
   104  
   105  (BitLen64 x) -> (SUB (MOVDconst [64]) (FLOGR x))
   106  
   107  (Bswap64 x) -> (MOVDBR x)
   108  (Bswap32 x) -> (MOVWBR x)
   109  
   110  (Sqrt x) -> (FSQRT x)
   111  
   112  // Atomic loads.
   113  (AtomicLoad32 ptr mem) -> (MOVWZatomicload ptr mem)
   114  (AtomicLoad64 ptr mem) -> (MOVDatomicload ptr mem)
   115  (AtomicLoadPtr ptr mem) -> (MOVDatomicload ptr mem)
   116  
   117  // Atomic stores.
   118  (AtomicStore32 ptr val mem) -> (MOVWatomicstore ptr val mem)
   119  (AtomicStore64 ptr val mem) -> (MOVDatomicstore ptr val mem)
   120  (AtomicStorePtrNoWB ptr val mem) -> (MOVDatomicstore ptr val mem)
   121  
   122  // Atomic adds.
   123  (AtomicAdd32 ptr val mem) -> (AddTupleFirst32 val (LAA ptr val mem))
   124  (AtomicAdd64 ptr val mem) -> (AddTupleFirst64 val (LAAG ptr val mem))
   125  (Select0 <t> (AddTupleFirst32 val tuple)) -> (ADDW val (Select0 <t> tuple))
   126  (Select1     (AddTupleFirst32   _ tuple)) -> (Select1 tuple)
   127  (Select0 <t> (AddTupleFirst64 val tuple)) -> (ADD val (Select0 <t> tuple))
   128  (Select1     (AddTupleFirst64   _ tuple)) -> (Select1 tuple)
   129  
   130  // Atomic exchanges.
   131  (AtomicExchange32 ptr val mem) -> (LoweredAtomicExchange32 ptr val mem)
   132  (AtomicExchange64 ptr val mem) -> (LoweredAtomicExchange64 ptr val mem)
   133  
   134  // Atomic compare and swap.
   135  (AtomicCompareAndSwap32 ptr old new_ mem) -> (LoweredAtomicCas32 ptr old new_ mem)
   136  (AtomicCompareAndSwap64 ptr old new_ mem) -> (LoweredAtomicCas64 ptr old new_ mem)
   137  
   138  // Lowering extension
   139  // Note: we always extend to 64 bits even though some ops don't need that many result bits.
   140  (SignExt8to16  x) -> (MOVBreg x)
   141  (SignExt8to32  x) -> (MOVBreg x)
   142  (SignExt8to64  x) -> (MOVBreg x)
   143  (SignExt16to32 x) -> (MOVHreg x)
   144  (SignExt16to64 x) -> (MOVHreg x)
   145  (SignExt32to64 x) -> (MOVWreg x)
   146  
   147  (ZeroExt8to16  x) -> (MOVBZreg x)
   148  (ZeroExt8to32  x) -> (MOVBZreg x)
   149  (ZeroExt8to64  x) -> (MOVBZreg x)
   150  (ZeroExt16to32 x) -> (MOVHZreg x)
   151  (ZeroExt16to64 x) -> (MOVHZreg x)
   152  (ZeroExt32to64 x) -> (MOVWZreg x)
   153  
   154  (Slicemask <t> x) -> (SRADconst (NEG <t> x) [63])
   155  
   156  // Lowering truncation
   157  // Because we ignore high parts of registers, truncates are just copies.
   158  (Trunc16to8  x) -> x
   159  (Trunc32to8  x) -> x
   160  (Trunc32to16 x) -> x
   161  (Trunc64to8  x) -> x
   162  (Trunc64to16 x) -> x
   163  (Trunc64to32 x) -> x
   164  
   165  // Lowering float <-> int
   166  (Cvt32to32F x) -> (CEFBRA x)
   167  (Cvt32to64F x) -> (CDFBRA x)
   168  (Cvt64to32F x) -> (CEGBRA x)
   169  (Cvt64to64F x) -> (CDGBRA x)
   170  
   171  (Cvt32Fto32 x) -> (CFEBRA x)
   172  (Cvt32Fto64 x) -> (CGEBRA x)
   173  (Cvt64Fto32 x) -> (CFDBRA x)
   174  (Cvt64Fto64 x) -> (CGDBRA x)
   175  
   176  (Cvt32Fto64F x) -> (LDEBR x)
   177  (Cvt64Fto32F x) -> (LEDBR x)
   178  
   179  (Round32F x) -> (LoweredRound32F x)
   180  (Round64F x) -> (LoweredRound64F x)
   181  
   182  // Lowering shifts
   183  // Unsigned shifts need to return 0 if shift amount is >= width of shifted value.
   184  //   result = (arg << shift) & (shift >= argbits ? 0 : 0xffffffffffffffff)
   185  (Lsh64x64 <t> x y) -> (AND (SLD <t> x y) (SUBEcarrymask <t> (CMPUconst y [63])))
   186  (Lsh64x32 <t> x y) -> (AND (SLD <t> x y) (SUBEcarrymask <t> (CMPWUconst y [63])))
   187  (Lsh64x16 <t> x y) -> (AND (SLD <t> x y) (SUBEcarrymask <t> (CMPWUconst (MOVHZreg y) [63])))
   188  (Lsh64x8  <t> x y) -> (AND (SLD <t> x y) (SUBEcarrymask <t> (CMPWUconst (MOVBZreg y) [63])))
   189  
   190  (Lsh32x64 <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPUconst y [31])))
   191  (Lsh32x32 <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst y [31])))
   192  (Lsh32x16 <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVHZreg y) [31])))
   193  (Lsh32x8  <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVBZreg y) [31])))
   194  
   195  (Lsh16x64 <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPUconst y [31])))
   196  (Lsh16x32 <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst y [31])))
   197  (Lsh16x16 <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVHZreg y) [31])))
   198  (Lsh16x8  <t> x y) -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVBZreg y) [31])))
   199  
   200  (Lsh8x64 <t> x y)  -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPUconst y [31])))
   201  (Lsh8x32 <t> x y)  -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst y [31])))
   202  (Lsh8x16 <t> x y)  -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVHZreg y) [31])))
   203  (Lsh8x8  <t> x y)  -> (ANDW (SLW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVBZreg y) [31])))
   204  
   205  (Rsh64Ux64 <t> x y) -> (AND (SRD <t> x y) (SUBEcarrymask <t> (CMPUconst y [63])))
   206  (Rsh64Ux32 <t> x y) -> (AND (SRD <t> x y) (SUBEcarrymask <t> (CMPWUconst y [63])))
   207  (Rsh64Ux16 <t> x y) -> (AND (SRD <t> x y) (SUBEcarrymask <t> (CMPWUconst (MOVHZreg y) [63])))
   208  (Rsh64Ux8  <t> x y) -> (AND (SRD <t> x y) (SUBEcarrymask <t> (CMPWUconst (MOVBZreg y) [63])))
   209  
   210  (Rsh32Ux64 <t> x y) -> (ANDW (SRW <t> x y) (SUBEWcarrymask <t> (CMPUconst y [31])))
   211  (Rsh32Ux32 <t> x y) -> (ANDW (SRW <t> x y) (SUBEWcarrymask <t> (CMPWUconst y [31])))
   212  (Rsh32Ux16 <t> x y) -> (ANDW (SRW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVHZreg y) [31])))
   213  (Rsh32Ux8  <t> x y) -> (ANDW (SRW <t> x y) (SUBEWcarrymask <t> (CMPWUconst (MOVBZreg y) [31])))
   214  
   215  (Rsh16Ux64 <t> x y) -> (ANDW (SRW <t> (MOVHZreg x) y) (SUBEWcarrymask <t> (CMPUconst y [15])))
   216  (Rsh16Ux32 <t> x y) -> (ANDW (SRW <t> (MOVHZreg x) y) (SUBEWcarrymask <t> (CMPWUconst y [15])))
   217  (Rsh16Ux16 <t> x y) -> (ANDW (SRW <t> (MOVHZreg x) y) (SUBEWcarrymask <t> (CMPWUconst (MOVHZreg y) [15])))
   218  (Rsh16Ux8  <t> x y) -> (ANDW (SRW <t> (MOVHZreg x) y) (SUBEWcarrymask <t> (CMPWUconst (MOVBZreg y) [15])))
   219  
   220  (Rsh8Ux64 <t> x y)  -> (ANDW (SRW <t> (MOVBZreg x) y) (SUBEWcarrymask <t> (CMPUconst y [7])))
   221  (Rsh8Ux32 <t> x y)  -> (ANDW (SRW <t> (MOVBZreg x) y) (SUBEWcarrymask <t> (CMPWUconst y [7])))
   222  (Rsh8Ux16 <t> x y)  -> (ANDW (SRW <t> (MOVBZreg x) y) (SUBEWcarrymask <t> (CMPWUconst (MOVHZreg y) [7])))
   223  (Rsh8Ux8  <t> x y)  -> (ANDW (SRW <t> (MOVBZreg x) y) (SUBEWcarrymask <t> (CMPWUconst (MOVBZreg y) [7])))
   224  
   225  // Signed right shift needs to return 0/-1 if shift amount is >= width of shifted value.
   226  // We implement this by setting the shift value to -1 (all ones) if the shift value is >= width.
   227  (Rsh64x64 <t> x y) -> (SRAD <t> x (OR <y.Type> y (NOT <y.Type> (SUBEcarrymask <y.Type> (CMPUconst y [63])))))
   228  (Rsh64x32 <t> x y) -> (SRAD <t> x (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst y [63])))))
   229  (Rsh64x16 <t> x y) -> (SRAD <t> x (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVHZreg y) [63])))))
   230  (Rsh64x8  <t> x y) -> (SRAD <t> x (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVBZreg y) [63])))))
   231  
   232  (Rsh32x64 <t> x y) -> (SRAW <t> x (OR <y.Type> y (NOT <y.Type> (SUBEcarrymask <y.Type> (CMPUconst y [31])))))
   233  (Rsh32x32 <t> x y) -> (SRAW <t> x (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst y [31])))))
   234  (Rsh32x16 <t> x y) -> (SRAW <t> x (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVHZreg y) [31])))))
   235  (Rsh32x8  <t> x y) -> (SRAW <t> x (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVBZreg y) [31])))))
   236  
   237  (Rsh16x64 <t> x y) -> (SRAW <t> (MOVHreg x) (OR <y.Type> y (NOT <y.Type> (SUBEcarrymask <y.Type> (CMPUconst y [15])))))
   238  (Rsh16x32 <t> x y) -> (SRAW <t> (MOVHreg x) (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst y [15])))))
   239  (Rsh16x16 <t> x y) -> (SRAW <t> (MOVHreg x) (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVHZreg y) [15])))))
   240  (Rsh16x8  <t> x y) -> (SRAW <t> (MOVHreg x) (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVBZreg y) [15])))))
   241  
   242  (Rsh8x64 <t> x y)  -> (SRAW <t> (MOVBreg x) (OR <y.Type> y (NOT <y.Type> (SUBEcarrymask <y.Type> (CMPUconst y [7])))))
   243  (Rsh8x32 <t> x y)  -> (SRAW <t> (MOVBreg x) (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst y [7])))))
   244  (Rsh8x16 <t> x y)  -> (SRAW <t> (MOVBreg x) (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVHZreg y) [7])))))
   245  (Rsh8x8  <t> x y)  -> (SRAW <t> (MOVBreg x) (ORW <y.Type> y (NOTW <y.Type> (SUBEWcarrymask <y.Type> (CMPWUconst (MOVBZreg y) [7])))))
   246  
   247  // Lowering comparisons
   248  (Less64  x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   249  (Less32  x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMPW x y))
   250  (Less16  x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVHreg x) (MOVHreg y)))
   251  (Less8   x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   252  (Less64U x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMPU x y))
   253  (Less32U x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMPWU x y))
   254  (Less16U x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVHZreg x) (MOVHZreg y)))
   255  (Less8U  x y) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVBZreg x) (MOVBZreg y)))
   256  // Use SETG with reversed operands to dodge NaN case.
   257  (Less64F x y) -> (MOVDGTnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMP y x))
   258  (Less32F x y) -> (MOVDGTnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMPS y x))
   259  
   260  (Leq64  x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   261  (Leq32  x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMPW x y))
   262  (Leq16  x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVHreg x) (MOVHreg y)))
   263  (Leq8   x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   264  (Leq64U x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMPU x y))
   265  (Leq32U x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMPWU x y))
   266  (Leq16U x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVHZreg x) (MOVHZreg y)))
   267  (Leq8U  x y) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVBZreg x) (MOVBZreg y)))
   268  // Use SETGE with reversed operands to dodge NaN case.
   269  (Leq64F x y) -> (MOVDGEnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMP y x))
   270  (Leq32F x y) -> (MOVDGEnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMPS y x))
   271  
   272  (Greater64  x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   273  (Greater32  x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMPW x y))
   274  (Greater16  x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVHreg x) (MOVHreg y)))
   275  (Greater8   x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   276  (Greater64U x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMPU x y))
   277  (Greater32U x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMPWU x y))
   278  (Greater16U x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVHZreg x) (MOVHZreg y)))
   279  (Greater8U  x y) -> (MOVDGT (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVBZreg x) (MOVBZreg y)))
   280  (Greater64F x y) -> (MOVDGTnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMP x y))
   281  (Greater32F x y) -> (MOVDGTnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y))
   282  
   283  (Geq64  x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   284  (Geq32  x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMPW x y))
   285  (Geq16  x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVHreg x) (MOVHreg y)))
   286  (Geq8   x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   287  (Geq64U x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMPU x y))
   288  (Geq32U x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMPWU x y))
   289  (Geq16U x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVHZreg x) (MOVHZreg y)))
   290  (Geq8U  x y) -> (MOVDGE (MOVDconst [0]) (MOVDconst [1]) (CMPU (MOVBZreg x) (MOVBZreg y)))
   291  (Geq64F x y) -> (MOVDGEnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMP x y))
   292  (Geq32F x y) -> (MOVDGEnoinv (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y))
   293  
   294  (Eq64  x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   295  (Eq32  x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (CMPW x y))
   296  (Eq16  x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVHreg x) (MOVHreg y)))
   297  (Eq8   x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   298  (EqB   x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   299  (EqPtr x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   300  (Eq64F x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (FCMP x y))
   301  (Eq32F x y) -> (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y))
   302  
   303  (Neq64  x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   304  (Neq32  x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (CMPW x y))
   305  (Neq16  x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVHreg x) (MOVHreg y)))
   306  (Neq8   x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   307  (NeqB   x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (CMP (MOVBreg x) (MOVBreg y)))
   308  (NeqPtr x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (CMP x y))
   309  (Neq64F x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (FCMP x y))
   310  (Neq32F x y) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (FCMPS x y))
   311  
   312  // Lowering loads
   313  (Load <t> ptr mem) && (is64BitInt(t) || isPtr(t)) -> (MOVDload ptr mem)
   314  (Load <t> ptr mem) && is32BitInt(t) && isSigned(t) -> (MOVWload ptr mem)
   315  (Load <t> ptr mem) && is32BitInt(t) && !isSigned(t) -> (MOVWZload ptr mem)
   316  (Load <t> ptr mem) && is16BitInt(t) && isSigned(t) -> (MOVHload ptr mem)
   317  (Load <t> ptr mem) && is16BitInt(t) && !isSigned(t) -> (MOVHZload ptr mem)
   318  (Load <t> ptr mem) && is8BitInt(t) && isSigned(t) -> (MOVBload ptr mem)
   319  (Load <t> ptr mem) && (t.IsBoolean() || (is8BitInt(t) && !isSigned(t))) -> (MOVBZload ptr mem)
   320  (Load <t> ptr mem) && is32BitFloat(t) -> (FMOVSload ptr mem)
   321  (Load <t> ptr mem) && is64BitFloat(t) -> (FMOVDload ptr mem)
   322  
   323  // Lowering stores
   324  // These more-specific FP versions of Store pattern should come first.
   325  (Store {t} ptr val mem) && t.(*types.Type).Size() == 8 && is64BitFloat(val.Type) -> (FMOVDstore ptr val mem)
   326  (Store {t} ptr val mem) && t.(*types.Type).Size() == 4 && is32BitFloat(val.Type) -> (FMOVSstore ptr val mem)
   327  
   328  (Store {t} ptr val mem) && t.(*types.Type).Size() == 8 -> (MOVDstore ptr val mem)
   329  (Store {t} ptr val mem) && t.(*types.Type).Size() == 4 -> (MOVWstore ptr val mem)
   330  (Store {t} ptr val mem) && t.(*types.Type).Size() == 2 -> (MOVHstore ptr val mem)
   331  (Store {t} ptr val mem) && t.(*types.Type).Size() == 1 -> (MOVBstore ptr val mem)
   332  
   333  // Lowering moves
   334  
   335  // Load and store for small copies.
   336  (Move [0] _ _ mem) -> mem
   337  (Move [1] dst src mem) -> (MOVBstore dst (MOVBZload src mem) mem)
   338  (Move [2] dst src mem) -> (MOVHstore dst (MOVHZload src mem) mem)
   339  (Move [4] dst src mem) -> (MOVWstore dst (MOVWZload src mem) mem)
   340  (Move [8] dst src mem) -> (MOVDstore dst (MOVDload src mem) mem)
   341  (Move [16] dst src mem) ->
   342  	(MOVDstore [8] dst (MOVDload [8] src mem)
   343  		(MOVDstore dst (MOVDload src mem) mem))
   344  (Move [24] dst src mem) ->
   345          (MOVDstore [16] dst (MOVDload [16] src mem)
   346  	        (MOVDstore [8] dst (MOVDload [8] src mem)
   347                  (MOVDstore dst (MOVDload src mem) mem)))
   348  (Move [3] dst src mem) ->
   349  	(MOVBstore [2] dst (MOVBZload [2] src mem)
   350  		(MOVHstore dst (MOVHZload src mem) mem))
   351  (Move [5] dst src mem) ->
   352  	(MOVBstore [4] dst (MOVBZload [4] src mem)
   353  		(MOVWstore dst (MOVWZload src mem) mem))
   354  (Move [6] dst src mem) ->
   355  	(MOVHstore [4] dst (MOVHZload [4] src mem)
   356  		(MOVWstore dst (MOVWZload src mem) mem))
   357  (Move [7] dst src mem) ->
   358  	(MOVBstore [6] dst (MOVBZload [6] src mem)
   359  		(MOVHstore [4] dst (MOVHZload [4] src mem)
   360  			(MOVWstore dst (MOVWZload src mem) mem)))
   361  
   362  // MVC for other moves. Use up to 4 instructions (sizes up to 1024 bytes).
   363  (Move [s] dst src mem) && s > 0 && s <= 256 ->
   364  	(MVC [makeValAndOff(s, 0)] dst src mem)
   365  (Move [s] dst src mem) && s > 256 && s <= 512 ->
   366  	(MVC [makeValAndOff(s-256, 256)] dst src (MVC [makeValAndOff(256, 0)] dst src mem))
   367  (Move [s] dst src mem) && s > 512 && s <= 768 ->
   368  	(MVC [makeValAndOff(s-512, 512)] dst src (MVC [makeValAndOff(256, 256)] dst src (MVC [makeValAndOff(256, 0)] dst src mem)))
   369  (Move [s] dst src mem) && s > 768 && s <= 1024 ->
   370  	(MVC [makeValAndOff(s-768, 768)] dst src (MVC [makeValAndOff(256, 512)] dst src (MVC [makeValAndOff(256, 256)] dst src (MVC [makeValAndOff(256, 0)] dst src mem))))
   371  
   372  // Move more than 1024 bytes using a loop.
   373  (Move [s] dst src mem) && s > 1024 ->
   374  	(LoweredMove [s%256] dst src (ADDconst <src.Type> src [(s/256)*256]) mem)
   375  
   376  // Lowering Zero instructions
   377  (Zero [0] _ mem) -> mem
   378  (Zero [1] destptr mem) -> (MOVBstoreconst [0] destptr mem)
   379  (Zero [2] destptr mem) -> (MOVHstoreconst [0] destptr mem)
   380  (Zero [4] destptr mem) -> (MOVWstoreconst [0] destptr mem)
   381  (Zero [8] destptr mem) -> (MOVDstoreconst [0] destptr mem)
   382  (Zero [3] destptr mem) ->
   383  	(MOVBstoreconst [makeValAndOff(0,2)] destptr
   384  		(MOVHstoreconst [0] destptr mem))
   385  (Zero [5] destptr mem) ->
   386  	(MOVBstoreconst [makeValAndOff(0,4)] destptr
   387  		(MOVWstoreconst [0] destptr mem))
   388  (Zero [6] destptr mem) ->
   389  	(MOVHstoreconst [makeValAndOff(0,4)] destptr
   390  		(MOVWstoreconst [0] destptr mem))
   391  (Zero [7] destptr mem) ->
   392  	(MOVWstoreconst [makeValAndOff(0,3)] destptr
   393  		(MOVWstoreconst [0] destptr mem))
   394  
   395  (Zero [s] destptr mem) && s > 0 && s <= 1024 ->
   396  	(CLEAR [makeValAndOff(s, 0)] destptr mem)
   397  
   398  // Move more than 1024 bytes using a loop.
   399  (Zero [s] destptr mem) && s > 1024 ->
   400  	(LoweredZero [s%256] destptr (ADDconst <destptr.Type> destptr [(s/256)*256]) mem)
   401  
   402  // Lowering constants
   403  (Const8   [val]) -> (MOVDconst [val])
   404  (Const16  [val]) -> (MOVDconst [val])
   405  (Const32  [val]) -> (MOVDconst [val])
   406  (Const64  [val]) -> (MOVDconst [val])
   407  (Const32F [val]) -> (FMOVSconst [val])
   408  (Const64F [val]) -> (FMOVDconst [val])
   409  (ConstNil) -> (MOVDconst [0])
   410  (ConstBool [b]) -> (MOVDconst [b])
   411  
   412  // Lowering calls
   413  (StaticCall [argwid] {target} mem) -> (CALLstatic [argwid] {target} mem)
   414  (ClosureCall [argwid] entry closure mem) -> (CALLclosure [argwid] entry closure mem)
   415  (InterCall [argwid] entry mem) -> (CALLinter [argwid] entry mem)
   416  
   417  // Miscellaneous
   418  (Convert <t> x mem) -> (MOVDconvert <t> x mem)
   419  (IsNonNil p) -> (MOVDNE (MOVDconst [0]) (MOVDconst [1]) (CMPconst p [0]))
   420  (IsInBounds idx len) -> (MOVDLT (MOVDconst [0]) (MOVDconst [1]) (CMPU idx len))
   421  (IsSliceInBounds idx len) -> (MOVDLE (MOVDconst [0]) (MOVDconst [1]) (CMPU idx len))
   422  (NilCheck ptr mem) -> (LoweredNilCheck ptr mem)
   423  (GetG mem) -> (LoweredGetG mem)
   424  (GetClosurePtr) -> (LoweredGetClosurePtr)
   425  (Addr {sym} base) -> (MOVDaddr {sym} base)
   426  (ITab (Load ptr mem)) -> (MOVDload ptr mem)
   427  
   428  // block rewrites
   429  (If (MOVDLT (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (LT cmp yes no)
   430  (If (MOVDLE (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (LE cmp yes no)
   431  (If (MOVDGT (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (GT cmp yes no)
   432  (If (MOVDGE (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (GE cmp yes no)
   433  (If (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (EQ cmp yes no)
   434  (If (MOVDNE (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (NE cmp yes no)
   435  
   436  // Special case for floating point - LF/LEF not generated.
   437  (If (MOVDGTnoinv (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (GTF cmp yes no)
   438  (If (MOVDGEnoinv (MOVDconst [0]) (MOVDconst [1]) cmp) yes no) -> (GEF cmp yes no)
   439  
   440  (If cond yes no) -> (NE (CMPWconst [0] (MOVBZreg <typ.Bool> cond)) yes no)
   441  
   442  // ***************************
   443  // Above: lowering rules
   444  // Below: optimizations
   445  // ***************************
   446  // TODO: Should the optimizations be a separate pass?
   447  
   448  // Fold unnecessary type conversions.
   449  (MOVDreg <t> x) && t.Compare(x.Type) == types.CMPeq -> x
   450  (MOVDnop <t> x) && t.Compare(x.Type) == types.CMPeq -> x
   451  
   452  // Propagate constants through type conversions.
   453  (MOVDreg (MOVDconst [c])) -> (MOVDconst [c])
   454  (MOVDnop (MOVDconst [c])) -> (MOVDconst [c])
   455  
   456  // If a register move has only 1 use, just use the same register without emitting instruction.
   457  // MOVDnop doesn't emit instruction, only for ensuring the type.
   458  (MOVDreg x) && x.Uses == 1 -> (MOVDnop x)
   459  
   460  // Fold type changes into loads.
   461  (MOVDreg <t> x:(MOVBZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBZload <t> [off] {sym} ptr mem)
   462  (MOVDreg <t> x:(MOVBload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBload  <t> [off] {sym} ptr mem)
   463  (MOVDreg <t> x:(MOVHZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHZload <t> [off] {sym} ptr mem)
   464  (MOVDreg <t> x:(MOVHload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHload  <t> [off] {sym} ptr mem)
   465  (MOVDreg <t> x:(MOVWZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWZload <t> [off] {sym} ptr mem)
   466  (MOVDreg <t> x:(MOVWload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWload  <t> [off] {sym} ptr mem)
   467  (MOVDreg <t> x:(MOVDload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVDload  <t> [off] {sym} ptr mem)
   468  
   469  (MOVDnop <t> x:(MOVBZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBZload <t> [off] {sym} ptr mem)
   470  (MOVDnop <t> x:(MOVBload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBload  <t> [off] {sym} ptr mem)
   471  (MOVDnop <t> x:(MOVHZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHZload <t> [off] {sym} ptr mem)
   472  (MOVDnop <t> x:(MOVHload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHload  <t> [off] {sym} ptr mem)
   473  (MOVDnop <t> x:(MOVWZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWZload <t> [off] {sym} ptr mem)
   474  (MOVDnop <t> x:(MOVWload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWload  <t> [off] {sym} ptr mem)
   475  (MOVDnop <t> x:(MOVDload  [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVDload  <t> [off] {sym} ptr mem)
   476  
   477  // TODO(mundaym): uncomment rules once signed indexed loads are added.
   478  (MOVDreg <t> x:(MOVBZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBZloadidx <t> [off] {sym} ptr idx mem)
   479  //(MOVDreg <t> x:(MOVBloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBloadidx  <t> [off] {sym} ptr idx mem)
   480  (MOVDreg <t> x:(MOVHZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHZloadidx <t> [off] {sym} ptr idx mem)
   481  //(MOVDreg <t> x:(MOVHloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHloadidx  <t> [off] {sym} ptr idx mem)
   482  (MOVDreg <t> x:(MOVWZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWZloadidx <t> [off] {sym} ptr idx mem)
   483  //(MOVDreg <t> x:(MOVWloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWloadidx  <t> [off] {sym} ptr idx mem)
   484  (MOVDreg <t> x:(MOVDloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVDloadidx  <t> [off] {sym} ptr idx mem)
   485  
   486  (MOVDnop <t> x:(MOVBZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBZloadidx <t> [off] {sym} ptr idx mem)
   487  //(MOVDnop <t> x:(MOVBloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBloadidx  <t> [off] {sym} ptr idx mem)
   488  (MOVDnop <t> x:(MOVHZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHZloadidx <t> [off] {sym} ptr idx mem)
   489  //(MOVDnop <t> x:(MOVHloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHloadidx  <t> [off] {sym} ptr idx mem)
   490  (MOVDnop <t> x:(MOVWZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWZloadidx <t> [off] {sym} ptr idx mem)
   491  //(MOVDnop <t> x:(MOVWloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWloadidx  <t> [off] {sym} ptr idx mem)
   492  (MOVDnop <t> x:(MOVDloadidx  [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVDloadidx  <t> [off] {sym} ptr idx mem)
   493  
   494  // Fold sign extensions into conditional moves of constants.
   495  // Designed to remove the MOVBZreg inserted by the If lowering.
   496  (MOVBZreg x:(MOVDLT (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   497  (MOVBZreg x:(MOVDLE (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   498  (MOVBZreg x:(MOVDGT (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   499  (MOVBZreg x:(MOVDGE (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   500  (MOVBZreg x:(MOVDEQ (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   501  (MOVBZreg x:(MOVDNE (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   502  (MOVBZreg x:(MOVDGTnoinv (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   503  (MOVBZreg x:(MOVDGEnoinv (MOVDconst [c]) (MOVDconst [d]) _)) && int64(uint8(c)) == c && int64(uint8(d)) == d -> (MOVDreg x)
   504  
   505  // Fold boolean tests into blocks.
   506  (NE (CMPWconst [0] (MOVDLT (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (LT cmp yes no)
   507  (NE (CMPWconst [0] (MOVDLE (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (LE cmp yes no)
   508  (NE (CMPWconst [0] (MOVDGT (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (GT cmp yes no)
   509  (NE (CMPWconst [0] (MOVDGE (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (GE cmp yes no)
   510  (NE (CMPWconst [0] (MOVDEQ (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (EQ cmp yes no)
   511  (NE (CMPWconst [0] (MOVDNE (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (NE cmp yes no)
   512  (NE (CMPWconst [0] (MOVDGTnoinv (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (GTF cmp yes no)
   513  (NE (CMPWconst [0] (MOVDGEnoinv (MOVDconst [0]) (MOVDconst [1]) cmp)) yes no) -> (GEF cmp yes no)
   514  
   515  // Fold constants into instructions.
   516  (ADD x (MOVDconst [c])) && is32Bit(c) -> (ADDconst [c] x)
   517  (ADDW x (MOVDconst [c])) -> (ADDWconst [c] x)
   518  
   519  (SUB x (MOVDconst [c])) && is32Bit(c) -> (SUBconst x [c])
   520  (SUB (MOVDconst [c]) x) && is32Bit(c) -> (NEG (SUBconst <v.Type> x [c]))
   521  (SUBW x (MOVDconst [c])) -> (SUBWconst x [c])
   522  (SUBW (MOVDconst [c]) x) -> (NEGW (SUBWconst <v.Type> x [c]))
   523  
   524  (MULLD x (MOVDconst [c])) && is32Bit(c) -> (MULLDconst [c] x)
   525  (MULLW x (MOVDconst [c])) -> (MULLWconst [c] x)
   526  
   527  // NILF instructions leave the high 32 bits unchanged which is
   528  // equivalent to the leftmost 32 bits being set.
   529  // TODO(mundaym): modify the assembler to accept 64-bit values
   530  // and use isU32Bit(^c).
   531  (AND x (MOVDconst [c])) && is32Bit(c) && c < 0 -> (ANDconst [c] x)
   532  (ANDW x (MOVDconst [c])) -> (ANDWconst [c] x)
   533  
   534  (ANDWconst [c] (ANDWconst [d] x)) -> (ANDWconst [c & d] x)
   535  (ANDconst [c] (ANDconst [d] x)) -> (ANDconst [c & d] x)
   536  
   537  (OR x (MOVDconst [c])) && isU32Bit(c) -> (ORconst [c] x)
   538  (ORW x (MOVDconst [c])) -> (ORWconst [c] x)
   539  
   540  (XOR x (MOVDconst [c])) && isU32Bit(c) -> (XORconst [c] x)
   541  (XORW x (MOVDconst [c])) -> (XORWconst [c] x)
   542  
   543  (SLD x (MOVDconst [c])) -> (SLDconst [c&63] x)
   544  (SLW x (MOVDconst [c])) -> (SLWconst [c&63] x)
   545  (SRD x (MOVDconst [c])) -> (SRDconst [c&63] x)
   546  (SRW x (MOVDconst [c])) -> (SRWconst [c&63] x)
   547  (SRAD x (MOVDconst [c])) -> (SRADconst [c&63] x)
   548  (SRAW x (MOVDconst [c])) -> (SRAWconst [c&63] x)
   549  
   550  (SRAW x (ANDWconst [63] y)) -> (SRAW x y)
   551  (SRAD x (ANDconst [63] y)) -> (SRAD x y)
   552  (SLW x (ANDWconst [63] y)) -> (SLW x y)
   553  (SLD x (ANDconst [63] y)) -> (SLD x y)
   554  (SRW x (ANDWconst [63] y)) -> (SRW x y)
   555  (SRD x (ANDconst [63] y)) -> (SRD x y)
   556  
   557  // Rotate generation
   558  (ADD (SLDconst x [c]) (SRDconst x [d])) && d == 64-c -> (RLLGconst [c] x)
   559  ( OR (SLDconst x [c]) (SRDconst x [d])) && d == 64-c -> (RLLGconst [c] x)
   560  (XOR (SLDconst x [c]) (SRDconst x [d])) && d == 64-c -> (RLLGconst [c] x)
   561  
   562  (ADDW (SLWconst x [c]) (SRWconst x [d])) && d == 32-c -> (RLLconst [c] x)
   563  ( ORW (SLWconst x [c]) (SRWconst x [d])) && d == 32-c -> (RLLconst [c] x)
   564  (XORW (SLWconst x [c]) (SRWconst x [d])) && d == 32-c -> (RLLconst [c] x)
   565  
   566  (CMP x (MOVDconst [c])) && is32Bit(c) -> (CMPconst x [c])
   567  (CMP (MOVDconst [c]) x) && is32Bit(c) -> (InvertFlags (CMPconst x [c]))
   568  (CMPW x (MOVDconst [c])) -> (CMPWconst x [c])
   569  (CMPW (MOVDconst [c]) x) -> (InvertFlags (CMPWconst x [c]))
   570  (CMPU x (MOVDconst [c])) && isU32Bit(c) -> (CMPUconst x [int64(uint32(c))])
   571  (CMPU (MOVDconst [c]) x) && isU32Bit(c) -> (InvertFlags (CMPUconst x [int64(uint32(c))]))
   572  (CMPWU x (MOVDconst [c])) -> (CMPWUconst x [int64(uint32(c))])
   573  (CMPWU (MOVDconst [c]) x) -> (InvertFlags (CMPWUconst x [int64(uint32(c))]))
   574  
   575  // Using MOV{W,H,B}Zreg instead of AND is cheaper.
   576  (AND x (MOVDconst [0xFF])) -> (MOVBZreg x)
   577  (AND x (MOVDconst [0xFFFF])) -> (MOVHZreg x)
   578  (AND x (MOVDconst [0xFFFFFFFF])) -> (MOVWZreg x)
   579  (ANDWconst [0xFF] x) -> (MOVBZreg x)
   580  (ANDWconst [0xFFFF] x) -> (MOVHZreg x)
   581  
   582  // strength reduction
   583  (MULLDconst [-1] x) -> (NEG x)
   584  (MULLDconst [0] _) -> (MOVDconst [0])
   585  (MULLDconst [1] x) -> x
   586  (MULLDconst [c] x) && isPowerOfTwo(c) -> (SLDconst [log2(c)] x)
   587  (MULLDconst [c] x) && isPowerOfTwo(c+1) && c >= 15 -> (SUB (SLDconst <v.Type> [log2(c+1)] x) x)
   588  (MULLDconst [c] x) && isPowerOfTwo(c-1) && c >= 17 -> (ADD (SLDconst <v.Type> [log2(c-1)] x) x)
   589  
   590  (MULLWconst [-1] x) -> (NEGW x)
   591  (MULLWconst [0] _) -> (MOVDconst [0])
   592  (MULLWconst [1] x) -> x
   593  (MULLWconst [c] x) && isPowerOfTwo(c) -> (SLWconst [log2(c)] x)
   594  (MULLWconst [c] x) && isPowerOfTwo(c+1) && c >= 15 -> (SUBW (SLWconst <v.Type> [log2(c+1)] x) x)
   595  (MULLWconst [c] x) && isPowerOfTwo(c-1) && c >= 17 -> (ADDW (SLWconst <v.Type> [log2(c-1)] x) x)
   596  
   597  // Fold ADD into MOVDaddr. Odd offsets from SB shouldn't be folded (LARL can't handle them).
   598  (ADDconst [c] (MOVDaddr [d] {s} x:(SB))) && ((c+d)&1 == 0) && is32Bit(c+d) -> (MOVDaddr [c+d] {s} x)
   599  (ADDconst [c] (MOVDaddr [d] {s} x)) && x.Op != OpSB && is20Bit(c+d) -> (MOVDaddr [c+d] {s} x)
   600  (ADD idx (MOVDaddr [c] {s} ptr)) && ptr.Op != OpSB && idx.Op != OpSB -> (MOVDaddridx [c] {s} ptr idx)
   601  
   602  // fold ADDconst into MOVDaddrx
   603  (ADDconst [c] (MOVDaddridx [d] {s} x y)) && is20Bit(c+d) -> (MOVDaddridx [c+d] {s} x y)
   604  (MOVDaddridx [c] {s} (ADDconst [d] x) y) && is20Bit(c+d) && x.Op != OpSB -> (MOVDaddridx [c+d] {s} x y)
   605  (MOVDaddridx [c] {s} x (ADDconst [d] y)) && is20Bit(c+d) && y.Op != OpSB -> (MOVDaddridx [c+d] {s} x y)
   606  
   607  // reverse ordering of compare instruction
   608  (MOVDLT x y (InvertFlags cmp)) -> (MOVDGT x y cmp)
   609  (MOVDGT x y (InvertFlags cmp)) -> (MOVDLT x y cmp)
   610  (MOVDLE x y (InvertFlags cmp)) -> (MOVDGE x y cmp)
   611  (MOVDGE x y (InvertFlags cmp)) -> (MOVDLE x y cmp)
   612  (MOVDEQ x y (InvertFlags cmp)) -> (MOVDEQ x y cmp)
   613  (MOVDNE x y (InvertFlags cmp)) -> (MOVDNE x y cmp)
   614  
   615  // don't extend after proper load
   616  (MOVBreg x:(MOVBload _ _)) -> (MOVDreg x)
   617  (MOVBZreg x:(MOVBZload _ _)) -> (MOVDreg x)
   618  (MOVHreg x:(MOVBload _ _)) -> (MOVDreg x)
   619  (MOVHreg x:(MOVBZload _ _)) -> (MOVDreg x)
   620  (MOVHreg x:(MOVHload _ _)) -> (MOVDreg x)
   621  (MOVHZreg x:(MOVBZload _ _)) -> (MOVDreg x)
   622  (MOVHZreg x:(MOVHZload _ _)) -> (MOVDreg x)
   623  (MOVWreg x:(MOVBload _ _)) -> (MOVDreg x)
   624  (MOVWreg x:(MOVBZload _ _)) -> (MOVDreg x)
   625  (MOVWreg x:(MOVHload _ _)) -> (MOVDreg x)
   626  (MOVWreg x:(MOVHZload _ _)) -> (MOVDreg x)
   627  (MOVWreg x:(MOVWload _ _)) -> (MOVDreg x)
   628  (MOVWZreg x:(MOVBZload _ _)) -> (MOVDreg x)
   629  (MOVWZreg x:(MOVHZload _ _)) -> (MOVDreg x)
   630  (MOVWZreg x:(MOVWZload _ _)) -> (MOVDreg x)
   631  
   632  // don't extend if argument is already extended
   633  (MOVBreg x:(Arg <t>)) && is8BitInt(t) && isSigned(t) -> (MOVDreg x)
   634  (MOVBZreg x:(Arg <t>)) && is8BitInt(t) && !isSigned(t) -> (MOVDreg x)
   635  (MOVHreg x:(Arg <t>)) && (is8BitInt(t) || is16BitInt(t)) && isSigned(t) -> (MOVDreg x)
   636  (MOVHZreg x:(Arg <t>)) && (is8BitInt(t) || is16BitInt(t)) && !isSigned(t) -> (MOVDreg x)
   637  (MOVWreg x:(Arg <t>)) && (is8BitInt(t) || is16BitInt(t) || is32BitInt(t)) && isSigned(t) -> (MOVDreg x)
   638  (MOVWZreg x:(Arg <t>)) && (is8BitInt(t) || is16BitInt(t) || is32BitInt(t)) && !isSigned(t) -> (MOVDreg x)
   639  
   640  // fold double extensions
   641  (MOVBreg x:(MOVBreg _)) -> (MOVDreg x)
   642  (MOVBZreg x:(MOVBZreg _)) -> (MOVDreg x)
   643  (MOVHreg x:(MOVBreg _)) -> (MOVDreg x)
   644  (MOVHreg x:(MOVBZreg _)) -> (MOVDreg x)
   645  (MOVHreg x:(MOVHreg _)) -> (MOVDreg x)
   646  (MOVHZreg x:(MOVBZreg _)) -> (MOVDreg x)
   647  (MOVHZreg x:(MOVHZreg _)) -> (MOVDreg x)
   648  (MOVWreg x:(MOVBreg _)) -> (MOVDreg x)
   649  (MOVWreg x:(MOVBZreg _)) -> (MOVDreg x)
   650  (MOVWreg x:(MOVHreg _)) -> (MOVDreg x)
   651  (MOVWreg x:(MOVHreg _)) -> (MOVDreg x)
   652  (MOVWreg x:(MOVWreg _)) -> (MOVDreg x)
   653  (MOVWZreg x:(MOVBZreg _)) -> (MOVDreg x)
   654  (MOVWZreg x:(MOVHZreg _)) -> (MOVDreg x)
   655  (MOVWZreg x:(MOVWZreg _)) -> (MOVDreg x)
   656  
   657  // fold extensions into constants
   658  (MOVBreg (MOVDconst [c])) -> (MOVDconst [int64(int8(c))])
   659  (MOVBZreg (MOVDconst [c])) -> (MOVDconst [int64(uint8(c))])
   660  (MOVHreg (MOVDconst [c])) -> (MOVDconst [int64(int16(c))])
   661  (MOVHZreg (MOVDconst [c])) -> (MOVDconst [int64(uint16(c))])
   662  (MOVWreg (MOVDconst [c])) -> (MOVDconst [int64(int32(c))])
   663  (MOVWZreg (MOVDconst [c])) -> (MOVDconst [int64(uint32(c))])
   664  
   665  // sign extended loads
   666  // Note: The combined instruction must end up in the same block
   667  // as the original load. If not, we end up making a value with
   668  // memory type live in two different blocks, which can lead to
   669  // multiple memory values alive simultaneously.
   670  // Make sure we don't combine these ops if the load has another use.
   671  // This prevents a single load from being split into multiple loads
   672  // which then might return different values.  See test/atomicload.go.
   673  (MOVBreg x:(MOVBZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBload <v.Type> [off] {sym} ptr mem)
   674  (MOVBZreg x:(MOVBZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBZload <v.Type> [off] {sym} ptr mem)
   675  (MOVHreg x:(MOVHZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHload <v.Type> [off] {sym} ptr mem)
   676  (MOVHZreg x:(MOVHZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHZload <v.Type> [off] {sym} ptr mem)
   677  (MOVWreg x:(MOVWZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWload <v.Type> [off] {sym} ptr mem)
   678  (MOVWZreg x:(MOVWZload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWZload <v.Type> [off] {sym} ptr mem)
   679  
   680  (MOVBZreg x:(MOVBZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVBZloadidx <v.Type> [off] {sym} ptr idx mem)
   681  (MOVHZreg x:(MOVHZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVHZloadidx <v.Type> [off] {sym} ptr idx mem)
   682  (MOVWZreg x:(MOVWZloadidx [off] {sym} ptr idx mem)) && x.Uses == 1 && clobber(x) -> @x.Block (MOVWZloadidx <v.Type> [off] {sym} ptr idx mem)
   683  
   684  // replace load from same location as preceding store with copy
   685  (MOVBZload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVBZreg x)
   686  (MOVHZload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVHZreg x)
   687  (MOVWZload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVWZreg x)
   688  (MOVDload [off] {sym} ptr (MOVDstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVDreg x)
   689  
   690  // Don't extend before storing
   691  (MOVWstore [off] {sym} ptr (MOVWreg x) mem) -> (MOVWstore [off] {sym} ptr x mem)
   692  (MOVHstore [off] {sym} ptr (MOVHreg x) mem) -> (MOVHstore [off] {sym} ptr x mem)
   693  (MOVBstore [off] {sym} ptr (MOVBreg x) mem) -> (MOVBstore [off] {sym} ptr x mem)
   694  (MOVWstore [off] {sym} ptr (MOVWZreg x) mem) -> (MOVWstore [off] {sym} ptr x mem)
   695  (MOVHstore [off] {sym} ptr (MOVHZreg x) mem) -> (MOVHstore [off] {sym} ptr x mem)
   696  (MOVBstore [off] {sym} ptr (MOVBZreg x) mem) -> (MOVBstore [off] {sym} ptr x mem)
   697  
   698  // Fold constants into memory operations.
   699  // Note that this is not always a good idea because if not all the uses of
   700  // the ADDconst get eliminated, we still have to compute the ADDconst and we now
   701  // have potentially two live values (ptr and (ADDconst [off] ptr)) instead of one.
   702  // Nevertheless, let's do it!
   703  (MOVDload   [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (MOVDload  [off1+off2] {sym} ptr mem)
   704  (MOVWload   [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (MOVWload  [off1+off2] {sym} ptr mem)
   705  (MOVHload   [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (MOVHload  [off1+off2] {sym} ptr mem)
   706  (MOVBload   [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (MOVBload  [off1+off2] {sym} ptr mem)
   707  (MOVWZload  [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (MOVWZload [off1+off2] {sym} ptr mem)
   708  (MOVHZload  [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (MOVHZload [off1+off2] {sym} ptr mem)
   709  (MOVBZload  [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (MOVBZload [off1+off2] {sym} ptr mem)
   710  (FMOVSload  [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (FMOVSload [off1+off2] {sym} ptr mem)
   711  (FMOVDload  [off1] {sym} (ADDconst [off2] ptr) mem) && is20Bit(off1+off2) -> (FMOVDload [off1+off2] {sym} ptr mem)
   712  
   713  (MOVDstore  [off1] {sym} (ADDconst [off2] ptr) val mem) && is20Bit(off1+off2) -> (MOVDstore  [off1+off2] {sym} ptr val mem)
   714  (MOVWstore  [off1] {sym} (ADDconst [off2] ptr) val mem) && is20Bit(off1+off2) -> (MOVWstore  [off1+off2] {sym} ptr val mem)
   715  (MOVHstore  [off1] {sym} (ADDconst [off2] ptr) val mem) && is20Bit(off1+off2) -> (MOVHstore  [off1+off2] {sym} ptr val mem)
   716  (MOVBstore  [off1] {sym} (ADDconst [off2] ptr) val mem) && is20Bit(off1+off2) -> (MOVBstore  [off1+off2] {sym} ptr val mem)
   717  (FMOVSstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is20Bit(off1+off2) -> (FMOVSstore [off1+off2] {sym} ptr val mem)
   718  (FMOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is20Bit(off1+off2) -> (FMOVDstore [off1+off2] {sym} ptr val mem)
   719  
   720  // Fold constants into stores.
   721  (MOVDstore [off] {sym} ptr (MOVDconst [c]) mem) && is16Bit(c) && isU12Bit(off) && ptr.Op != OpSB ->
   722  	(MOVDstoreconst [makeValAndOff(c,off)] {sym} ptr mem)
   723  (MOVWstore [off] {sym} ptr (MOVDconst [c]) mem) && is16Bit(c) && isU12Bit(off) && ptr.Op != OpSB ->
   724  	(MOVWstoreconst [makeValAndOff(int64(int32(c)),off)] {sym} ptr mem)
   725  (MOVHstore [off] {sym} ptr (MOVDconst [c]) mem) && isU12Bit(off) && ptr.Op != OpSB ->
   726  	(MOVHstoreconst [makeValAndOff(int64(int16(c)),off)] {sym} ptr mem)
   727  (MOVBstore [off] {sym} ptr (MOVDconst [c]) mem) && is20Bit(off) && ptr.Op != OpSB ->
   728  	(MOVBstoreconst [makeValAndOff(int64(int8(c)),off)] {sym} ptr mem)
   729  
   730  // Fold address offsets into constant stores.
   731  (MOVDstoreconst [sc] {s} (ADDconst [off] ptr) mem) && isU12Bit(ValAndOff(sc).Off()+off) ->
   732  	(MOVDstoreconst [ValAndOff(sc).add(off)] {s} ptr mem)
   733  (MOVWstoreconst [sc] {s} (ADDconst [off] ptr) mem) && isU12Bit(ValAndOff(sc).Off()+off) ->
   734  	(MOVWstoreconst [ValAndOff(sc).add(off)] {s} ptr mem)
   735  (MOVHstoreconst [sc] {s} (ADDconst [off] ptr) mem) && isU12Bit(ValAndOff(sc).Off()+off) ->
   736  	(MOVHstoreconst [ValAndOff(sc).add(off)] {s} ptr mem)
   737  (MOVBstoreconst [sc] {s} (ADDconst [off] ptr) mem) && is20Bit(ValAndOff(sc).Off()+off) ->
   738  	(MOVBstoreconst [ValAndOff(sc).add(off)] {s} ptr mem)
   739  
   740  // We need to fold MOVDaddr into the MOVx ops so that the live variable analysis knows
   741  // what variables are being read/written by the ops.
   742  (MOVDload  [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   743  	(MOVDload  [off1+off2] {mergeSym(sym1,sym2)} base mem)
   744  (MOVWZload  [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   745  	(MOVWZload  [off1+off2] {mergeSym(sym1,sym2)} base mem)
   746  (MOVHZload  [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   747  	(MOVHZload  [off1+off2] {mergeSym(sym1,sym2)} base mem)
   748  (MOVBZload  [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   749  	(MOVBZload  [off1+off2] {mergeSym(sym1,sym2)} base mem)
   750  (FMOVSload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   751  	(FMOVSload [off1+off2] {mergeSym(sym1,sym2)} base mem)
   752  (FMOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   753  	(FMOVDload [off1+off2] {mergeSym(sym1,sym2)} base mem)
   754  
   755  (MOVBload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   756  	(MOVBload [off1+off2] {mergeSym(sym1,sym2)} base mem)
   757  (MOVHload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   758  	(MOVHload [off1+off2] {mergeSym(sym1,sym2)} base mem)
   759  (MOVWload [off1] {sym1} (MOVDaddr [off2] {sym2} base) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   760  	(MOVWload [off1+off2] {mergeSym(sym1,sym2)} base mem)
   761  
   762  (MOVDstore  [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   763  	(MOVDstore  [off1+off2] {mergeSym(sym1,sym2)} base val mem)
   764  (MOVWstore  [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   765  	(MOVWstore  [off1+off2] {mergeSym(sym1,sym2)} base val mem)
   766  (MOVHstore  [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   767  	(MOVHstore  [off1+off2] {mergeSym(sym1,sym2)} base val mem)
   768  (MOVBstore  [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   769  	(MOVBstore  [off1+off2] {mergeSym(sym1,sym2)} base val mem)
   770  (FMOVSstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   771  	(FMOVSstore [off1+off2] {mergeSym(sym1,sym2)} base val mem)
   772  (FMOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} base) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   773  	(FMOVDstore [off1+off2] {mergeSym(sym1,sym2)} base val mem)
   774  
   775  // Cannot store constant to SB directly (no 'move relative long immediate' instructions).
   776  (MOVDstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) && ptr.Op != OpSB && canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd(off) ->
   777  	(MOVDstoreconst [ValAndOff(sc).add(off)] {mergeSym(sym1, sym2)} ptr mem)
   778  (MOVWstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) && ptr.Op != OpSB && canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd(off) ->
   779  	(MOVWstoreconst [ValAndOff(sc).add(off)] {mergeSym(sym1, sym2)} ptr mem)
   780  (MOVHstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) && ptr.Op != OpSB && canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd(off) ->
   781  	(MOVHstoreconst [ValAndOff(sc).add(off)] {mergeSym(sym1, sym2)} ptr mem)
   782  (MOVBstoreconst [sc] {sym1} (MOVDaddr [off] {sym2} ptr) mem) && ptr.Op != OpSB && canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd(off) ->
   783  	(MOVBstoreconst [ValAndOff(sc).add(off)] {mergeSym(sym1, sym2)} ptr mem)
   784  
   785  // generating indexed loads and stores
   786  (MOVBZload [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   787  	(MOVBZloadidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx mem)
   788  (MOVHZload [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   789  	(MOVHZloadidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx mem)
   790  (MOVWZload [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   791  	(MOVWZloadidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx mem)
   792  (MOVDload [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   793  	(MOVDloadidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx mem)
   794  (FMOVSload [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   795  	(FMOVSloadidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx mem)
   796  (FMOVDload [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   797  	(FMOVDloadidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx mem)
   798  
   799  (MOVBstore [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   800  	(MOVBstoreidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx val mem)
   801  (MOVHstore [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   802  	(MOVHstoreidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx val mem)
   803  (MOVWstore [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   804  	(MOVWstoreidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx val mem)
   805  (MOVDstore [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   806  	(MOVDstoreidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx val mem)
   807  (FMOVSstore [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   808  	(FMOVSstoreidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx val mem)
   809  (FMOVDstore [off1] {sym1} (MOVDaddridx [off2] {sym2} ptr idx) val mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
   810  	(FMOVDstoreidx [off1+off2] {mergeSym(sym1,sym2)} ptr idx val mem)
   811  
   812  (MOVBZload [off] {sym} (ADD ptr idx) mem) && ptr.Op != OpSB -> (MOVBZloadidx [off] {sym} ptr idx mem)
   813  (MOVHZload [off] {sym} (ADD ptr idx) mem) && ptr.Op != OpSB -> (MOVHZloadidx [off] {sym} ptr idx mem)
   814  (MOVWZload [off] {sym} (ADD ptr idx) mem) && ptr.Op != OpSB -> (MOVWZloadidx [off] {sym} ptr idx mem)
   815  (MOVDload [off] {sym} (ADD ptr idx) mem) && ptr.Op != OpSB -> (MOVDloadidx [off] {sym} ptr idx mem)
   816  (FMOVSload [off] {sym} (ADD ptr idx) mem) && ptr.Op != OpSB -> (FMOVSloadidx [off] {sym} ptr idx mem)
   817  (FMOVDload [off] {sym} (ADD ptr idx) mem) && ptr.Op != OpSB -> (FMOVDloadidx [off] {sym} ptr idx mem)
   818  (MOVBstore [off] {sym} (ADD ptr idx) val mem) && ptr.Op != OpSB -> (MOVBstoreidx [off] {sym} ptr idx val mem)
   819  (MOVHstore [off] {sym} (ADD ptr idx) val mem) && ptr.Op != OpSB -> (MOVHstoreidx [off] {sym} ptr idx val mem)
   820  (MOVWstore [off] {sym} (ADD ptr idx) val mem) && ptr.Op != OpSB -> (MOVWstoreidx [off] {sym} ptr idx val mem)
   821  (MOVDstore [off] {sym} (ADD ptr idx) val mem) && ptr.Op != OpSB -> (MOVDstoreidx [off] {sym} ptr idx val mem)
   822  (FMOVSstore [off] {sym} (ADD ptr idx) val mem) && ptr.Op != OpSB -> (FMOVSstoreidx [off] {sym} ptr idx val mem)
   823  (FMOVDstore [off] {sym} (ADD ptr idx) val mem) && ptr.Op != OpSB -> (FMOVDstoreidx [off] {sym} ptr idx val mem)
   824  
   825  // combine ADD into indexed loads and stores
   826  (MOVBZloadidx [c] {sym} (ADDconst [d] ptr) idx mem) -> (MOVBZloadidx [c+d] {sym} ptr idx mem)
   827  (MOVHZloadidx [c] {sym} (ADDconst [d] ptr) idx mem) -> (MOVHZloadidx [c+d] {sym} ptr idx mem)
   828  (MOVWZloadidx [c] {sym} (ADDconst [d] ptr) idx mem) -> (MOVWZloadidx [c+d] {sym} ptr idx mem)
   829  (MOVDloadidx [c] {sym} (ADDconst [d] ptr) idx mem) -> (MOVDloadidx [c+d] {sym} ptr idx mem)
   830  (FMOVSloadidx [c] {sym} (ADDconst [d] ptr) idx mem) -> (FMOVSloadidx [c+d] {sym} ptr idx mem)
   831  (FMOVDloadidx [c] {sym} (ADDconst [d] ptr) idx mem) -> (FMOVDloadidx [c+d] {sym} ptr idx mem)
   832  
   833  (MOVBstoreidx [c] {sym} (ADDconst [d] ptr) idx val mem) -> (MOVBstoreidx [c+d] {sym} ptr idx val mem)
   834  (MOVHstoreidx [c] {sym} (ADDconst [d] ptr) idx val mem) -> (MOVHstoreidx [c+d] {sym} ptr idx val mem)
   835  (MOVWstoreidx [c] {sym} (ADDconst [d] ptr) idx val mem) -> (MOVWstoreidx [c+d] {sym} ptr idx val mem)
   836  (MOVDstoreidx [c] {sym} (ADDconst [d] ptr) idx val mem) -> (MOVDstoreidx [c+d] {sym} ptr idx val mem)
   837  (FMOVSstoreidx [c] {sym} (ADDconst [d] ptr) idx val mem) -> (FMOVSstoreidx [c+d] {sym} ptr idx val mem)
   838  (FMOVDstoreidx [c] {sym} (ADDconst [d] ptr) idx val mem) -> (FMOVDstoreidx [c+d] {sym} ptr idx val mem)
   839  
   840  (MOVBZloadidx [c] {sym} ptr (ADDconst [d] idx) mem) -> (MOVBZloadidx [c+d] {sym} ptr idx mem)
   841  (MOVHZloadidx [c] {sym} ptr (ADDconst [d] idx) mem) -> (MOVHZloadidx [c+d] {sym} ptr idx mem)
   842  (MOVWZloadidx [c] {sym} ptr (ADDconst [d] idx) mem) -> (MOVWZloadidx [c+d] {sym} ptr idx mem)
   843  (MOVDloadidx [c] {sym} ptr (ADDconst [d] idx) mem) -> (MOVDloadidx [c+d] {sym} ptr idx mem)
   844  (FMOVSloadidx [c] {sym} ptr (ADDconst [d] idx) mem) -> (FMOVSloadidx [c+d] {sym} ptr idx mem)
   845  (FMOVDloadidx [c] {sym} ptr (ADDconst [d] idx) mem) -> (FMOVDloadidx [c+d] {sym} ptr idx mem)
   846  
   847  (MOVBstoreidx [c] {sym} ptr (ADDconst [d] idx) val mem) -> (MOVBstoreidx [c+d] {sym} ptr idx val mem)
   848  (MOVHstoreidx [c] {sym} ptr (ADDconst [d] idx) val mem) -> (MOVHstoreidx [c+d] {sym} ptr idx val mem)
   849  (MOVWstoreidx [c] {sym} ptr (ADDconst [d] idx) val mem) -> (MOVWstoreidx [c+d] {sym} ptr idx val mem)
   850  (MOVDstoreidx [c] {sym} ptr (ADDconst [d] idx) val mem) -> (MOVDstoreidx [c+d] {sym} ptr idx val mem)
   851  (FMOVSstoreidx [c] {sym} ptr (ADDconst [d] idx) val mem) -> (FMOVSstoreidx [c+d] {sym} ptr idx val mem)
   852  (FMOVDstoreidx [c] {sym} ptr (ADDconst [d] idx) val mem) -> (FMOVDstoreidx [c+d] {sym} ptr idx val mem)
   853  
   854  // MOVDaddr into MOVDaddridx
   855  (MOVDaddridx [off1] {sym1} (MOVDaddr [off2] {sym2} x) y) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) && x.Op != OpSB ->
   856         (MOVDaddridx [off1+off2] {mergeSym(sym1,sym2)} x y)
   857  (MOVDaddridx [off1] {sym1} x (MOVDaddr [off2] {sym2} y)) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) && y.Op != OpSB ->
   858         (MOVDaddridx [off1+off2] {mergeSym(sym1,sym2)} x y)
   859  
   860  // Absorb InvertFlags into branches.
   861  (LT (InvertFlags cmp) yes no) -> (GT cmp yes no)
   862  (GT (InvertFlags cmp) yes no) -> (LT cmp yes no)
   863  (LE (InvertFlags cmp) yes no) -> (GE cmp yes no)
   864  (GE (InvertFlags cmp) yes no) -> (LE cmp yes no)
   865  (EQ (InvertFlags cmp) yes no) -> (EQ cmp yes no)
   866  (NE (InvertFlags cmp) yes no) -> (NE cmp yes no)
   867  
   868  // Constant comparisons.
   869  (CMPconst (MOVDconst [x]) [y]) && x==y -> (FlagEQ)
   870  (CMPconst (MOVDconst [x]) [y]) && x<y -> (FlagLT)
   871  (CMPconst (MOVDconst [x]) [y]) && x>y -> (FlagGT)
   872  (CMPUconst (MOVDconst [x]) [y]) && uint64(x)==uint64(y) -> (FlagEQ)
   873  (CMPUconst (MOVDconst [x]) [y]) && uint64(x)<uint64(y) -> (FlagLT)
   874  (CMPUconst (MOVDconst [x]) [y]) && uint64(x)>uint64(y) -> (FlagGT)
   875  
   876  (CMPWconst (MOVDconst [x]) [y]) && int32(x)==int32(y) -> (FlagEQ)
   877  (CMPWconst (MOVDconst [x]) [y]) && int32(x)<int32(y) -> (FlagLT)
   878  (CMPWconst (MOVDconst [x]) [y]) && int32(x)>int32(y) -> (FlagGT)
   879  (CMPWUconst (MOVDconst [x]) [y]) && uint32(x)==uint32(y) -> (FlagEQ)
   880  (CMPWUconst (MOVDconst [x]) [y]) && uint32(x)<uint32(y) -> (FlagLT)
   881  (CMPWUconst (MOVDconst [x]) [y]) && uint32(x)>uint32(y) -> (FlagGT)
   882  
   883  // Other known comparisons.
   884  (CMPconst (MOVBZreg _) [c]) && 0xFF < c -> (FlagLT)
   885  (CMPconst (MOVHZreg _) [c]) && 0xFFFF < c -> (FlagLT)
   886  (CMPconst (MOVWZreg _) [c]) && 0xFFFFFFFF < c -> (FlagLT)
   887  (CMPWconst (SRWconst _ [c]) [n]) && 0 <= n && 0 < c && c <= 32 && (1<<uint64(32-c)) <= uint64(n) -> (FlagLT)
   888  (CMPconst (SRDconst _ [c]) [n]) && 0 <= n && 0 < c && c <= 64 && (1<<uint64(64-c)) <= uint64(n) -> (FlagLT)
   889  (CMPconst (ANDconst _ [m]) [n]) && 0 <= m && m < n -> (FlagLT)
   890  (CMPWconst (ANDWconst _ [m]) [n]) && 0 <= int32(m) && int32(m) < int32(n) -> (FlagLT)
   891  
   892  // Absorb flag constants into SBB ops.
   893  (SUBEcarrymask (FlagEQ)) -> (MOVDconst [-1])
   894  (SUBEcarrymask (FlagLT)) -> (MOVDconst [-1])
   895  (SUBEcarrymask (FlagGT)) -> (MOVDconst [0])
   896  (SUBEWcarrymask (FlagEQ)) -> (MOVDconst [-1])
   897  (SUBEWcarrymask (FlagLT)) -> (MOVDconst [-1])
   898  (SUBEWcarrymask (FlagGT)) -> (MOVDconst [0])
   899  
   900  // Absorb flag constants into branches.
   901  (EQ (FlagEQ) yes no) -> (First nil yes no)
   902  (EQ (FlagLT) yes no) -> (First nil no yes)
   903  (EQ (FlagGT) yes no) -> (First nil no yes)
   904  
   905  (NE (FlagEQ) yes no) -> (First nil no yes)
   906  (NE (FlagLT) yes no) -> (First nil yes no)
   907  (NE (FlagGT) yes no) -> (First nil yes no)
   908  
   909  (LT (FlagEQ) yes no) -> (First nil no yes)
   910  (LT (FlagLT) yes no) -> (First nil yes no)
   911  (LT (FlagGT) yes no) -> (First nil no yes)
   912  
   913  (LE (FlagEQ) yes no) -> (First nil yes no)
   914  (LE (FlagLT) yes no) -> (First nil yes no)
   915  (LE (FlagGT) yes no) -> (First nil no yes)
   916  
   917  (GT (FlagEQ) yes no) -> (First nil no yes)
   918  (GT (FlagLT) yes no) -> (First nil no yes)
   919  (GT (FlagGT) yes no) -> (First nil yes no)
   920  
   921  (GE (FlagEQ) yes no) -> (First nil yes no)
   922  (GE (FlagLT) yes no) -> (First nil no yes)
   923  (GE (FlagGT) yes no) -> (First nil yes no)
   924  
   925  // Absorb flag constants into SETxx ops.
   926  (MOVDEQ _ x (FlagEQ)) -> x
   927  (MOVDEQ y _ (FlagLT)) -> y
   928  (MOVDEQ y _ (FlagGT)) -> y
   929  
   930  (MOVDNE y _ (FlagEQ)) -> y
   931  (MOVDNE _ x (FlagLT)) -> x
   932  (MOVDNE _ x (FlagGT)) -> x
   933  
   934  (MOVDLT y _ (FlagEQ)) -> y
   935  (MOVDLT _ x (FlagLT)) -> x
   936  (MOVDLT y _ (FlagGT)) -> y
   937  
   938  (MOVDLE _ x (FlagEQ)) -> x
   939  (MOVDLE _ x (FlagLT)) -> x
   940  (MOVDLE y _ (FlagGT)) -> y
   941  
   942  (MOVDGT y _ (FlagEQ)) -> y
   943  (MOVDGT y _ (FlagLT)) -> y
   944  (MOVDGT _ x (FlagGT)) -> x
   945  
   946  (MOVDGE _ x (FlagEQ)) -> x
   947  (MOVDGE y _ (FlagLT)) -> y
   948  (MOVDGE _ x (FlagGT)) -> x
   949  
   950  // Remove redundant *const ops
   951  (ADDconst [0] x) -> x
   952  (ADDWconst [c] x) && int32(c)==0 -> x
   953  (SUBconst [0] x) -> x
   954  (SUBWconst [c] x) && int32(c) == 0 -> x
   955  (ANDconst [0] _)                 -> (MOVDconst [0])
   956  (ANDWconst [c] _) && int32(c)==0  -> (MOVDconst [0])
   957  (ANDconst [-1] x)                -> x
   958  (ANDWconst [c] x) && int32(c)==-1 -> x
   959  (ORconst [0] x)                  -> x
   960  (ORWconst [c] x) && int32(c)==0   -> x
   961  (ORconst [-1] _)                 -> (MOVDconst [-1])
   962  (ORWconst [c] _) && int32(c)==-1  -> (MOVDconst [-1])
   963  (XORconst [0] x)                  -> x
   964  (XORWconst [c] x) && int32(c)==0   -> x
   965  
   966  // Convert constant subtracts to constant adds.
   967  (SUBconst [c] x) && c != -(1<<31) -> (ADDconst [-c] x)
   968  (SUBWconst [c] x) -> (ADDWconst [int64(int32(-c))] x)
   969  
   970  // generic constant folding
   971  // TODO: more of this
   972  (ADDconst [c] (MOVDconst [d])) -> (MOVDconst [c+d])
   973  (ADDWconst [c] (MOVDconst [d])) -> (MOVDconst [int64(int32(c+d))])
   974  (ADDconst [c] (ADDconst [d] x)) && is32Bit(c+d) -> (ADDconst [c+d] x)
   975  (ADDWconst [c] (ADDWconst [d] x)) -> (ADDWconst [int64(int32(c+d))] x)
   976  (SUBconst (MOVDconst [d]) [c]) -> (MOVDconst [d-c])
   977  (SUBconst (SUBconst x [d]) [c]) && is32Bit(-c-d) -> (ADDconst [-c-d] x)
   978  (SRADconst [c] (MOVDconst [d])) -> (MOVDconst [d>>uint64(c)])
   979  (SRAWconst [c] (MOVDconst [d])) -> (MOVDconst [d>>uint64(c)])
   980  (NEG (MOVDconst [c])) -> (MOVDconst [-c])
   981  (NEGW (MOVDconst [c])) -> (MOVDconst [int64(int32(-c))])
   982  (MULLDconst [c] (MOVDconst [d])) -> (MOVDconst [c*d])
   983  (MULLWconst [c] (MOVDconst [d])) -> (MOVDconst [int64(int32(c*d))])
   984  (AND (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [c&d])
   985  (ANDconst [c] (MOVDconst [d])) -> (MOVDconst [c&d])
   986  (ANDWconst [c] (MOVDconst [d])) -> (MOVDconst [c&d])
   987  (OR (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [c|d])
   988  (ORconst [c] (MOVDconst [d])) -> (MOVDconst [c|d])
   989  (ORWconst [c] (MOVDconst [d])) -> (MOVDconst [c|d])
   990  (XOR (MOVDconst [c]) (MOVDconst [d])) -> (MOVDconst [c^d])
   991  (XORconst [c] (MOVDconst [d])) -> (MOVDconst [c^d])
   992  (XORWconst [c] (MOVDconst [d])) -> (MOVDconst [c^d])
   993  (LoweredRound32F x:(FMOVSconst)) -> x
   994  (LoweredRound64F x:(FMOVDconst)) -> x
   995  
   996  // generic simplifications
   997  // TODO: more of this
   998  (ADD x (NEG y)) -> (SUB x y)
   999  (ADDW x (NEGW y)) -> (SUBW x y)
  1000  (SUB x x) -> (MOVDconst [0])
  1001  (SUBW x x) -> (MOVDconst [0])
  1002  (AND x x) -> x
  1003  (ANDW x x) -> x
  1004  (OR x x) -> x
  1005  (ORW x x) -> x
  1006  (XOR x x) -> (MOVDconst [0])
  1007  (XORW x x) -> (MOVDconst [0])
  1008  (NEG (ADDconst [c] (NEG x))) && c != -(1<<31) -> (ADDconst [-c] x)
  1009  
  1010  // fused multiply-add
  1011  (FADD (FMUL y z) x) -> (FMADD x y z)
  1012  (FADDS (FMULS y z) x) -> (FMADDS x y z)
  1013  (FSUB (FMUL y z) x) -> (FMSUB x y z)
  1014  (FSUBS (FMULS y z) x) -> (FMSUBS x y z)
  1015  
  1016  // Fold memory operations into operations.
  1017  // Exclude global data (SB) because these instructions cannot handle relative addresses.
  1018  // TODO(mundaym): use LARL in the assembler to handle SB?
  1019  // TODO(mundaym): indexed versions of these?
  1020  (ADD <t> x g:(MOVDload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1021  	-> (ADDload <t> [off] {sym} x ptr mem)
  1022  (ADD <t> g:(MOVDload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1023  	-> (ADDload <t> [off] {sym} x ptr mem)
  1024  (ADDW <t> x g:(MOVWload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1025  	-> (ADDWload <t> [off] {sym} x ptr mem)
  1026  (ADDW <t> g:(MOVWload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1027  	-> (ADDWload <t> [off] {sym} x ptr mem)
  1028  (ADDW <t> x g:(MOVWZload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1029  	-> (ADDWload <t> [off] {sym} x ptr mem)
  1030  (ADDW <t> g:(MOVWZload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1031  	-> (ADDWload <t> [off] {sym} x ptr mem)
  1032  (MULLD <t> x g:(MOVDload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1033  	-> (MULLDload <t> [off] {sym} x ptr mem)
  1034  (MULLD <t> g:(MOVDload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1035  	-> (MULLDload <t> [off] {sym} x ptr mem)
  1036  (MULLW <t> x g:(MOVWload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1037  	-> (MULLWload <t> [off] {sym} x ptr mem)
  1038  (MULLW <t> g:(MOVWload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1039  	-> (MULLWload <t> [off] {sym} x ptr mem)
  1040  (MULLW <t> x g:(MOVWZload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1041  	-> (MULLWload <t> [off] {sym} x ptr mem)
  1042  (MULLW <t> g:(MOVWZload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1043  	-> (MULLWload <t> [off] {sym} x ptr mem)
  1044  (SUB <t> x g:(MOVDload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1045  	-> (SUBload <t> [off] {sym} x ptr mem)
  1046  (SUBW <t> x g:(MOVWload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1047  	-> (SUBWload <t> [off] {sym} x ptr mem)
  1048  (SUBW <t> x g:(MOVWZload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1049  	-> (SUBWload <t> [off] {sym} x ptr mem)
  1050  (AND <t> x g:(MOVDload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1051  	-> (ANDload <t> [off] {sym} x ptr mem)
  1052  (AND <t> g:(MOVDload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1053  	-> (ANDload <t> [off] {sym} x ptr mem)
  1054  (ANDW <t> x g:(MOVWload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1055  	-> (ANDWload <t> [off] {sym} x ptr mem)
  1056  (ANDW <t> g:(MOVWload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1057  	-> (ANDWload <t> [off] {sym} x ptr mem)
  1058  (ANDW <t> x g:(MOVWZload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1059  	-> (ANDWload <t> [off] {sym} x ptr mem)
  1060  (ANDW <t> g:(MOVWZload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1061  	-> (ANDWload <t> [off] {sym} x ptr mem)
  1062  (OR <t> x g:(MOVDload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1063  	-> (ORload <t> [off] {sym} x ptr mem)
  1064  (OR <t> g:(MOVDload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1065  	-> (ORload <t> [off] {sym} x ptr mem)
  1066  (ORW <t> x g:(MOVWload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1067  	-> (ORWload <t> [off] {sym} x ptr mem)
  1068  (ORW <t> g:(MOVWload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1069  	-> (ORWload <t> [off] {sym} x ptr mem)
  1070  (ORW <t> x g:(MOVWZload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1071  	-> (ORWload <t> [off] {sym} x ptr mem)
  1072  (ORW <t> g:(MOVWZload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1073  	-> (ORWload <t> [off] {sym} x ptr mem)
  1074  (XOR <t> x g:(MOVDload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1075  	-> (XORload <t> [off] {sym} x ptr mem)
  1076  (XOR <t> g:(MOVDload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1077  	-> (XORload <t> [off] {sym} x ptr mem)
  1078  (XORW <t> x g:(MOVWload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1079  	-> (XORWload <t> [off] {sym} x ptr mem)
  1080  (XORW <t> g:(MOVWload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1081  	-> (XORWload <t> [off] {sym} x ptr mem)
  1082  (XORW <t> x g:(MOVWZload [off] {sym} ptr mem)) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1083  	-> (XORWload <t> [off] {sym} x ptr mem)
  1084  (XORW <t> g:(MOVWZload [off] {sym} ptr mem) x) && ptr.Op != OpSB && is20Bit(off) && canMergeLoad(v, g, x) && clobber(g)
  1085  	-> (XORWload <t> [off] {sym} x ptr mem)
  1086  
  1087  // Combine constant stores into larger (unaligned) stores.
  1088  // Avoid SB because constant stores to relative offsets are
  1089  // emulated by the assembler and also can't handle unaligned offsets.
  1090  (MOVBstoreconst [c] {s} p x:(MOVBstoreconst [a] {s} p mem))
  1091    && p.Op != OpSB
  1092    && x.Uses == 1
  1093    && ValAndOff(a).Off() + 1 == ValAndOff(c).Off()
  1094    && clobber(x)
  1095    -> (MOVHstoreconst [makeValAndOff(ValAndOff(c).Val()&0xff | ValAndOff(a).Val()<<8, ValAndOff(a).Off())] {s} p mem)
  1096  (MOVHstoreconst [c] {s} p x:(MOVHstoreconst [a] {s} p mem))
  1097    && p.Op != OpSB
  1098    && x.Uses == 1
  1099    && ValAndOff(a).Off() + 2 == ValAndOff(c).Off()
  1100    && clobber(x)
  1101    -> (MOVWstore [ValAndOff(a).Off()] {s} p (MOVDconst [int64(int32(ValAndOff(c).Val()&0xffff | ValAndOff(a).Val()<<16))]) mem)
  1102  (MOVWstoreconst [c] {s} p x:(MOVWstoreconst [a] {s} p mem))
  1103    && p.Op != OpSB
  1104    && x.Uses == 1
  1105    && ValAndOff(a).Off() + 4 == ValAndOff(c).Off()
  1106    && clobber(x)
  1107    -> (MOVDstore [ValAndOff(a).Off()] {s} p (MOVDconst [ValAndOff(c).Val()&0xffffffff | ValAndOff(a).Val()<<32]) mem)
  1108  
  1109  // Combine stores into larger (unaligned) stores.
  1110  // It doesn't work on global data (based on SB) because stores with relative addressing
  1111  // require that the memory operand be aligned.
  1112  (MOVBstore [i] {s} p w x:(MOVBstore [i-1] {s} p (SRDconst [8] w) mem))
  1113    && p.Op != OpSB
  1114    && x.Uses == 1
  1115    && clobber(x)
  1116    -> (MOVHstore [i-1] {s} p w mem)
  1117  (MOVBstore [i] {s} p w0:(SRDconst [j] w) x:(MOVBstore [i-1] {s} p (SRDconst [j+8] w) mem))
  1118    && p.Op != OpSB
  1119    && x.Uses == 1
  1120    && clobber(x)
  1121    -> (MOVHstore [i-1] {s} p w0 mem)
  1122  (MOVBstore [i] {s} p w x:(MOVBstore [i-1] {s} p (SRWconst [8] w) mem))
  1123    && p.Op != OpSB
  1124    && x.Uses == 1
  1125    && clobber(x)
  1126    -> (MOVHstore [i-1] {s} p w mem)
  1127  (MOVBstore [i] {s} p w0:(SRWconst [j] w) x:(MOVBstore [i-1] {s} p (SRWconst [j+8] w) mem))
  1128    && p.Op != OpSB
  1129    && x.Uses == 1
  1130    && clobber(x)
  1131    -> (MOVHstore [i-1] {s} p w0 mem)
  1132  (MOVHstore [i] {s} p w x:(MOVHstore [i-2] {s} p (SRDconst [16] w) mem))
  1133    && p.Op != OpSB
  1134    && x.Uses == 1
  1135    && clobber(x)
  1136    -> (MOVWstore [i-2] {s} p w mem)
  1137  (MOVHstore [i] {s} p w0:(SRDconst [j] w) x:(MOVHstore [i-2] {s} p (SRDconst [j+16] w) mem))
  1138    && p.Op != OpSB
  1139    && x.Uses == 1
  1140    && clobber(x)
  1141    -> (MOVWstore [i-2] {s} p w0 mem)
  1142  (MOVHstore [i] {s} p w x:(MOVHstore [i-2] {s} p (SRWconst [16] w) mem))
  1143    && p.Op != OpSB
  1144    && x.Uses == 1
  1145    && clobber(x)
  1146    -> (MOVWstore [i-2] {s} p w mem)
  1147  (MOVHstore [i] {s} p w0:(SRWconst [j] w) x:(MOVHstore [i-2] {s} p (SRWconst [j+16] w) mem))
  1148    && p.Op != OpSB
  1149    && x.Uses == 1
  1150    && clobber(x)
  1151    -> (MOVWstore [i-2] {s} p w0 mem)
  1152  (MOVWstore [i] {s} p (SRDconst [32] w) x:(MOVWstore [i-4] {s} p w mem))
  1153    && p.Op != OpSB
  1154    && x.Uses == 1
  1155    && clobber(x)
  1156    -> (MOVDstore [i-4] {s} p w mem)
  1157  (MOVWstore [i] {s} p w0:(SRDconst [j] w) x:(MOVWstore [i-4] {s} p (SRDconst [j+32] w) mem))
  1158    && p.Op != OpSB
  1159    && x.Uses == 1
  1160    && clobber(x)
  1161    -> (MOVDstore [i-4] {s} p w0 mem)
  1162  
  1163  (MOVBstoreidx [i] {s} p idx w x:(MOVBstoreidx [i-1] {s} p idx (SRDconst [8] w) mem))
  1164    && x.Uses == 1
  1165    && clobber(x)
  1166    -> (MOVHstoreidx [i-1] {s} p idx w mem)
  1167  (MOVBstoreidx [i] {s} p idx w0:(SRDconst [j] w) x:(MOVBstoreidx [i-1] {s} p idx (SRDconst [j+8] w) mem))
  1168    && x.Uses == 1
  1169    && clobber(x)
  1170    -> (MOVHstoreidx [i-1] {s} p idx w0 mem)
  1171  (MOVBstoreidx [i] {s} p idx w x:(MOVBstoreidx [i-1] {s} p idx (SRWconst [8] w) mem))
  1172    && x.Uses == 1
  1173    && clobber(x)
  1174    -> (MOVHstoreidx [i-1] {s} p idx w mem)
  1175  (MOVBstoreidx [i] {s} p idx w0:(SRWconst [j] w) x:(MOVBstoreidx [i-1] {s} p idx (SRWconst [j+8] w) mem))
  1176    && x.Uses == 1
  1177    && clobber(x)
  1178    -> (MOVHstoreidx [i-1] {s} p idx w0 mem)
  1179  (MOVHstoreidx [i] {s} p idx w x:(MOVHstoreidx [i-2] {s} p idx (SRDconst [16] w) mem))
  1180    && x.Uses == 1
  1181    && clobber(x)
  1182    -> (MOVWstoreidx [i-2] {s} p idx w mem)
  1183  (MOVHstoreidx [i] {s} p idx w0:(SRDconst [j] w) x:(MOVHstoreidx [i-2] {s} p idx (SRDconst [j+16] w) mem))
  1184    && x.Uses == 1
  1185    && clobber(x)
  1186    -> (MOVWstoreidx [i-2] {s} p idx w0 mem)
  1187  (MOVHstoreidx [i] {s} p idx w x:(MOVHstoreidx [i-2] {s} p idx (SRWconst [16] w) mem))
  1188    && x.Uses == 1
  1189    && clobber(x)
  1190    -> (MOVWstoreidx [i-2] {s} p idx w mem)
  1191  (MOVHstoreidx [i] {s} p idx w0:(SRWconst [j] w) x:(MOVHstoreidx [i-2] {s} p idx (SRWconst [j+16] w) mem))
  1192    && x.Uses == 1
  1193    && clobber(x)
  1194    -> (MOVWstoreidx [i-2] {s} p idx w0 mem)
  1195  (MOVWstoreidx [i] {s} p idx w x:(MOVWstoreidx [i-4] {s} p idx (SRDconst [32] w) mem))
  1196    && x.Uses == 1
  1197    && clobber(x)
  1198    -> (MOVDstoreidx [i-4] {s} p idx w mem)
  1199  (MOVWstoreidx [i] {s} p idx w0:(SRDconst [j] w) x:(MOVWstoreidx [i-4] {s} p idx (SRDconst [j+32] w) mem))
  1200    && x.Uses == 1
  1201    && clobber(x)
  1202    -> (MOVDstoreidx [i-4] {s} p idx w0 mem)
  1203  
  1204  // Combine stores into larger (unaligned) stores with the bytes reversed (little endian).
  1205  // Store-with-bytes-reversed instructions do not support relative memory addresses,
  1206  // so these stores can't operate on global data (SB).
  1207  (MOVBstore [i] {s} p (SRDconst [8] w) x:(MOVBstore [i-1] {s} p w mem))
  1208    && p.Op != OpSB
  1209    && x.Uses == 1
  1210    && clobber(x)
  1211    -> (MOVHBRstore [i-1] {s} p w mem)
  1212  (MOVBstore [i] {s} p (SRDconst [j] w) x:(MOVBstore [i-1] {s} p w0:(SRDconst [j-8] w) mem))
  1213    && p.Op != OpSB
  1214    && x.Uses == 1
  1215    && clobber(x)
  1216    -> (MOVHBRstore [i-1] {s} p w0 mem)
  1217  (MOVBstore [i] {s} p (SRWconst [8] w) x:(MOVBstore [i-1] {s} p w mem))
  1218    && p.Op != OpSB
  1219    && x.Uses == 1
  1220    && clobber(x)
  1221    -> (MOVHBRstore [i-1] {s} p w mem)
  1222  (MOVBstore [i] {s} p (SRWconst [j] w) x:(MOVBstore [i-1] {s} p w0:(SRWconst [j-8] w) mem))
  1223    && p.Op != OpSB
  1224    && x.Uses == 1
  1225    && clobber(x)
  1226    -> (MOVHBRstore [i-1] {s} p w0 mem)
  1227  (MOVHBRstore [i] {s} p (SRDconst [16] w) x:(MOVHBRstore [i-2] {s} p w mem))
  1228    && x.Uses == 1
  1229    && clobber(x)
  1230    -> (MOVWBRstore [i-2] {s} p w mem)
  1231  (MOVHBRstore [i] {s} p (SRDconst [j] w) x:(MOVHBRstore [i-2] {s} p w0:(SRDconst [j-16] w) mem))
  1232    && x.Uses == 1
  1233    && clobber(x)
  1234    -> (MOVWBRstore [i-2] {s} p w0 mem)
  1235  (MOVHBRstore [i] {s} p (SRWconst [16] w) x:(MOVHBRstore [i-2] {s} p w mem))
  1236    && x.Uses == 1
  1237    && clobber(x)
  1238    -> (MOVWBRstore [i-2] {s} p w mem)
  1239  (MOVHBRstore [i] {s} p (SRWconst [j] w) x:(MOVHBRstore [i-2] {s} p w0:(SRWconst [j-16] w) mem))
  1240    && x.Uses == 1
  1241    && clobber(x)
  1242    -> (MOVWBRstore [i-2] {s} p w0 mem)
  1243  (MOVWBRstore [i] {s} p (SRDconst [32] w) x:(MOVWBRstore [i-4] {s} p w mem))
  1244    && x.Uses == 1
  1245    && clobber(x)
  1246    -> (MOVDBRstore [i-4] {s} p w mem)
  1247  (MOVWBRstore [i] {s} p (SRDconst [j] w) x:(MOVWBRstore [i-4] {s} p w0:(SRDconst [j-32] w) mem))
  1248    && x.Uses == 1
  1249    && clobber(x)
  1250    -> (MOVDBRstore [i-4] {s} p w0 mem)
  1251  
  1252  (MOVBstoreidx [i] {s} p idx (SRDconst [8] w) x:(MOVBstoreidx [i-1] {s} p idx w mem))
  1253    && x.Uses == 1
  1254    && clobber(x)
  1255    -> (MOVHBRstoreidx [i-1] {s} p idx w mem)
  1256  (MOVBstoreidx [i] {s} p idx (SRDconst [j] w) x:(MOVBstoreidx [i-1] {s} p idx w0:(SRDconst [j-8] w) mem))
  1257    && x.Uses == 1
  1258    && clobber(x)
  1259    -> (MOVHBRstoreidx [i-1] {s} p idx w0 mem)
  1260  (MOVBstoreidx [i] {s} p idx (SRWconst [8] w) x:(MOVBstoreidx [i-1] {s} p idx w mem))
  1261    && x.Uses == 1
  1262    && clobber(x)
  1263    -> (MOVHBRstoreidx [i-1] {s} p idx w mem)
  1264  (MOVBstoreidx [i] {s} p idx (SRWconst [j] w) x:(MOVBstoreidx [i-1] {s} p idx w0:(SRWconst [j-8] w) mem))
  1265    && x.Uses == 1
  1266    && clobber(x)
  1267    -> (MOVHBRstoreidx [i-1] {s} p idx w0 mem)
  1268  (MOVHBRstoreidx [i] {s} p idx (SRDconst [16] w) x:(MOVHBRstoreidx [i-2] {s} p idx w mem))
  1269    && x.Uses == 1
  1270    && clobber(x)
  1271    -> (MOVWBRstoreidx [i-2] {s} p idx w mem)
  1272  (MOVHBRstoreidx [i] {s} p idx (SRDconst [j] w) x:(MOVHBRstoreidx [i-2] {s} p idx w0:(SRDconst [j-16] w) mem))
  1273    && x.Uses == 1
  1274    && clobber(x)
  1275    -> (MOVWBRstoreidx [i-2] {s} p idx w0 mem)
  1276  (MOVHBRstoreidx [i] {s} p idx (SRWconst [16] w) x:(MOVHBRstoreidx [i-2] {s} p idx w mem))
  1277    && x.Uses == 1
  1278    && clobber(x)
  1279    -> (MOVWBRstoreidx [i-2] {s} p idx w mem)
  1280  (MOVHBRstoreidx [i] {s} p idx (SRWconst [j] w) x:(MOVHBRstoreidx [i-2] {s} p idx w0:(SRWconst [j-16] w) mem))
  1281    && x.Uses == 1
  1282    && clobber(x)
  1283    -> (MOVWBRstoreidx [i-2] {s} p idx w0 mem)
  1284  (MOVWBRstoreidx [i] {s} p idx (SRDconst [32] w) x:(MOVWBRstoreidx [i-4] {s} p idx w mem))
  1285    && x.Uses == 1
  1286    && clobber(x)
  1287    -> (MOVDBRstoreidx [i-4] {s} p idx w mem)
  1288  (MOVWBRstoreidx [i] {s} p idx (SRDconst [j] w) x:(MOVWBRstoreidx [i-4] {s} p idx w0:(SRDconst [j-32] w) mem))
  1289    && x.Uses == 1
  1290    && clobber(x)
  1291    -> (MOVDBRstoreidx [i-4] {s} p idx w0 mem)
  1292  
  1293  // Combining byte loads into larger (unaligned) loads.
  1294  
  1295  // Big-endian loads
  1296  
  1297  (ORW                 x1:(MOVBZload [i1] {s} p mem)
  1298      sh:(SLWconst [8] x0:(MOVBZload [i0] {s} p mem)))
  1299    && i1 == i0+1
  1300    && p.Op != OpSB
  1301    && x0.Uses == 1
  1302    && x1.Uses == 1
  1303    && sh.Uses == 1
  1304    && mergePoint(b,x0,x1) != nil
  1305    && clobber(x0)
  1306    && clobber(x1)
  1307    && clobber(sh)
  1308    -> @mergePoint(b,x0,x1) (MOVHZload [i0] {s} p mem)
  1309  
  1310  (OR                  x1:(MOVBZload [i1] {s} p mem)
  1311      sh:(SLDconst [8] x0:(MOVBZload [i0] {s} p mem)))
  1312    && i1 == i0+1
  1313    && p.Op != OpSB
  1314    && x0.Uses == 1
  1315    && x1.Uses == 1
  1316    && sh.Uses == 1
  1317    && mergePoint(b,x0,x1) != nil
  1318    && clobber(x0)
  1319    && clobber(x1)
  1320    && clobber(sh)
  1321    -> @mergePoint(b,x0,x1) (MOVHZload [i0] {s} p mem)
  1322  
  1323  (ORW                  x1:(MOVHZload [i1] {s} p mem)
  1324      sh:(SLWconst [16] x0:(MOVHZload [i0] {s} p mem)))
  1325    && i1 == i0+2
  1326    && p.Op != OpSB
  1327    && x0.Uses == 1
  1328    && x1.Uses == 1
  1329    && sh.Uses == 1
  1330    && mergePoint(b,x0,x1) != nil
  1331    && clobber(x0)
  1332    && clobber(x1)
  1333    && clobber(sh)
  1334    -> @mergePoint(b,x0,x1) (MOVWZload [i0] {s} p mem)
  1335  
  1336  (OR                   x1:(MOVHZload [i1] {s} p mem)
  1337      sh:(SLDconst [16] x0:(MOVHZload [i0] {s} p mem)))
  1338    && i1 == i0+2
  1339    && p.Op != OpSB
  1340    && x0.Uses == 1
  1341    && x1.Uses == 1
  1342    && sh.Uses == 1
  1343    && mergePoint(b,x0,x1) != nil
  1344    && clobber(x0)
  1345    && clobber(x1)
  1346    && clobber(sh)
  1347    -> @mergePoint(b,x0,x1) (MOVWZload [i0] {s} p mem)
  1348  
  1349  (OR                   x1:(MOVWZload [i1] {s} p mem)
  1350      sh:(SLDconst [32] x0:(MOVWZload [i0] {s} p mem)))
  1351    && i1 == i0+4
  1352    && p.Op != OpSB
  1353    && x0.Uses == 1
  1354    && x1.Uses == 1
  1355    && sh.Uses == 1
  1356    && mergePoint(b,x0,x1) != nil
  1357    && clobber(x0)
  1358    && clobber(x1)
  1359    && clobber(sh)
  1360    -> @mergePoint(b,x0,x1) (MOVDload [i0] {s} p mem)
  1361  
  1362  (ORW
  1363      s0:(SLWconst [j0] x0:(MOVBZload [i0] {s} p mem))
  1364      or:(ORW
  1365          s1:(SLWconst [j1] x1:(MOVBZload [i1] {s} p mem))
  1366  	y))
  1367    && i1 == i0+1
  1368    && j1 == j0-8
  1369    && j1 % 16 == 0
  1370    && x0.Uses == 1
  1371    && x1.Uses == 1
  1372    && s0.Uses == 1
  1373    && s1.Uses == 1
  1374    && or.Uses == 1
  1375    && mergePoint(b,x0,x1) != nil
  1376    && clobber(x0)
  1377    && clobber(x1)
  1378    && clobber(s0)
  1379    && clobber(s1)
  1380    && clobber(or)
  1381    -> @mergePoint(b,x0,x1) (ORW <v.Type> (SLWconst <v.Type> [j1] (MOVHZload [i0] {s} p mem)) y)
  1382  
  1383  (OR
  1384      s0:(SLDconst [j0] x0:(MOVBZload [i0] {s} p mem))
  1385      or:(OR
  1386          s1:(SLDconst [j1] x1:(MOVBZload [i1] {s} p mem))
  1387  	y))
  1388    && i1 == i0+1
  1389    && j1 == j0-8
  1390    && j1 % 16 == 0
  1391    && x0.Uses == 1
  1392    && x1.Uses == 1
  1393    && s0.Uses == 1
  1394    && s1.Uses == 1
  1395    && or.Uses == 1
  1396    && mergePoint(b,x0,x1) != nil
  1397    && clobber(x0)
  1398    && clobber(x1)
  1399    && clobber(s0)
  1400    && clobber(s1)
  1401    && clobber(or)
  1402    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j1] (MOVHZload [i0] {s} p mem)) y)
  1403  
  1404  (OR
  1405      s0:(SLDconst [j0] x0:(MOVHZload [i0] {s} p mem))
  1406      or:(OR
  1407          s1:(SLDconst [j1] x1:(MOVHZload [i1] {s} p mem))
  1408  	y))
  1409    && i1 == i0+2
  1410    && j1 == j0-16
  1411    && j1 % 32 == 0
  1412    && x0.Uses == 1
  1413    && x1.Uses == 1
  1414    && s0.Uses == 1
  1415    && s1.Uses == 1
  1416    && or.Uses == 1
  1417    && mergePoint(b,x0,x1) != nil
  1418    && clobber(x0)
  1419    && clobber(x1)
  1420    && clobber(s0)
  1421    && clobber(s1)
  1422    && clobber(or)
  1423    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j1] (MOVWZload [i0] {s} p mem)) y)
  1424  
  1425  // Big-endian indexed loads
  1426  
  1427  (ORW                 x1:(MOVBZloadidx [i1] {s} p idx mem)
  1428      sh:(SLWconst [8] x0:(MOVBZloadidx [i0] {s} p idx mem)))
  1429    && i1 == i0+1
  1430    && p.Op != OpSB
  1431    && x0.Uses == 1
  1432    && x1.Uses == 1
  1433    && sh.Uses == 1
  1434    && mergePoint(b,x0,x1) != nil
  1435    && clobber(x0)
  1436    && clobber(x1)
  1437    && clobber(sh)
  1438    -> @mergePoint(b,x0,x1) (MOVHZloadidx [i0] {s} p idx mem)
  1439  
  1440  (OR                  x1:(MOVBZloadidx [i1] {s} p idx mem)
  1441      sh:(SLDconst [8] x0:(MOVBZloadidx [i0] {s} p idx mem)))
  1442    && i1 == i0+1
  1443    && p.Op != OpSB
  1444    && x0.Uses == 1
  1445    && x1.Uses == 1
  1446    && sh.Uses == 1
  1447    && mergePoint(b,x0,x1) != nil
  1448    && clobber(x0)
  1449    && clobber(x1)
  1450    && clobber(sh)
  1451    -> @mergePoint(b,x0,x1) (MOVHZloadidx [i0] {s} p idx mem)
  1452  
  1453  (ORW                  x1:(MOVHZloadidx [i1] {s} p idx mem)
  1454      sh:(SLWconst [16] x0:(MOVHZloadidx [i0] {s} p idx mem)))
  1455    && i1 == i0+2
  1456    && p.Op != OpSB
  1457    && x0.Uses == 1
  1458    && x1.Uses == 1
  1459    && sh.Uses == 1
  1460    && mergePoint(b,x0,x1) != nil
  1461    && clobber(x0)
  1462    && clobber(x1)
  1463    && clobber(sh)
  1464    -> @mergePoint(b,x0,x1) (MOVWZloadidx [i0] {s} p idx mem)
  1465  
  1466  (OR                   x1:(MOVHZloadidx [i1] {s} p idx mem)
  1467      sh:(SLDconst [16] x0:(MOVHZloadidx [i0] {s} p idx mem)))
  1468    && i1 == i0+2
  1469    && p.Op != OpSB
  1470    && x0.Uses == 1
  1471    && x1.Uses == 1
  1472    && sh.Uses == 1
  1473    && mergePoint(b,x0,x1) != nil
  1474    && clobber(x0)
  1475    && clobber(x1)
  1476    && clobber(sh)
  1477    -> @mergePoint(b,x0,x1) (MOVWZloadidx [i0] {s} p idx mem)
  1478  
  1479  (OR                   x1:(MOVWZloadidx [i1] {s} p idx mem)
  1480      sh:(SLDconst [32] x0:(MOVWZloadidx [i0] {s} p idx mem)))
  1481    && i1 == i0+4
  1482    && p.Op != OpSB
  1483    && x0.Uses == 1
  1484    && x1.Uses == 1
  1485    && sh.Uses == 1
  1486    && mergePoint(b,x0,x1) != nil
  1487    && clobber(x0)
  1488    && clobber(x1)
  1489    && clobber(sh)
  1490    -> @mergePoint(b,x0,x1) (MOVDloadidx [i0] {s} p idx mem)
  1491  
  1492  (ORW
  1493      s0:(SLWconst [j0] x0:(MOVBZloadidx [i0] {s} p idx mem))
  1494      or:(ORW
  1495          s1:(SLWconst [j1] x1:(MOVBZloadidx [i1] {s} p idx mem))
  1496  	y))
  1497    && i1 == i0+1
  1498    && j1 == j0-8
  1499    && j1 % 16 == 0
  1500    && x0.Uses == 1
  1501    && x1.Uses == 1
  1502    && s0.Uses == 1
  1503    && s1.Uses == 1
  1504    && or.Uses == 1
  1505    && mergePoint(b,x0,x1) != nil
  1506    && clobber(x0)
  1507    && clobber(x1)
  1508    && clobber(s0)
  1509    && clobber(s1)
  1510    && clobber(or)
  1511    -> @mergePoint(b,x0,x1) (ORW <v.Type> (SLWconst <v.Type> [j1] (MOVHZloadidx [i0] {s} p idx mem)) y)
  1512  
  1513  (OR
  1514      s0:(SLDconst [j0] x0:(MOVBZloadidx [i0] {s} p idx mem))
  1515      or:(OR
  1516          s1:(SLDconst [j1] x1:(MOVBZloadidx [i1] {s} p idx mem))
  1517  	y))
  1518    && i1 == i0+1
  1519    && j1 == j0-8
  1520    && j1 % 16 == 0
  1521    && x0.Uses == 1
  1522    && x1.Uses == 1
  1523    && s0.Uses == 1
  1524    && s1.Uses == 1
  1525    && or.Uses == 1
  1526    && mergePoint(b,x0,x1) != nil
  1527    && clobber(x0)
  1528    && clobber(x1)
  1529    && clobber(s0)
  1530    && clobber(s1)
  1531    && clobber(or)
  1532    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j1] (MOVHZloadidx [i0] {s} p idx mem)) y)
  1533  
  1534  (OR
  1535      s0:(SLDconst [j0] x0:(MOVHZloadidx [i0] {s} p idx mem))
  1536      or:(OR
  1537          s1:(SLDconst [j1] x1:(MOVHZloadidx [i1] {s} p idx mem))
  1538  	y))
  1539    && i1 == i0+2
  1540    && j1 == j0-16
  1541    && j1 % 32 == 0
  1542    && x0.Uses == 1
  1543    && x1.Uses == 1
  1544    && s0.Uses == 1
  1545    && s1.Uses == 1
  1546    && or.Uses == 1
  1547    && mergePoint(b,x0,x1) != nil
  1548    && clobber(x0)
  1549    && clobber(x1)
  1550    && clobber(s0)
  1551    && clobber(s1)
  1552    && clobber(or)
  1553    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j1] (MOVWZloadidx [i0] {s} p idx mem)) y)
  1554  
  1555  // Little-endian loads
  1556  
  1557  (ORW                 x0:(MOVBZload [i0] {s} p mem)
  1558      sh:(SLWconst [8] x1:(MOVBZload [i1] {s} p mem)))
  1559    && p.Op != OpSB
  1560    && i1 == i0+1
  1561    && x0.Uses == 1
  1562    && x1.Uses == 1
  1563    && sh.Uses == 1
  1564    && mergePoint(b,x0,x1) != nil
  1565    && clobber(x0)
  1566    && clobber(x1)
  1567    && clobber(sh)
  1568    -> @mergePoint(b,x0,x1) (MOVHZreg (MOVHBRload [i0] {s} p mem))
  1569  
  1570  (OR                  x0:(MOVBZload [i0] {s} p mem)
  1571      sh:(SLDconst [8] x1:(MOVBZload [i1] {s} p mem)))
  1572    && p.Op != OpSB
  1573    && i1 == i0+1
  1574    && x0.Uses == 1
  1575    && x1.Uses == 1
  1576    && sh.Uses == 1
  1577    && mergePoint(b,x0,x1) != nil
  1578    && clobber(x0)
  1579    && clobber(x1)
  1580    && clobber(sh)
  1581    -> @mergePoint(b,x0,x1) (MOVHZreg (MOVHBRload [i0] {s} p mem))
  1582  
  1583  (ORW                  r0:(MOVHZreg x0:(MOVHBRload [i0] {s} p mem))
  1584      sh:(SLWconst [16] r1:(MOVHZreg x1:(MOVHBRload [i1] {s} p mem))))
  1585    && i1 == i0+2
  1586    && x0.Uses == 1
  1587    && x1.Uses == 1
  1588    && r0.Uses == 1
  1589    && r1.Uses == 1
  1590    && sh.Uses == 1
  1591    && mergePoint(b,x0,x1) != nil
  1592    && clobber(x0)
  1593    && clobber(x1)
  1594    && clobber(r0)
  1595    && clobber(r1)
  1596    && clobber(sh)
  1597    -> @mergePoint(b,x0,x1) (MOVWBRload [i0] {s} p mem)
  1598  
  1599  (OR                   r0:(MOVHZreg x0:(MOVHBRload [i0] {s} p mem))
  1600      sh:(SLDconst [16] r1:(MOVHZreg x1:(MOVHBRload [i1] {s} p mem))))
  1601    && i1 == i0+2
  1602    && x0.Uses == 1
  1603    && x1.Uses == 1
  1604    && r0.Uses == 1
  1605    && r1.Uses == 1
  1606    && sh.Uses == 1
  1607    && mergePoint(b,x0,x1) != nil
  1608    && clobber(x0)
  1609    && clobber(x1)
  1610    && clobber(r0)
  1611    && clobber(r1)
  1612    && clobber(sh)
  1613    -> @mergePoint(b,x0,x1) (MOVWZreg (MOVWBRload [i0] {s} p mem))
  1614  
  1615  (OR                   r0:(MOVWZreg x0:(MOVWBRload [i0] {s} p mem))
  1616      sh:(SLDconst [32] r1:(MOVWZreg x1:(MOVWBRload [i1] {s} p mem))))
  1617    && i1 == i0+4
  1618    && x0.Uses == 1
  1619    && x1.Uses == 1
  1620    && r0.Uses == 1
  1621    && r1.Uses == 1
  1622    && sh.Uses == 1
  1623    && mergePoint(b,x0,x1) != nil
  1624    && clobber(x0)
  1625    && clobber(x1)
  1626    && clobber(r0)
  1627    && clobber(r1)
  1628    && clobber(sh)
  1629    -> @mergePoint(b,x0,x1) (MOVDBRload [i0] {s} p mem)
  1630  
  1631  (ORW
  1632      s1:(SLWconst [j1] x1:(MOVBZload [i1] {s} p mem))
  1633      or:(ORW
  1634          s0:(SLWconst [j0] x0:(MOVBZload [i0] {s} p mem))
  1635  	y))
  1636    && p.Op != OpSB
  1637    && i1 == i0+1
  1638    && j1 == j0+8
  1639    && j0 % 16 == 0
  1640    && x0.Uses == 1
  1641    && x1.Uses == 1
  1642    && s0.Uses == 1
  1643    && s1.Uses == 1
  1644    && or.Uses == 1
  1645    && mergePoint(b,x0,x1) != nil
  1646    && clobber(x0)
  1647    && clobber(x1)
  1648    && clobber(s0)
  1649    && clobber(s1)
  1650    && clobber(or)
  1651    -> @mergePoint(b,x0,x1) (ORW <v.Type> (SLWconst <v.Type> [j0] (MOVHZreg (MOVHBRload [i0] {s} p mem))) y)
  1652  
  1653  (OR
  1654      s1:(SLDconst [j1] x1:(MOVBZload [i1] {s} p mem))
  1655      or:(OR
  1656          s0:(SLDconst [j0] x0:(MOVBZload [i0] {s} p mem))
  1657  	y))
  1658    && p.Op != OpSB
  1659    && i1 == i0+1
  1660    && j1 == j0+8
  1661    && j0 % 16 == 0
  1662    && x0.Uses == 1
  1663    && x1.Uses == 1
  1664    && s0.Uses == 1
  1665    && s1.Uses == 1
  1666    && or.Uses == 1
  1667    && mergePoint(b,x0,x1) != nil
  1668    && clobber(x0)
  1669    && clobber(x1)
  1670    && clobber(s0)
  1671    && clobber(s1)
  1672    && clobber(or)
  1673    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j0] (MOVHZreg (MOVHBRload [i0] {s} p mem))) y)
  1674  
  1675  (OR
  1676      s1:(SLDconst [j1] r1:(MOVHZreg x1:(MOVHBRload [i1] {s} p mem)))
  1677      or:(OR
  1678          s0:(SLDconst [j0] r0:(MOVHZreg x0:(MOVHBRload [i0] {s} p mem)))
  1679  	y))
  1680    && i1 == i0+2
  1681    && j1 == j0+16
  1682    && j0 % 32 == 0
  1683    && x0.Uses == 1
  1684    && x1.Uses == 1
  1685    && r0.Uses == 1
  1686    && r1.Uses == 1
  1687    && s0.Uses == 1
  1688    && s1.Uses == 1
  1689    && or.Uses == 1
  1690    && mergePoint(b,x0,x1) != nil
  1691    && clobber(x0)
  1692    && clobber(x1)
  1693    && clobber(r0)
  1694    && clobber(r1)
  1695    && clobber(s0)
  1696    && clobber(s1)
  1697    && clobber(or)
  1698    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j0] (MOVWZreg (MOVWBRload [i0] {s} p mem))) y)
  1699  
  1700  // Little-endian indexed loads
  1701  
  1702  (ORW                 x0:(MOVBZloadidx [i0] {s} p idx mem)
  1703      sh:(SLWconst [8] x1:(MOVBZloadidx [i1] {s} p idx mem)))
  1704    && p.Op != OpSB
  1705    && i1 == i0+1
  1706    && x0.Uses == 1
  1707    && x1.Uses == 1
  1708    && sh.Uses == 1
  1709    && mergePoint(b,x0,x1) != nil
  1710    && clobber(x0)
  1711    && clobber(x1)
  1712    && clobber(sh)
  1713    -> @mergePoint(b,x0,x1) (MOVHZreg (MOVHBRloadidx [i0] {s} p idx mem))
  1714  
  1715  (OR                  x0:(MOVBZloadidx [i0] {s} p idx mem)
  1716      sh:(SLDconst [8] x1:(MOVBZloadidx [i1] {s} p idx mem)))
  1717    && p.Op != OpSB
  1718    && i1 == i0+1
  1719    && x0.Uses == 1
  1720    && x1.Uses == 1
  1721    && sh.Uses == 1
  1722    && mergePoint(b,x0,x1) != nil
  1723    && clobber(x0)
  1724    && clobber(x1)
  1725    && clobber(sh)
  1726    -> @mergePoint(b,x0,x1) (MOVHZreg (MOVHBRloadidx [i0] {s} p idx mem))
  1727  
  1728  (ORW                  r0:(MOVHZreg x0:(MOVHBRloadidx [i0] {s} p idx mem))
  1729      sh:(SLWconst [16] r1:(MOVHZreg x1:(MOVHBRloadidx [i1] {s} p idx mem))))
  1730    && i1 == i0+2
  1731    && x0.Uses == 1
  1732    && x1.Uses == 1
  1733    && r0.Uses == 1
  1734    && r1.Uses == 1
  1735    && sh.Uses == 1
  1736    && mergePoint(b,x0,x1) != nil
  1737    && clobber(x0)
  1738    && clobber(x1)
  1739    && clobber(r0)
  1740    && clobber(r1)
  1741    && clobber(sh)
  1742    -> @mergePoint(b,x0,x1) (MOVWBRloadidx [i0] {s} p idx mem)
  1743  
  1744  (OR                   r0:(MOVHZreg x0:(MOVHBRloadidx [i0] {s} p idx mem))
  1745      sh:(SLDconst [16] r1:(MOVHZreg x1:(MOVHBRloadidx [i1] {s} p idx mem))))
  1746    && i1 == i0+2
  1747    && x0.Uses == 1
  1748    && x1.Uses == 1
  1749    && r0.Uses == 1
  1750    && r1.Uses == 1
  1751    && sh.Uses == 1
  1752    && mergePoint(b,x0,x1) != nil
  1753    && clobber(x0)
  1754    && clobber(x1)
  1755    && clobber(r0)
  1756    && clobber(r1)
  1757    && clobber(sh)
  1758    -> @mergePoint(b,x0,x1) (MOVWZreg (MOVWBRloadidx [i0] {s} p idx mem))
  1759  
  1760  (OR                   r0:(MOVWZreg x0:(MOVWBRloadidx [i0] {s} p idx mem))
  1761      sh:(SLDconst [32] r1:(MOVWZreg x1:(MOVWBRloadidx [i1] {s} p idx mem))))
  1762    && i1 == i0+4
  1763    && x0.Uses == 1
  1764    && x1.Uses == 1
  1765    && r0.Uses == 1
  1766    && r1.Uses == 1
  1767    && sh.Uses == 1
  1768    && mergePoint(b,x0,x1) != nil
  1769    && clobber(x0)
  1770    && clobber(x1)
  1771    && clobber(r0)
  1772    && clobber(r1)
  1773    && clobber(sh)
  1774    -> @mergePoint(b,x0,x1) (MOVDBRloadidx [i0] {s} p idx mem)
  1775  
  1776  (ORW
  1777      s1:(SLWconst [j1] x1:(MOVBZloadidx [i1] {s} p idx mem))
  1778      or:(ORW
  1779          s0:(SLWconst [j0] x0:(MOVBZloadidx [i0] {s} p idx mem))
  1780  	y))
  1781    && p.Op != OpSB
  1782    && i1 == i0+1
  1783    && j1 == j0+8
  1784    && j0 % 16 == 0
  1785    && x0.Uses == 1
  1786    && x1.Uses == 1
  1787    && s0.Uses == 1
  1788    && s1.Uses == 1
  1789    && or.Uses == 1
  1790    && mergePoint(b,x0,x1) != nil
  1791    && clobber(x0)
  1792    && clobber(x1)
  1793    && clobber(s0)
  1794    && clobber(s1)
  1795    && clobber(or)
  1796    -> @mergePoint(b,x0,x1) (ORW <v.Type> (SLWconst <v.Type> [j0] (MOVHZreg (MOVHBRloadidx [i0] {s} p idx mem))) y)
  1797  
  1798  (OR
  1799      s1:(SLDconst [j1] x1:(MOVBZloadidx [i1] {s} p idx mem))
  1800      or:(OR
  1801          s0:(SLDconst [j0] x0:(MOVBZloadidx [i0] {s} p idx mem))
  1802  	y))
  1803    && p.Op != OpSB
  1804    && i1 == i0+1
  1805    && j1 == j0+8
  1806    && j0 % 16 == 0
  1807    && x0.Uses == 1
  1808    && x1.Uses == 1
  1809    && s0.Uses == 1
  1810    && s1.Uses == 1
  1811    && or.Uses == 1
  1812    && mergePoint(b,x0,x1) != nil
  1813    && clobber(x0)
  1814    && clobber(x1)
  1815    && clobber(s0)
  1816    && clobber(s1)
  1817    && clobber(or)
  1818    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j0] (MOVHZreg (MOVHBRloadidx [i0] {s} p idx mem))) y)
  1819  
  1820  (OR
  1821      s1:(SLDconst [j1] r1:(MOVHZreg x1:(MOVHBRloadidx [i1] {s} p idx mem)))
  1822      or:(OR
  1823          s0:(SLDconst [j0] r0:(MOVHZreg x0:(MOVHBRloadidx [i0] {s} p idx mem)))
  1824  	y))
  1825    && i1 == i0+2
  1826    && j1 == j0+16
  1827    && j0 % 32 == 0
  1828    && x0.Uses == 1
  1829    && x1.Uses == 1
  1830    && r0.Uses == 1
  1831    && r1.Uses == 1
  1832    && s0.Uses == 1
  1833    && s1.Uses == 1
  1834    && or.Uses == 1
  1835    && mergePoint(b,x0,x1) != nil
  1836    && clobber(x0)
  1837    && clobber(x1)
  1838    && clobber(r0)
  1839    && clobber(r1)
  1840    && clobber(s0)
  1841    && clobber(s1)
  1842    && clobber(or)
  1843    -> @mergePoint(b,x0,x1) (OR <v.Type> (SLDconst <v.Type> [j0] (MOVWZreg (MOVWBRloadidx [i0] {s} p idx mem))) y)
  1844  
  1845  // Combine stores into store multiples.
  1846  // 32-bit
  1847  (MOVWstore [i] {s} p w1 x:(MOVWstore [i-4] {s} p w0 mem))
  1848    && p.Op != OpSB
  1849    && x.Uses == 1
  1850    && is20Bit(i-4)
  1851    && clobber(x)
  1852    -> (STM2 [i-4] {s} p w0 w1 mem)
  1853  (MOVWstore [i] {s} p w2 x:(STM2 [i-8] {s} p w0 w1 mem))
  1854    && x.Uses == 1
  1855    && is20Bit(i-8)
  1856    && clobber(x)
  1857    -> (STM3 [i-8] {s} p w0 w1 w2 mem)
  1858  (MOVWstore [i] {s} p w3 x:(STM3 [i-12] {s} p w0 w1 w2 mem))
  1859    && x.Uses == 1
  1860    && is20Bit(i-12)
  1861    && clobber(x)
  1862    -> (STM4 [i-12] {s} p w0 w1 w2 w3 mem)
  1863  (STM2 [i] {s} p w2 w3 x:(STM2 [i-8] {s} p w0 w1 mem))
  1864    && x.Uses == 1
  1865    && is20Bit(i-8)
  1866    && clobber(x)
  1867    -> (STM4 [i-8] {s} p w0 w1 w2 w3 mem)
  1868  // 64-bit
  1869  (MOVDstore [i] {s} p w1 x:(MOVDstore [i-8] {s} p w0 mem))
  1870    && p.Op != OpSB
  1871    && x.Uses == 1
  1872    && is20Bit(i-8)
  1873    && clobber(x)
  1874    -> (STMG2 [i-8] {s} p w0 w1 mem)
  1875  (MOVDstore [i] {s} p w2 x:(STMG2 [i-16] {s} p w0 w1 mem))
  1876    && x.Uses == 1
  1877    && is20Bit(i-16)
  1878    && clobber(x)
  1879    -> (STMG3 [i-16] {s} p w0 w1 w2 mem)
  1880  (MOVDstore [i] {s} p w3 x:(STMG3 [i-24] {s} p w0 w1 w2 mem))
  1881    && x.Uses == 1
  1882    && is20Bit(i-24)
  1883    && clobber(x)
  1884    -> (STMG4 [i-24] {s} p w0 w1 w2 w3 mem)
  1885  (STMG2 [i] {s} p w2 w3 x:(STMG2 [i-16] {s} p w0 w1 mem))
  1886    && x.Uses == 1
  1887    && is20Bit(i-16)
  1888    && clobber(x)
  1889    -> (STMG4 [i-16] {s} p w0 w1 w2 w3 mem)
  1890  
  1891  // Convert 32-bit store multiples into 64-bit stores.
  1892  (STM2 [i] {s} p (SRDconst [32] x) x mem) -> (MOVDstore [i] {s} p x mem)