github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/compile/internal/ssa/gen/ARM.rules (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  (Add(Ptr|32|16|8) x y) -> (ADD x y)
     6  (Add(32|64)F x y) -> (ADD(F|D) x y)
     7  (Add32carry x y) -> (ADDS x y)
     8  (Add32withcarry x y c) -> (ADC x y c)
     9  
    10  (Sub(Ptr|32|16|8) x y) -> (SUB x y)
    11  (Sub(32|64)F x y) -> (SUB(F|D) x y)
    12  (Sub32carry x y) -> (SUBS x y)
    13  (Sub32withcarry x y c) -> (SBC x y c)
    14  
    15  (Mul(32|16|8) x y) -> (MUL x y)
    16  (Mul(32|64)F x y) -> (MUL(F|D) x y)
    17  (Hmul(32|32u) x y) -> (HMU(L|LU) x y)
    18  (Mul32uhilo x y) -> (MULLU x y)
    19  
    20  (Div32 x y) ->
    21  	(SUB (XOR <typ.UInt32>                                                        // negate the result if one operand is negative
    22  		(Select0 <typ.UInt32> (CALLudiv
    23  			(SUB <typ.UInt32> (XOR x <typ.UInt32> (Signmask x)) (Signmask x))   // negate x if negative
    24  			(SUB <typ.UInt32> (XOR y <typ.UInt32> (Signmask y)) (Signmask y)))) // negate y if negative
    25  		(Signmask (XOR <typ.UInt32> x y))) (Signmask (XOR <typ.UInt32> x y)))
    26  (Div32u x y) -> (Select0 <typ.UInt32> (CALLudiv x y))
    27  (Div16 x y) -> (Div32 (SignExt16to32 x) (SignExt16to32 y))
    28  (Div16u x y) -> (Div32u (ZeroExt16to32 x) (ZeroExt16to32 y))
    29  (Div8 x y) -> (Div32 (SignExt8to32 x) (SignExt8to32 y))
    30  (Div8u x y) -> (Div32u (ZeroExt8to32 x) (ZeroExt8to32 y))
    31  (Div(32|64)F x y) -> (DIV(F|D) x y)
    32  
    33  (Mod32 x y) ->
    34  	(SUB (XOR <typ.UInt32>                                                        // negate the result if x is negative
    35  		(Select1 <typ.UInt32> (CALLudiv
    36  			(SUB <typ.UInt32> (XOR <typ.UInt32> x (Signmask x)) (Signmask x))   // negate x if negative
    37  			(SUB <typ.UInt32> (XOR <typ.UInt32> y (Signmask y)) (Signmask y)))) // negate y if negative
    38  		(Signmask x)) (Signmask x))
    39  (Mod32u x y) -> (Select1 <typ.UInt32> (CALLudiv x y))
    40  (Mod16 x y) -> (Mod32 (SignExt16to32 x) (SignExt16to32 y))
    41  (Mod16u x y) -> (Mod32u (ZeroExt16to32 x) (ZeroExt16to32 y))
    42  (Mod8 x y) -> (Mod32 (SignExt8to32 x) (SignExt8to32 y))
    43  (Mod8u x y) -> (Mod32u (ZeroExt8to32 x) (ZeroExt8to32 y))
    44  
    45  // (x + y) / 2 with x>=y -> (x - y) / 2 + y
    46  (Avg32u <t> x y) -> (ADD (SRLconst <t> (SUB <t> x y) [1]) y)
    47  
    48  (And(32|16|8) x y) -> (AND x y)
    49  (Or(32|16|8) x y) -> (OR x y)
    50  (Xor(32|16|8) x y) -> (XOR x y)
    51  
    52  // unary ops
    53  (Neg(32|16|8) x) -> (RSBconst [0] x)
    54  (Neg(32|64)F x) -> (NEG(F|D) x)
    55  
    56  (Com(32|16|8) x) -> (MVN x)
    57  
    58  (Sqrt x) -> (SQRTD x)
    59  
    60  // TODO: optimize this for ARMv5 and ARMv6
    61  (Ctz32NonZero x) -> (Ctz32 x)
    62  
    63  // count trailing zero for ARMv5 and ARMv6
    64  // 32 - CLZ(x&-x - 1)
    65  (Ctz32 <t> x) && objabi.GOARM<=6 -> (RSBconst [32] (CLZ <t> (SUBconst <t> (AND <t> x (RSBconst <t> [0] x)) [1])))
    66  
    67  // count trailing zero for ARMv7
    68  (Ctz32 <t> x) && objabi.GOARM==7 -> (CLZ <t> (RBIT <t> x))
    69  
    70  // bit length
    71  (BitLen32 <t> x) -> (RSBconst [32] (CLZ <t> x))
    72  
    73  // byte swap for ARMv5
    74  // let (a, b, c, d) be the bytes of x from high to low
    75  // t1 = x right rotate 16 bits -- (c,   d,   a,   b  )
    76  // t2 = x ^ t1                 -- (a^c, b^d, a^c, b^d)
    77  // t3 = t2 &^ 0xff0000         -- (a^c, 0,   a^c, b^d)
    78  // t4 = t3 >> 8                -- (0,   a^c, 0,   a^c)
    79  // t5 = x right rotate 8 bits  -- (d,   a,   b,   c  )
    80  // result = t4 ^ t5            -- (d,   c,   b,   a  )
    81  // using shifted ops this can be done in 4 instructions.
    82  (Bswap32 <t> x) && objabi.GOARM==5 ->
    83  	(XOR <t>
    84  		(SRLconst <t> (BICconst <t> (XOR <t> x (SRRconst <t> [16] x)) [0xff0000]) [8])
    85  		(SRRconst <t> x [8]))
    86  
    87  // byte swap for ARMv6 and above
    88  (Bswap32 x) && objabi.GOARM>=6 -> (REV x)
    89  
    90  // boolean ops -- booleans are represented with 0=false, 1=true
    91  (AndB x y) -> (AND x y)
    92  (OrB x y) -> (OR x y)
    93  (EqB x y) -> (XORconst [1] (XOR <typ.Bool> x y))
    94  (NeqB x y) -> (XOR x y)
    95  (Not x) -> (XORconst [1] x)
    96  
    97  // shifts
    98  // hardware instruction uses only the low byte of the shift
    99  // we compare to 256 to ensure Go semantics for large shifts
   100  (Lsh32x32 x y) -> (CMOVWHSconst (SLL <x.Type> x y) (CMPconst [256] y) [0])
   101  (Lsh32x16 x y) -> (CMOVWHSconst (SLL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0])
   102  (Lsh32x8  x y) -> (SLL x (ZeroExt8to32 y))
   103  
   104  (Lsh16x32 x y) -> (CMOVWHSconst (SLL <x.Type> x y) (CMPconst [256] y) [0])
   105  (Lsh16x16 x y) -> (CMOVWHSconst (SLL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0])
   106  (Lsh16x8  x y) -> (SLL x (ZeroExt8to32 y))
   107  
   108  (Lsh8x32 x y) -> (CMOVWHSconst (SLL <x.Type> x y) (CMPconst [256] y) [0])
   109  (Lsh8x16 x y) -> (CMOVWHSconst (SLL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0])
   110  (Lsh8x8  x y) -> (SLL x (ZeroExt8to32 y))
   111  
   112  (Rsh32Ux32 x y) -> (CMOVWHSconst (SRL <x.Type> x y) (CMPconst [256] y) [0])
   113  (Rsh32Ux16 x y) -> (CMOVWHSconst (SRL <x.Type> x (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0])
   114  (Rsh32Ux8  x y) -> (SRL x (ZeroExt8to32 y))
   115  
   116  (Rsh16Ux32 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt16to32 x) y) (CMPconst [256] y) [0])
   117  (Rsh16Ux16 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt16to32 x) (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0])
   118  (Rsh16Ux8  x y) -> (SRL (ZeroExt16to32 x) (ZeroExt8to32 y))
   119  
   120  (Rsh8Ux32 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt8to32 x) y) (CMPconst [256] y) [0])
   121  (Rsh8Ux16 x y) -> (CMOVWHSconst (SRL <x.Type> (ZeroExt8to32 x) (ZeroExt16to32 y)) (CMPconst [256] (ZeroExt16to32 y)) [0])
   122  (Rsh8Ux8  x y) -> (SRL (ZeroExt8to32 x) (ZeroExt8to32 y))
   123  
   124  (Rsh32x32 x y) -> (SRAcond x y (CMPconst [256] y))
   125  (Rsh32x16 x y) -> (SRAcond x (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y)))
   126  (Rsh32x8  x y) -> (SRA x (ZeroExt8to32 y))
   127  
   128  (Rsh16x32 x y) -> (SRAcond (SignExt16to32 x) y (CMPconst [256] y))
   129  (Rsh16x16 x y) -> (SRAcond (SignExt16to32 x) (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y)))
   130  (Rsh16x8  x y) -> (SRA (SignExt16to32 x) (ZeroExt8to32 y))
   131  
   132  (Rsh8x32 x y) -> (SRAcond (SignExt8to32 x) y (CMPconst [256] y))
   133  (Rsh8x16 x y) -> (SRAcond (SignExt8to32 x) (ZeroExt16to32 y) (CMPconst [256] (ZeroExt16to32 y)))
   134  (Rsh8x8  x y) -> (SRA (SignExt8to32 x) (ZeroExt8to32 y))
   135  
   136  // constant shifts
   137  // generic opt rewrites all constant shifts to shift by Const64
   138  (Lsh32x64 x (Const64 [c])) && uint64(c) < 32 -> (SLLconst x [c])
   139  (Rsh32x64 x (Const64 [c])) && uint64(c) < 32 -> (SRAconst x [c])
   140  (Rsh32Ux64 x (Const64 [c])) && uint64(c) < 32 -> (SRLconst x [c])
   141  (Lsh16x64 x (Const64 [c])) && uint64(c) < 16 -> (SLLconst x [c])
   142  (Rsh16x64 x (Const64 [c])) && uint64(c) < 16 -> (SRAconst (SLLconst <typ.UInt32> x [16]) [c+16])
   143  (Rsh16Ux64 x (Const64 [c])) && uint64(c) < 16 -> (SRLconst (SLLconst <typ.UInt32> x [16]) [c+16])
   144  (Lsh8x64 x (Const64 [c])) && uint64(c) < 8 -> (SLLconst x [c])
   145  (Rsh8x64 x (Const64 [c])) && uint64(c) < 8 -> (SRAconst (SLLconst <typ.UInt32> x [24]) [c+24])
   146  (Rsh8Ux64 x (Const64 [c])) && uint64(c) < 8 -> (SRLconst (SLLconst <typ.UInt32> x [24]) [c+24])
   147  
   148  // large constant shifts
   149  (Lsh32x64 _ (Const64 [c])) && uint64(c) >= 32 -> (Const32 [0])
   150  (Rsh32Ux64 _ (Const64 [c])) && uint64(c) >= 32 -> (Const32 [0])
   151  (Lsh16x64 _ (Const64 [c])) && uint64(c) >= 16 -> (Const16 [0])
   152  (Rsh16Ux64 _ (Const64 [c])) && uint64(c) >= 16 -> (Const16 [0])
   153  (Lsh8x64 _ (Const64 [c])) && uint64(c) >= 8 -> (Const8 [0])
   154  (Rsh8Ux64 _ (Const64 [c])) && uint64(c) >= 8 -> (Const8 [0])
   155  
   156  // large constant signed right shift, we leave the sign bit
   157  (Rsh32x64 x (Const64 [c])) && uint64(c) >= 32 -> (SRAconst x [31])
   158  (Rsh16x64 x (Const64 [c])) && uint64(c) >= 16 -> (SRAconst (SLLconst <typ.UInt32> x [16]) [31])
   159  (Rsh8x64 x (Const64 [c])) && uint64(c) >= 8 -> (SRAconst (SLLconst <typ.UInt32> x [24]) [31])
   160  
   161  // constants
   162  (Const8 [val]) -> (MOVWconst [val])
   163  (Const16 [val]) -> (MOVWconst [val])
   164  (Const32 [val]) -> (MOVWconst [val])
   165  (Const32F [val]) -> (MOVFconst [val])
   166  (Const64F [val]) -> (MOVDconst [val])
   167  (ConstNil) -> (MOVWconst [0])
   168  (ConstBool [b]) -> (MOVWconst [b])
   169  
   170  // truncations
   171  // Because we ignore high parts of registers, truncates are just copies.
   172  (Trunc16to8 x) -> x
   173  (Trunc32to8 x) -> x
   174  (Trunc32to16 x) -> x
   175  
   176  // Zero-/Sign-extensions
   177  (ZeroExt8to16 x) -> (MOVBUreg x)
   178  (ZeroExt8to32 x) -> (MOVBUreg x)
   179  (ZeroExt16to32 x) -> (MOVHUreg x)
   180  
   181  (SignExt8to16 x) -> (MOVBreg x)
   182  (SignExt8to32 x) -> (MOVBreg x)
   183  (SignExt16to32 x) -> (MOVHreg x)
   184  
   185  (Signmask x) -> (SRAconst x [31])
   186  (Zeromask x) -> (SRAconst (RSBshiftRL <typ.Int32> x x [1]) [31]) // sign bit of uint32(x)>>1 - x
   187  (Slicemask <t> x) -> (SRAconst (RSBconst <t> [0] x) [31])
   188  
   189  // float <-> int conversion
   190  (Cvt32to32F x) -> (MOVWF x)
   191  (Cvt32to64F x) -> (MOVWD x)
   192  (Cvt32Uto32F x) -> (MOVWUF x)
   193  (Cvt32Uto64F x) -> (MOVWUD x)
   194  (Cvt32Fto32 x) -> (MOVFW x)
   195  (Cvt64Fto32 x) -> (MOVDW x)
   196  (Cvt32Fto32U x) -> (MOVFWU x)
   197  (Cvt64Fto32U x) -> (MOVDWU x)
   198  (Cvt32Fto64F x) -> (MOVFD x)
   199  (Cvt64Fto32F x) -> (MOVDF x)
   200  
   201  (Round(32|64)F x) -> x
   202  
   203  // comparisons
   204  (Eq8 x y)  -> (Equal (CMP (ZeroExt8to32 x) (ZeroExt8to32 y)))
   205  (Eq16 x y) -> (Equal (CMP (ZeroExt16to32 x) (ZeroExt16to32 y)))
   206  (Eq32 x y) -> (Equal (CMP x y))
   207  (EqPtr x y) -> (Equal (CMP x y))
   208  (Eq(32|64)F x y) -> (Equal (CMP(F|D) x y))
   209  
   210  (Neq8 x y)  -> (NotEqual (CMP (ZeroExt8to32 x) (ZeroExt8to32 y)))
   211  (Neq16 x y) -> (NotEqual (CMP (ZeroExt16to32 x) (ZeroExt16to32 y)))
   212  (Neq32 x y) -> (NotEqual (CMP x y))
   213  (NeqPtr x y) -> (NotEqual (CMP x y))
   214  (Neq(32|64)F x y) -> (NotEqual (CMP(F|D) x y))
   215  
   216  (Less8 x y)  -> (LessThan (CMP (SignExt8to32 x) (SignExt8to32 y)))
   217  (Less16 x y) -> (LessThan (CMP (SignExt16to32 x) (SignExt16to32 y)))
   218  (Less32 x y) -> (LessThan (CMP x y))
   219  (Less(32|64)F x y) -> (GreaterThan (CMP(F|D) y x)) // reverse operands to work around NaN
   220  
   221  (Less8U x y)  -> (LessThanU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y)))
   222  (Less16U x y) -> (LessThanU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y)))
   223  (Less32U x y) -> (LessThanU (CMP x y))
   224  
   225  (Leq8 x y)  -> (LessEqual (CMP (SignExt8to32 x) (SignExt8to32 y)))
   226  (Leq16 x y) -> (LessEqual (CMP (SignExt16to32 x) (SignExt16to32 y)))
   227  (Leq32 x y) -> (LessEqual (CMP x y))
   228  (Leq(32|64)F x y) -> (GreaterEqual (CMP(F|D) y x)) // reverse operands to work around NaN
   229  
   230  (Leq8U x y)  -> (LessEqualU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y)))
   231  (Leq16U x y) -> (LessEqualU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y)))
   232  (Leq32U x y) -> (LessEqualU (CMP x y))
   233  
   234  (Greater8 x y)  -> (GreaterThan (CMP (SignExt8to32 x) (SignExt8to32 y)))
   235  (Greater16 x y) -> (GreaterThan (CMP (SignExt16to32 x) (SignExt16to32 y)))
   236  (Greater32 x y) -> (GreaterThan (CMP x y))
   237  (Greater(32|64)F x y) -> (GreaterThan (CMP(F|D) x y))
   238  
   239  (Greater8U x y)  -> (GreaterThanU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y)))
   240  (Greater16U x y) -> (GreaterThanU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y)))
   241  (Greater32U x y) -> (GreaterThanU (CMP x y))
   242  
   243  (Geq8 x y)  -> (GreaterEqual (CMP (SignExt8to32 x) (SignExt8to32 y)))
   244  (Geq16 x y) -> (GreaterEqual (CMP (SignExt16to32 x) (SignExt16to32 y)))
   245  (Geq32 x y) -> (GreaterEqual (CMP x y))
   246  (Geq(32|64)F x y) -> (GreaterEqual (CMP(F|D) x y))
   247  
   248  (Geq8U x y)  -> (GreaterEqualU (CMP (ZeroExt8to32 x) (ZeroExt8to32 y)))
   249  (Geq16U x y) -> (GreaterEqualU (CMP (ZeroExt16to32 x) (ZeroExt16to32 y)))
   250  (Geq32U x y) -> (GreaterEqualU (CMP x y))
   251  
   252  (OffPtr [off] ptr:(SP)) -> (MOVWaddr [off] ptr)
   253  (OffPtr [off] ptr) -> (ADDconst [off] ptr)
   254  
   255  (Addr {sym} base) -> (MOVWaddr {sym} base)
   256  (LocalAddr {sym} base _) -> (MOVWaddr {sym} base)
   257  
   258  // loads
   259  (Load <t> ptr mem) && t.IsBoolean() -> (MOVBUload ptr mem)
   260  (Load <t> ptr mem) && (is8BitInt(t) && isSigned(t)) -> (MOVBload ptr mem)
   261  (Load <t> ptr mem) && (is8BitInt(t) && !isSigned(t)) -> (MOVBUload ptr mem)
   262  (Load <t> ptr mem) && (is16BitInt(t) && isSigned(t)) -> (MOVHload ptr mem)
   263  (Load <t> ptr mem) && (is16BitInt(t) && !isSigned(t)) -> (MOVHUload ptr mem)
   264  (Load <t> ptr mem) && (is32BitInt(t) || isPtr(t)) -> (MOVWload ptr mem)
   265  (Load <t> ptr mem) && is32BitFloat(t) -> (MOVFload ptr mem)
   266  (Load <t> ptr mem) && is64BitFloat(t) -> (MOVDload ptr mem)
   267  
   268  // stores
   269  (Store {t} ptr val mem) && t.(*types.Type).Size() == 1 -> (MOVBstore ptr val mem)
   270  (Store {t} ptr val mem) && t.(*types.Type).Size() == 2 -> (MOVHstore ptr val mem)
   271  (Store {t} ptr val mem) && t.(*types.Type).Size() == 4 && !is32BitFloat(val.Type) -> (MOVWstore ptr val mem)
   272  (Store {t} ptr val mem) && t.(*types.Type).Size() == 4 && is32BitFloat(val.Type) -> (MOVFstore ptr val mem)
   273  (Store {t} ptr val mem) && t.(*types.Type).Size() == 8 && is64BitFloat(val.Type) -> (MOVDstore ptr val mem)
   274  
   275  // zero instructions
   276  (Zero [0] _ mem) -> mem
   277  (Zero [1] ptr mem) -> (MOVBstore ptr (MOVWconst [0]) mem)
   278  (Zero [2] {t} ptr mem) && t.(*types.Type).Alignment()%2 == 0 ->
   279  	(MOVHstore ptr (MOVWconst [0]) mem)
   280  (Zero [2] ptr mem) ->
   281  	(MOVBstore [1] ptr (MOVWconst [0])
   282  		(MOVBstore [0] ptr (MOVWconst [0]) mem))
   283  (Zero [4] {t} ptr mem) && t.(*types.Type).Alignment()%4 == 0 ->
   284  	(MOVWstore ptr (MOVWconst [0]) mem)
   285  (Zero [4] {t} ptr mem) && t.(*types.Type).Alignment()%2 == 0 ->
   286  	(MOVHstore [2] ptr (MOVWconst [0])
   287  		(MOVHstore [0] ptr (MOVWconst [0]) mem))
   288  (Zero [4] ptr mem) ->
   289  	(MOVBstore [3] ptr (MOVWconst [0])
   290  		(MOVBstore [2] ptr (MOVWconst [0])
   291  			(MOVBstore [1] ptr (MOVWconst [0])
   292  				(MOVBstore [0] ptr (MOVWconst [0]) mem))))
   293  
   294  (Zero [3] ptr mem) ->
   295  	(MOVBstore [2] ptr (MOVWconst [0])
   296  		(MOVBstore [1] ptr (MOVWconst [0])
   297  			(MOVBstore [0] ptr (MOVWconst [0]) mem)))
   298  
   299  // Medium zeroing uses a duff device
   300  // 4 and 128 are magic constants, see runtime/mkduff.go
   301  (Zero [s] {t} ptr mem)
   302  	&& s%4 == 0 && s > 4 && s <= 512
   303  	&& t.(*types.Type).Alignment()%4 == 0 && !config.noDuffDevice ->
   304  	(DUFFZERO [4 * (128 - s/4)] ptr (MOVWconst [0]) mem)
   305  
   306  // Large zeroing uses a loop
   307  (Zero [s] {t} ptr mem)
   308  	&& (s > 512 || config.noDuffDevice) || t.(*types.Type).Alignment()%4 != 0 ->
   309  	(LoweredZero [t.(*types.Type).Alignment()]
   310  		ptr
   311  		(ADDconst <ptr.Type> ptr [s-moveSize(t.(*types.Type).Alignment(), config)])
   312  		(MOVWconst [0])
   313  		mem)
   314  
   315  // moves
   316  (Move [0] _ _ mem) -> mem
   317  (Move [1] dst src mem) -> (MOVBstore dst (MOVBUload src mem) mem)
   318  (Move [2] {t} dst src mem) && t.(*types.Type).Alignment()%2 == 0 ->
   319  	(MOVHstore dst (MOVHUload src mem) mem)
   320  (Move [2] dst src mem) ->
   321  	(MOVBstore [1] dst (MOVBUload [1] src mem)
   322  		(MOVBstore dst (MOVBUload src mem) mem))
   323  (Move [4] {t} dst src mem) && t.(*types.Type).Alignment()%4 == 0 ->
   324  	(MOVWstore dst (MOVWload src mem) mem)
   325  (Move [4] {t} dst src mem) && t.(*types.Type).Alignment()%2 == 0 ->
   326  	(MOVHstore [2] dst (MOVHUload [2] src mem)
   327  		(MOVHstore dst (MOVHUload src mem) mem))
   328  (Move [4] dst src mem) ->
   329  	(MOVBstore [3] dst (MOVBUload [3] src mem)
   330  		(MOVBstore [2] dst (MOVBUload [2] src mem)
   331  			(MOVBstore [1] dst (MOVBUload [1] src mem)
   332  				(MOVBstore dst (MOVBUload src mem) mem))))
   333  
   334  (Move [3] dst src mem) ->
   335  	(MOVBstore [2] dst (MOVBUload [2] src mem)
   336  		(MOVBstore [1] dst (MOVBUload [1] src mem)
   337  			(MOVBstore dst (MOVBUload src mem) mem)))
   338  
   339  // Medium move uses a duff device
   340  // 8 and 128 are magic constants, see runtime/mkduff.go
   341  (Move [s] {t} dst src mem)
   342  	&& s%4 == 0 && s > 4 && s <= 512
   343  	&& t.(*types.Type).Alignment()%4 == 0 && !config.noDuffDevice ->
   344  	(DUFFCOPY [8 * (128 - s/4)] dst src mem)
   345  
   346  // Large move uses a loop
   347  (Move [s] {t} dst src mem)
   348  	&& (s > 512 || config.noDuffDevice) || t.(*types.Type).Alignment()%4 != 0 ->
   349  	(LoweredMove [t.(*types.Type).Alignment()]
   350  		dst
   351  		src
   352  		(ADDconst <src.Type> src [s-moveSize(t.(*types.Type).Alignment(), config)])
   353  		mem)
   354  
   355  // calls
   356  (StaticCall [argwid] {target} mem) -> (CALLstatic [argwid] {target} mem)
   357  (ClosureCall [argwid] entry closure mem) -> (CALLclosure [argwid] entry closure mem)
   358  (InterCall [argwid] entry mem) -> (CALLinter [argwid] entry mem)
   359  
   360  // checks
   361  (NilCheck ptr mem) -> (LoweredNilCheck ptr mem)
   362  (IsNonNil ptr) -> (NotEqual (CMPconst [0] ptr))
   363  (IsInBounds idx len) -> (LessThanU (CMP idx len))
   364  (IsSliceInBounds idx len) -> (LessEqualU (CMP idx len))
   365  
   366  // pseudo-ops
   367  (GetClosurePtr) -> (LoweredGetClosurePtr)
   368  (GetCallerSP) -> (LoweredGetCallerSP)
   369  (GetCallerPC) -> (LoweredGetCallerPC)
   370  
   371  // Absorb pseudo-ops into blocks.
   372  (If (Equal cc) yes no) -> (EQ cc yes no)
   373  (If (NotEqual cc) yes no) -> (NE cc yes no)
   374  (If (LessThan cc) yes no) -> (LT cc yes no)
   375  (If (LessThanU cc) yes no) -> (ULT cc yes no)
   376  (If (LessEqual cc) yes no) -> (LE cc yes no)
   377  (If (LessEqualU cc) yes no) -> (ULE cc yes no)
   378  (If (GreaterThan cc) yes no) -> (GT cc yes no)
   379  (If (GreaterThanU cc) yes no) -> (UGT cc yes no)
   380  (If (GreaterEqual cc) yes no) -> (GE cc yes no)
   381  (If (GreaterEqualU cc) yes no) -> (UGE cc yes no)
   382  
   383  (If cond yes no) -> (NE (CMPconst [0] cond) yes no)
   384  
   385  // Absorb boolean tests into block
   386  (NE (CMPconst [0] (Equal cc)) yes no) -> (EQ cc yes no)
   387  (NE (CMPconst [0] (NotEqual cc)) yes no) -> (NE cc yes no)
   388  (NE (CMPconst [0] (LessThan cc)) yes no) -> (LT cc yes no)
   389  (NE (CMPconst [0] (LessThanU cc)) yes no) -> (ULT cc yes no)
   390  (NE (CMPconst [0] (LessEqual cc)) yes no) -> (LE cc yes no)
   391  (NE (CMPconst [0] (LessEqualU cc)) yes no) -> (ULE cc yes no)
   392  (NE (CMPconst [0] (GreaterThan cc)) yes no) -> (GT cc yes no)
   393  (NE (CMPconst [0] (GreaterThanU cc)) yes no) -> (UGT cc yes no)
   394  (NE (CMPconst [0] (GreaterEqual cc)) yes no) -> (GE cc yes no)
   395  (NE (CMPconst [0] (GreaterEqualU cc)) yes no) -> (UGE cc yes no)
   396  
   397  // Write barrier.
   398  (WB {fn} destptr srcptr mem) -> (LoweredWB {fn} destptr srcptr mem)
   399  
   400  // Optimizations
   401  
   402  // fold offset into address
   403  (ADDconst [off1] (MOVWaddr [off2] {sym} ptr)) -> (MOVWaddr [off1+off2] {sym} ptr)
   404  (SUBconst [off1] (MOVWaddr [off2] {sym} ptr)) -> (MOVWaddr [off2-off1] {sym} ptr)
   405  
   406  // fold address into load/store
   407  (MOVBload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVBload [off1+off2] {sym} ptr mem)
   408  (MOVBload [off1] {sym} (SUBconst [off2] ptr) mem) -> (MOVBload [off1-off2] {sym} ptr mem)
   409  (MOVBUload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVBUload [off1+off2] {sym} ptr mem)
   410  (MOVBUload [off1] {sym} (SUBconst [off2] ptr) mem) -> (MOVBUload [off1-off2] {sym} ptr mem)
   411  (MOVHload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVHload [off1+off2] {sym} ptr mem)
   412  (MOVHload [off1] {sym} (SUBconst [off2] ptr) mem) -> (MOVHload [off1-off2] {sym} ptr mem)
   413  (MOVHUload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVHUload [off1+off2] {sym} ptr mem)
   414  (MOVHUload [off1] {sym} (SUBconst [off2] ptr) mem) -> (MOVHUload [off1-off2] {sym} ptr mem)
   415  (MOVWload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVWload [off1+off2] {sym} ptr mem)
   416  (MOVWload [off1] {sym} (SUBconst [off2] ptr) mem) -> (MOVWload [off1-off2] {sym} ptr mem)
   417  (MOVFload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVFload [off1+off2] {sym} ptr mem)
   418  (MOVFload [off1] {sym} (SUBconst [off2] ptr) mem) -> (MOVFload [off1-off2] {sym} ptr mem)
   419  (MOVDload [off1] {sym} (ADDconst [off2] ptr) mem) -> (MOVDload [off1+off2] {sym} ptr mem)
   420  (MOVDload [off1] {sym} (SUBconst [off2] ptr) mem) -> (MOVDload [off1-off2] {sym} ptr mem)
   421  
   422  (MOVBstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVBstore [off1+off2] {sym} ptr val mem)
   423  (MOVBstore [off1] {sym} (SUBconst [off2] ptr) val mem) -> (MOVBstore [off1-off2] {sym} ptr val mem)
   424  (MOVHstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVHstore [off1+off2] {sym} ptr val mem)
   425  (MOVHstore [off1] {sym} (SUBconst [off2] ptr) val mem) -> (MOVHstore [off1-off2] {sym} ptr val mem)
   426  (MOVWstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVWstore [off1+off2] {sym} ptr val mem)
   427  (MOVWstore [off1] {sym} (SUBconst [off2] ptr) val mem) -> (MOVWstore [off1-off2] {sym} ptr val mem)
   428  (MOVFstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVFstore [off1+off2] {sym} ptr val mem)
   429  (MOVFstore [off1] {sym} (SUBconst [off2] ptr) val mem) -> (MOVFstore [off1-off2] {sym} ptr val mem)
   430  (MOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) -> (MOVDstore [off1+off2] {sym} ptr val mem)
   431  (MOVDstore [off1] {sym} (SUBconst [off2] ptr) val mem) -> (MOVDstore [off1-off2] {sym} ptr val mem)
   432  
   433  (MOVBload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) ->
   434  	(MOVBload [off1+off2] {mergeSym(sym1,sym2)} ptr mem)
   435  (MOVBUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) ->
   436  	(MOVBUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem)
   437  (MOVHload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) ->
   438  	(MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem)
   439  (MOVHUload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) ->
   440  	(MOVHUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem)
   441  (MOVWload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) ->
   442  	(MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem)
   443  (MOVFload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) ->
   444  	(MOVFload [off1+off2] {mergeSym(sym1,sym2)} ptr mem)
   445  (MOVDload [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) mem) && canMergeSym(sym1,sym2) ->
   446  	(MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem)
   447  
   448  (MOVBstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) ->
   449  	(MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem)
   450  (MOVHstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) ->
   451  	(MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem)
   452  (MOVWstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) ->
   453  	(MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem)
   454  (MOVFstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) ->
   455  	(MOVFstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem)
   456  (MOVDstore [off1] {sym1} (MOVWaddr [off2] {sym2} ptr) val mem) && canMergeSym(sym1,sym2) ->
   457  	(MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem)
   458  
   459  // replace load from same location as preceding store with zero/sign extension (or copy in case of full width)
   460  (MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVBreg x)
   461  (MOVBUload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVBUreg x)
   462  (MOVHload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVHreg x)
   463  (MOVHUload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVHUreg x)
   464  (MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x
   465  
   466  (MOVFload [off] {sym} ptr (MOVFstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x
   467  (MOVDload [off] {sym} ptr (MOVDstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x
   468  
   469  (MOVWloadidx ptr idx (MOVWstoreidx ptr2 idx x _)) && isSamePtr(ptr, ptr2) -> x
   470  (MOVWloadshiftLL ptr idx [c] (MOVWstoreshiftLL ptr2 idx [d] x _)) && c==d && isSamePtr(ptr, ptr2) -> x
   471  (MOVWloadshiftRL ptr idx [c] (MOVWstoreshiftRL ptr2 idx [d] x _)) && c==d && isSamePtr(ptr, ptr2) -> x
   472  (MOVWloadshiftRA ptr idx [c] (MOVWstoreshiftRA ptr2 idx [d] x _)) && c==d && isSamePtr(ptr, ptr2) -> x
   473  (MOVBUloadidx ptr idx (MOVBstoreidx ptr2 idx x _)) && isSamePtr(ptr, ptr2) -> (MOVBUreg x)
   474  (MOVBloadidx ptr idx (MOVBstoreidx ptr2 idx x _)) && isSamePtr(ptr, ptr2) -> (MOVBreg x)
   475  (MOVHUloadidx ptr idx (MOVHstoreidx ptr2 idx x _)) && isSamePtr(ptr, ptr2) -> (MOVHUreg x)
   476  (MOVHloadidx ptr idx (MOVHstoreidx ptr2 idx x _)) && isSamePtr(ptr, ptr2) -> (MOVHreg x)
   477  
   478  // fold constant into arithmatic ops
   479  (ADD x (MOVWconst [c])) -> (ADDconst [c] x)
   480  (SUB (MOVWconst [c]) x) -> (RSBconst [c] x)
   481  (SUB x (MOVWconst [c])) -> (SUBconst [c] x)
   482  (RSB (MOVWconst [c]) x) -> (SUBconst [c] x)
   483  (RSB x (MOVWconst [c])) -> (RSBconst [c] x)
   484  
   485  (ADDS x (MOVWconst [c])) -> (ADDSconst [c] x)
   486  (SUBS x (MOVWconst [c])) -> (SUBSconst [c] x)
   487  
   488  (ADC (MOVWconst [c]) x flags) -> (ADCconst [c] x flags)
   489  (ADC x (MOVWconst [c]) flags) -> (ADCconst [c] x flags)
   490  (SBC (MOVWconst [c]) x flags) -> (RSCconst [c] x flags)
   491  (SBC x (MOVWconst [c]) flags) -> (SBCconst [c] x flags)
   492  
   493  (AND x (MOVWconst [c])) -> (ANDconst [c] x)
   494  (OR  x (MOVWconst [c])) -> (ORconst [c] x)
   495  (XOR x (MOVWconst [c])) -> (XORconst [c] x)
   496  (BIC x (MOVWconst [c])) -> (BICconst [c] x)
   497  
   498  (SLL x (MOVWconst [c])) -> (SLLconst x [c&31]) // Note: I don't think we ever generate bad constant shifts (i.e. c>=32)
   499  (SRL x (MOVWconst [c])) -> (SRLconst x [c&31])
   500  (SRA x (MOVWconst [c])) -> (SRAconst x [c&31])
   501  
   502  (CMP x (MOVWconst [c])) -> (CMPconst [c] x)
   503  (CMP (MOVWconst [c]) x) -> (InvertFlags (CMPconst [c] x))
   504  (CMN x (MOVWconst [c])) -> (CMNconst [c] x)
   505  (TST x (MOVWconst [c])) -> (TSTconst [c] x)
   506  (TEQ x (MOVWconst [c])) -> (TEQconst [c] x)
   507  
   508  // don't extend after proper load
   509  // MOVWreg instruction is not emitted if src and dst registers are same, but it ensures the type.
   510  (MOVBreg x:(MOVBload _ _)) -> (MOVWreg x)
   511  (MOVBUreg x:(MOVBUload _ _)) -> (MOVWreg x)
   512  (MOVHreg x:(MOVBload _ _)) -> (MOVWreg x)
   513  (MOVHreg x:(MOVBUload _ _)) -> (MOVWreg x)
   514  (MOVHreg x:(MOVHload _ _)) -> (MOVWreg x)
   515  (MOVHUreg x:(MOVBUload _ _)) -> (MOVWreg x)
   516  (MOVHUreg x:(MOVHUload _ _)) -> (MOVWreg x)
   517  
   518  // fold extensions and ANDs together
   519  (MOVBUreg (ANDconst [c] x)) -> (ANDconst [c&0xff] x)
   520  (MOVHUreg (ANDconst [c] x)) -> (ANDconst [c&0xffff] x)
   521  (MOVBreg (ANDconst [c] x)) && c & 0x80 == 0 -> (ANDconst [c&0x7f] x)
   522  (MOVHreg (ANDconst [c] x)) && c & 0x8000 == 0 -> (ANDconst [c&0x7fff] x)
   523  
   524  // fold double extensions
   525  (MOVBreg x:(MOVBreg _)) -> (MOVWreg x)
   526  (MOVBUreg x:(MOVBUreg _)) -> (MOVWreg x)
   527  (MOVHreg x:(MOVBreg _)) -> (MOVWreg x)
   528  (MOVHreg x:(MOVBUreg _)) -> (MOVWreg x)
   529  (MOVHreg x:(MOVHreg _)) -> (MOVWreg x)
   530  (MOVHUreg x:(MOVBUreg _)) -> (MOVWreg x)
   531  (MOVHUreg x:(MOVHUreg _)) -> (MOVWreg x)
   532  
   533  // don't extend before store
   534  (MOVBstore [off] {sym} ptr (MOVBreg x) mem) -> (MOVBstore [off] {sym} ptr x mem)
   535  (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) -> (MOVBstore [off] {sym} ptr x mem)
   536  (MOVBstore [off] {sym} ptr (MOVHreg x) mem) -> (MOVBstore [off] {sym} ptr x mem)
   537  (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) -> (MOVBstore [off] {sym} ptr x mem)
   538  (MOVHstore [off] {sym} ptr (MOVHreg x) mem) -> (MOVHstore [off] {sym} ptr x mem)
   539  (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) -> (MOVHstore [off] {sym} ptr x mem)
   540  
   541  // if a register move has only 1 use, just use the same register without emitting instruction
   542  // MOVWnop doesn't emit instruction, only for ensuring the type.
   543  (MOVWreg x) && x.Uses == 1 -> (MOVWnop x)
   544  
   545  // mul by constant
   546  (MUL x (MOVWconst [c])) && int32(c) == -1 -> (RSBconst [0] x)
   547  (MUL _ (MOVWconst [0])) -> (MOVWconst [0])
   548  (MUL x (MOVWconst [1])) -> x
   549  (MUL x (MOVWconst [c])) && isPowerOfTwo(c) -> (SLLconst [log2(c)] x)
   550  (MUL x (MOVWconst [c])) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (ADDshiftLL x x [log2(c-1)])
   551  (MUL x (MOVWconst [c])) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (RSBshiftLL x x [log2(c+1)])
   552  (MUL x (MOVWconst [c])) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (SLLconst [log2(c/3)] (ADDshiftLL <x.Type> x x [1]))
   553  (MUL x (MOVWconst [c])) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (SLLconst [log2(c/5)] (ADDshiftLL <x.Type> x x [2]))
   554  (MUL x (MOVWconst [c])) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (SLLconst [log2(c/7)] (RSBshiftLL <x.Type> x x [3]))
   555  (MUL x (MOVWconst [c])) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (SLLconst [log2(c/9)] (ADDshiftLL <x.Type> x x [3]))
   556  
   557  (MULA x (MOVWconst [c]) a) && int32(c) == -1 -> (SUB a x)
   558  (MULA _ (MOVWconst [0]) a) -> a
   559  (MULA x (MOVWconst [1]) a) -> (ADD x a)
   560  (MULA x (MOVWconst [c]) a) && isPowerOfTwo(c) -> (ADD (SLLconst <x.Type> [log2(c)] x) a)
   561  (MULA x (MOVWconst [c]) a) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (ADD (ADDshiftLL <x.Type> x x [log2(c-1)]) a)
   562  (MULA x (MOVWconst [c]) a) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (ADD (RSBshiftLL <x.Type> x x [log2(c+1)]) a)
   563  (MULA x (MOVWconst [c]) a) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) a)
   564  (MULA x (MOVWconst [c]) a) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) a)
   565  (MULA x (MOVWconst [c]) a) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/7)] (RSBshiftLL <x.Type> x x [3])) a)
   566  (MULA x (MOVWconst [c]) a) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) a)
   567  
   568  (MULA (MOVWconst [c]) x a) && int32(c) == -1 -> (SUB a x)
   569  (MULA (MOVWconst [0]) _ a) -> a
   570  (MULA (MOVWconst [1]) x a) -> (ADD x a)
   571  (MULA (MOVWconst [c]) x a) && isPowerOfTwo(c) -> (ADD (SLLconst <x.Type> [log2(c)] x) a)
   572  (MULA (MOVWconst [c]) x a) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (ADD (ADDshiftLL <x.Type> x x [log2(c-1)]) a)
   573  (MULA (MOVWconst [c]) x a) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (ADD (RSBshiftLL <x.Type> x x [log2(c+1)]) a)
   574  (MULA (MOVWconst [c]) x a) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) a)
   575  (MULA (MOVWconst [c]) x a) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) a)
   576  (MULA (MOVWconst [c]) x a) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/7)] (RSBshiftLL <x.Type> x x [3])) a)
   577  (MULA (MOVWconst [c]) x a) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (ADD (SLLconst <x.Type> [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) a)
   578  
   579  (MULS x (MOVWconst [c]) a) && int32(c) == -1 -> (ADD a x)
   580  (MULS _ (MOVWconst [0]) a) -> a
   581  (MULS x (MOVWconst [1]) a) -> (RSB x a)
   582  (MULS x (MOVWconst [c]) a) && isPowerOfTwo(c) -> (RSB (SLLconst <x.Type> [log2(c)] x) a)
   583  (MULS x (MOVWconst [c]) a) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (RSB (ADDshiftLL <x.Type> x x [log2(c-1)]) a)
   584  (MULS x (MOVWconst [c]) a) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (RSB (RSBshiftLL <x.Type> x x [log2(c+1)]) a)
   585  (MULS x (MOVWconst [c]) a) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) a)
   586  (MULS x (MOVWconst [c]) a) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) a)
   587  (MULS x (MOVWconst [c]) a) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/7)] (RSBshiftLL <x.Type> x x [3])) a)
   588  (MULS x (MOVWconst [c]) a) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) a)
   589  
   590  (MULS (MOVWconst [c]) x a) && int32(c) == -1 -> (ADD a x)
   591  (MULS (MOVWconst [0]) _ a) -> a
   592  (MULS (MOVWconst [1]) x a) -> (RSB x a)
   593  (MULS (MOVWconst [c]) x a) && isPowerOfTwo(c) -> (RSB (SLLconst <x.Type> [log2(c)] x) a)
   594  (MULS (MOVWconst [c]) x a) && isPowerOfTwo(c-1) && int32(c) >= 3 -> (RSB (ADDshiftLL <x.Type> x x [log2(c-1)]) a)
   595  (MULS (MOVWconst [c]) x a) && isPowerOfTwo(c+1) && int32(c) >= 7 -> (RSB (RSBshiftLL <x.Type> x x [log2(c+1)]) a)
   596  (MULS (MOVWconst [c]) x a) && c%3 == 0 && isPowerOfTwo(c/3) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/3)] (ADDshiftLL <x.Type> x x [1])) a)
   597  (MULS (MOVWconst [c]) x a) && c%5 == 0 && isPowerOfTwo(c/5) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/5)] (ADDshiftLL <x.Type> x x [2])) a)
   598  (MULS (MOVWconst [c]) x a) && c%7 == 0 && isPowerOfTwo(c/7) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/7)] (RSBshiftLL <x.Type> x x [3])) a)
   599  (MULS (MOVWconst [c]) x a) && c%9 == 0 && isPowerOfTwo(c/9) && is32Bit(c) -> (RSB (SLLconst <x.Type> [log2(c/9)] (ADDshiftLL <x.Type> x x [3])) a)
   600  
   601  // div by constant
   602  (Select0 (CALLudiv x (MOVWconst [1]))) -> x
   603  (Select1 (CALLudiv _ (MOVWconst [1]))) -> (MOVWconst [0])
   604  (Select0 (CALLudiv x (MOVWconst [c]))) && isPowerOfTwo(c) -> (SRLconst [log2(c)] x)
   605  (Select1 (CALLudiv x (MOVWconst [c]))) && isPowerOfTwo(c) -> (ANDconst [c-1] x)
   606  
   607  // constant comparisons
   608  (CMPconst (MOVWconst [x]) [y]) && int32(x)==int32(y) -> (FlagEQ)
   609  (CMPconst (MOVWconst [x]) [y]) && int32(x)<int32(y) && uint32(x)<uint32(y) -> (FlagLT_ULT)
   610  (CMPconst (MOVWconst [x]) [y]) && int32(x)<int32(y) && uint32(x)>uint32(y) -> (FlagLT_UGT)
   611  (CMPconst (MOVWconst [x]) [y]) && int32(x)>int32(y) && uint32(x)<uint32(y) -> (FlagGT_ULT)
   612  (CMPconst (MOVWconst [x]) [y]) && int32(x)>int32(y) && uint32(x)>uint32(y) -> (FlagGT_UGT)
   613  (CMNconst (MOVWconst [x]) [y]) && int32(x)==int32(-y) -> (FlagEQ)
   614  (CMNconst (MOVWconst [x]) [y]) && int32(x)<int32(-y) && uint32(x)<uint32(-y) -> (FlagLT_ULT)
   615  (CMNconst (MOVWconst [x]) [y]) && int32(x)<int32(-y) && uint32(x)>uint32(-y) -> (FlagLT_UGT)
   616  (CMNconst (MOVWconst [x]) [y]) && int32(x)>int32(-y) && uint32(x)<uint32(-y) -> (FlagGT_ULT)
   617  (CMNconst (MOVWconst [x]) [y]) && int32(x)>int32(-y) && uint32(x)>uint32(-y) -> (FlagGT_UGT)
   618  (TSTconst (MOVWconst [x]) [y]) && int32(x&y)==0 -> (FlagEQ)
   619  (TSTconst (MOVWconst [x]) [y]) && int32(x&y)<0 -> (FlagLT_UGT)
   620  (TSTconst (MOVWconst [x]) [y]) && int32(x&y)>0 -> (FlagGT_UGT)
   621  (TEQconst (MOVWconst [x]) [y]) && int32(x^y)==0 -> (FlagEQ)
   622  (TEQconst (MOVWconst [x]) [y]) && int32(x^y)<0 -> (FlagLT_UGT)
   623  (TEQconst (MOVWconst [x]) [y]) && int32(x^y)>0 -> (FlagGT_UGT)
   624  
   625  // other known comparisons
   626  (CMPconst (MOVBUreg _) [c]) && 0xff < c -> (FlagLT_ULT)
   627  (CMPconst (MOVHUreg _) [c]) && 0xffff < c -> (FlagLT_ULT)
   628  (CMPconst (ANDconst _ [m]) [n]) && 0 <= int32(m) && int32(m) < int32(n) -> (FlagLT_ULT)
   629  (CMPconst (SRLconst _ [c]) [n]) && 0 <= n && 0 < c && c <= 32 && (1<<uint32(32-c)) <= uint32(n) -> (FlagLT_ULT)
   630  
   631  // absorb flag constants into branches
   632  (EQ (FlagEQ) yes no) -> (First nil yes no)
   633  (EQ (FlagLT_ULT) yes no) -> (First nil no yes)
   634  (EQ (FlagLT_UGT) yes no) -> (First nil no yes)
   635  (EQ (FlagGT_ULT) yes no) -> (First nil no yes)
   636  (EQ (FlagGT_UGT) yes no) -> (First nil no yes)
   637  
   638  (NE (FlagEQ) yes no) -> (First nil no yes)
   639  (NE (FlagLT_ULT) yes no) -> (First nil yes no)
   640  (NE (FlagLT_UGT) yes no) -> (First nil yes no)
   641  (NE (FlagGT_ULT) yes no) -> (First nil yes no)
   642  (NE (FlagGT_UGT) yes no) -> (First nil yes no)
   643  
   644  (LT (FlagEQ) yes no) -> (First nil no yes)
   645  (LT (FlagLT_ULT) yes no) -> (First nil yes no)
   646  (LT (FlagLT_UGT) yes no) -> (First nil yes no)
   647  (LT (FlagGT_ULT) yes no) -> (First nil no yes)
   648  (LT (FlagGT_UGT) yes no) -> (First nil no yes)
   649  
   650  (LE (FlagEQ) yes no) -> (First nil yes no)
   651  (LE (FlagLT_ULT) yes no) -> (First nil yes no)
   652  (LE (FlagLT_UGT) yes no) -> (First nil yes no)
   653  (LE (FlagGT_ULT) yes no) -> (First nil no yes)
   654  (LE (FlagGT_UGT) yes no) -> (First nil no yes)
   655  
   656  (GT (FlagEQ) yes no) -> (First nil no yes)
   657  (GT (FlagLT_ULT) yes no) -> (First nil no yes)
   658  (GT (FlagLT_UGT) yes no) -> (First nil no yes)
   659  (GT (FlagGT_ULT) yes no) -> (First nil yes no)
   660  (GT (FlagGT_UGT) yes no) -> (First nil yes no)
   661  
   662  (GE (FlagEQ) yes no) -> (First nil yes no)
   663  (GE (FlagLT_ULT) yes no) -> (First nil no yes)
   664  (GE (FlagLT_UGT) yes no) -> (First nil no yes)
   665  (GE (FlagGT_ULT) yes no) -> (First nil yes no)
   666  (GE (FlagGT_UGT) yes no) -> (First nil yes no)
   667  
   668  (ULT (FlagEQ) yes no) -> (First nil no yes)
   669  (ULT (FlagLT_ULT) yes no) -> (First nil yes no)
   670  (ULT (FlagLT_UGT) yes no) -> (First nil no yes)
   671  (ULT (FlagGT_ULT) yes no) -> (First nil yes no)
   672  (ULT (FlagGT_UGT) yes no) -> (First nil no yes)
   673  
   674  (ULE (FlagEQ) yes no) -> (First nil yes no)
   675  (ULE (FlagLT_ULT) yes no) -> (First nil yes no)
   676  (ULE (FlagLT_UGT) yes no) -> (First nil no yes)
   677  (ULE (FlagGT_ULT) yes no) -> (First nil yes no)
   678  (ULE (FlagGT_UGT) yes no) -> (First nil no yes)
   679  
   680  (UGT (FlagEQ) yes no) -> (First nil no yes)
   681  (UGT (FlagLT_ULT) yes no) -> (First nil no yes)
   682  (UGT (FlagLT_UGT) yes no) -> (First nil yes no)
   683  (UGT (FlagGT_ULT) yes no) -> (First nil no yes)
   684  (UGT (FlagGT_UGT) yes no) -> (First nil yes no)
   685  
   686  (UGE (FlagEQ) yes no) -> (First nil yes no)
   687  (UGE (FlagLT_ULT) yes no) -> (First nil no yes)
   688  (UGE (FlagLT_UGT) yes no) -> (First nil yes no)
   689  (UGE (FlagGT_ULT) yes no) -> (First nil no yes)
   690  (UGE (FlagGT_UGT) yes no) -> (First nil yes no)
   691  
   692  // absorb InvertFlags into branches
   693  (LT (InvertFlags cmp) yes no) -> (GT cmp yes no)
   694  (GT (InvertFlags cmp) yes no) -> (LT cmp yes no)
   695  (LE (InvertFlags cmp) yes no) -> (GE cmp yes no)
   696  (GE (InvertFlags cmp) yes no) -> (LE cmp yes no)
   697  (ULT (InvertFlags cmp) yes no) -> (UGT cmp yes no)
   698  (UGT (InvertFlags cmp) yes no) -> (ULT cmp yes no)
   699  (ULE (InvertFlags cmp) yes no) -> (UGE cmp yes no)
   700  (UGE (InvertFlags cmp) yes no) -> (ULE cmp yes no)
   701  (EQ (InvertFlags cmp) yes no) -> (EQ cmp yes no)
   702  (NE (InvertFlags cmp) yes no) -> (NE cmp yes no)
   703  
   704  // absorb flag constants into boolean values
   705  (Equal (FlagEQ)) -> (MOVWconst [1])
   706  (Equal (FlagLT_ULT)) -> (MOVWconst [0])
   707  (Equal (FlagLT_UGT)) -> (MOVWconst [0])
   708  (Equal (FlagGT_ULT)) -> (MOVWconst [0])
   709  (Equal (FlagGT_UGT)) -> (MOVWconst [0])
   710  
   711  (NotEqual (FlagEQ)) -> (MOVWconst [0])
   712  (NotEqual (FlagLT_ULT)) -> (MOVWconst [1])
   713  (NotEqual (FlagLT_UGT)) -> (MOVWconst [1])
   714  (NotEqual (FlagGT_ULT)) -> (MOVWconst [1])
   715  (NotEqual (FlagGT_UGT)) -> (MOVWconst [1])
   716  
   717  (LessThan (FlagEQ)) -> (MOVWconst [0])
   718  (LessThan (FlagLT_ULT)) -> (MOVWconst [1])
   719  (LessThan (FlagLT_UGT)) -> (MOVWconst [1])
   720  (LessThan (FlagGT_ULT)) -> (MOVWconst [0])
   721  (LessThan (FlagGT_UGT)) -> (MOVWconst [0])
   722  
   723  (LessThanU (FlagEQ)) -> (MOVWconst [0])
   724  (LessThanU (FlagLT_ULT)) -> (MOVWconst [1])
   725  (LessThanU (FlagLT_UGT)) -> (MOVWconst [0])
   726  (LessThanU (FlagGT_ULT)) -> (MOVWconst [1])
   727  (LessThanU (FlagGT_UGT)) -> (MOVWconst [0])
   728  
   729  (LessEqual (FlagEQ)) -> (MOVWconst [1])
   730  (LessEqual (FlagLT_ULT)) -> (MOVWconst [1])
   731  (LessEqual (FlagLT_UGT)) -> (MOVWconst [1])
   732  (LessEqual (FlagGT_ULT)) -> (MOVWconst [0])
   733  (LessEqual (FlagGT_UGT)) -> (MOVWconst [0])
   734  
   735  (LessEqualU (FlagEQ)) -> (MOVWconst [1])
   736  (LessEqualU (FlagLT_ULT)) -> (MOVWconst [1])
   737  (LessEqualU (FlagLT_UGT)) -> (MOVWconst [0])
   738  (LessEqualU (FlagGT_ULT)) -> (MOVWconst [1])
   739  (LessEqualU (FlagGT_UGT)) -> (MOVWconst [0])
   740  
   741  (GreaterThan (FlagEQ)) -> (MOVWconst [0])
   742  (GreaterThan (FlagLT_ULT)) -> (MOVWconst [0])
   743  (GreaterThan (FlagLT_UGT)) -> (MOVWconst [0])
   744  (GreaterThan (FlagGT_ULT)) -> (MOVWconst [1])
   745  (GreaterThan (FlagGT_UGT)) -> (MOVWconst [1])
   746  
   747  (GreaterThanU (FlagEQ)) -> (MOVWconst [0])
   748  (GreaterThanU (FlagLT_ULT)) -> (MOVWconst [0])
   749  (GreaterThanU (FlagLT_UGT)) -> (MOVWconst [1])
   750  (GreaterThanU (FlagGT_ULT)) -> (MOVWconst [0])
   751  (GreaterThanU (FlagGT_UGT)) -> (MOVWconst [1])
   752  
   753  (GreaterEqual (FlagEQ)) -> (MOVWconst [1])
   754  (GreaterEqual (FlagLT_ULT)) -> (MOVWconst [0])
   755  (GreaterEqual (FlagLT_UGT)) -> (MOVWconst [0])
   756  (GreaterEqual (FlagGT_ULT)) -> (MOVWconst [1])
   757  (GreaterEqual (FlagGT_UGT)) -> (MOVWconst [1])
   758  
   759  (GreaterEqualU (FlagEQ)) -> (MOVWconst [1])
   760  (GreaterEqualU (FlagLT_ULT)) -> (MOVWconst [0])
   761  (GreaterEqualU (FlagLT_UGT)) -> (MOVWconst [1])
   762  (GreaterEqualU (FlagGT_ULT)) -> (MOVWconst [0])
   763  (GreaterEqualU (FlagGT_UGT)) -> (MOVWconst [1])
   764  
   765  // absorb InvertFlags into boolean values
   766  (Equal (InvertFlags x)) -> (Equal x)
   767  (NotEqual (InvertFlags x)) -> (NotEqual x)
   768  (LessThan (InvertFlags x)) -> (GreaterThan x)
   769  (LessThanU (InvertFlags x)) -> (GreaterThanU x)
   770  (GreaterThan (InvertFlags x)) -> (LessThan x)
   771  (GreaterThanU (InvertFlags x)) -> (LessThanU x)
   772  (LessEqual (InvertFlags x)) -> (GreaterEqual x)
   773  (LessEqualU (InvertFlags x)) -> (GreaterEqualU x)
   774  (GreaterEqual (InvertFlags x)) -> (LessEqual x)
   775  (GreaterEqualU (InvertFlags x)) -> (LessEqualU x)
   776  
   777  // absorb flag constants into conditional instructions
   778  (CMOVWLSconst _ (FlagEQ) [c]) -> (MOVWconst [c])
   779  (CMOVWLSconst _ (FlagLT_ULT) [c]) -> (MOVWconst [c])
   780  (CMOVWLSconst x (FlagLT_UGT)) -> x
   781  (CMOVWLSconst _ (FlagGT_ULT) [c]) -> (MOVWconst [c])
   782  (CMOVWLSconst x (FlagGT_UGT)) -> x
   783  
   784  (CMOVWHSconst _ (FlagEQ) [c]) -> (MOVWconst [c])
   785  (CMOVWHSconst x (FlagLT_ULT)) -> x
   786  (CMOVWHSconst _ (FlagLT_UGT) [c]) -> (MOVWconst [c])
   787  (CMOVWHSconst x (FlagGT_ULT)) -> x
   788  (CMOVWHSconst _ (FlagGT_UGT) [c]) -> (MOVWconst [c])
   789  
   790  (CMOVWLSconst x (InvertFlags flags) [c]) -> (CMOVWHSconst x flags [c])
   791  (CMOVWHSconst x (InvertFlags flags) [c]) -> (CMOVWLSconst x flags [c])
   792  
   793  (SRAcond x _ (FlagEQ)) -> (SRAconst x [31])
   794  (SRAcond x y (FlagLT_ULT)) -> (SRA x y)
   795  (SRAcond x _ (FlagLT_UGT)) -> (SRAconst x [31])
   796  (SRAcond x y (FlagGT_ULT)) -> (SRA x y)
   797  (SRAcond x _ (FlagGT_UGT)) -> (SRAconst x [31])
   798  
   799  // remove redundant *const ops
   800  (ADDconst [0] x) -> x
   801  (SUBconst [0] x) -> x
   802  (ANDconst [0] _) -> (MOVWconst [0])
   803  (ANDconst [c] x) && int32(c)==-1 -> x
   804  (ORconst [0] x) -> x
   805  (ORconst [c] _) && int32(c)==-1 -> (MOVWconst [-1])
   806  (XORconst [0] x) -> x
   807  (BICconst [0] x) -> x
   808  (BICconst [c] _) && int32(c)==-1 -> (MOVWconst [0])
   809  
   810  // generic constant folding
   811  (ADDconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) -> (SUBconst [int64(int32(-c))] x)
   812  (SUBconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(uint32(-c)) -> (ADDconst [int64(int32(-c))] x)
   813  (ANDconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) -> (BICconst [int64(int32(^uint32(c)))] x)
   814  (BICconst [c] x) && !isARMImmRot(uint32(c)) && isARMImmRot(^uint32(c)) -> (ANDconst [int64(int32(^uint32(c)))] x)
   815  (ADDconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff -> (SUBconst [int64(int32(-c))] x)
   816  (SUBconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && uint32(-c)<=0xffff -> (ANDconst [int64(int32(-c))] x)
   817  (ANDconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff -> (BICconst [int64(int32(^uint32(c)))] x)
   818  (BICconst [c] x) && objabi.GOARM==7 && !isARMImmRot(uint32(c)) && uint32(c)>0xffff && ^uint32(c)<=0xffff -> (ANDconst [int64(int32(^uint32(c)))] x)
   819  (ADDconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(c+d))])
   820  (ADDconst [c] (ADDconst [d] x)) -> (ADDconst [int64(int32(c+d))] x)
   821  (ADDconst [c] (SUBconst [d] x)) -> (ADDconst [int64(int32(c-d))] x)
   822  (ADDconst [c] (RSBconst [d] x)) -> (RSBconst [int64(int32(c+d))] x)
   823  (ADCconst [c] (ADDconst [d] x) flags) -> (ADCconst [int64(int32(c+d))] x flags)
   824  (ADCconst [c] (SUBconst [d] x) flags) -> (ADCconst [int64(int32(c-d))] x flags)
   825  (SUBconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(d-c))])
   826  (SUBconst [c] (SUBconst [d] x)) -> (ADDconst [int64(int32(-c-d))] x)
   827  (SUBconst [c] (ADDconst [d] x)) -> (ADDconst [int64(int32(-c+d))] x)
   828  (SUBconst [c] (RSBconst [d] x)) -> (RSBconst [int64(int32(-c+d))] x)
   829  (SBCconst [c] (ADDconst [d] x) flags) -> (SBCconst [int64(int32(c-d))] x flags)
   830  (SBCconst [c] (SUBconst [d] x) flags) -> (SBCconst [int64(int32(c+d))] x flags)
   831  (RSBconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(c-d))])
   832  (RSBconst [c] (RSBconst [d] x)) -> (ADDconst [int64(int32(c-d))] x)
   833  (RSBconst [c] (ADDconst [d] x)) -> (RSBconst [int64(int32(c-d))] x)
   834  (RSBconst [c] (SUBconst [d] x)) -> (RSBconst [int64(int32(c+d))] x)
   835  (RSCconst [c] (ADDconst [d] x) flags) -> (RSCconst [int64(int32(c-d))] x flags)
   836  (RSCconst [c] (SUBconst [d] x) flags) -> (RSCconst [int64(int32(c+d))] x flags)
   837  (SLLconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(uint32(d)<<uint64(c)))])
   838  (SRLconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(uint32(d)>>uint64(c)))])
   839  (SRAconst [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(d)>>uint64(c))])
   840  (MUL (MOVWconst [c]) (MOVWconst [d])) -> (MOVWconst [int64(int32(c*d))])
   841  (MULA (MOVWconst [c]) (MOVWconst [d]) a) -> (ADDconst [int64(int32(c*d))] a)
   842  (MULS (MOVWconst [c]) (MOVWconst [d]) a) -> (SUBconst [int64(int32(c*d))] a)
   843  (Select0 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(int32(uint32(c)/uint32(d)))])
   844  (Select1 (CALLudiv (MOVWconst [c]) (MOVWconst [d]))) -> (MOVWconst [int64(int32(uint32(c)%uint32(d)))])
   845  (ANDconst [c] (MOVWconst [d])) -> (MOVWconst [c&d])
   846  (ANDconst [c] (ANDconst [d] x)) -> (ANDconst [c&d] x)
   847  (ORconst [c] (MOVWconst [d])) -> (MOVWconst [c|d])
   848  (ORconst [c] (ORconst [d] x)) -> (ORconst [c|d] x)
   849  (XORconst [c] (MOVWconst [d])) -> (MOVWconst [c^d])
   850  (XORconst [c] (XORconst [d] x)) -> (XORconst [c^d] x)
   851  (BICconst [c] (MOVWconst [d])) -> (MOVWconst [d&^c])
   852  (BICconst [c] (BICconst [d] x)) -> (BICconst [int64(int32(c|d))] x)
   853  (MVN (MOVWconst [c])) -> (MOVWconst [^c])
   854  (MOVBreg (MOVWconst [c])) -> (MOVWconst [int64(int8(c))])
   855  (MOVBUreg (MOVWconst [c])) -> (MOVWconst [int64(uint8(c))])
   856  (MOVHreg (MOVWconst [c])) -> (MOVWconst [int64(int16(c))])
   857  (MOVHUreg (MOVWconst [c])) -> (MOVWconst [int64(uint16(c))])
   858  (MOVWreg (MOVWconst [c])) -> (MOVWconst [c])
   859  // BFX: Width = c >> 8, LSB = c & 0xff, result = d << (32 - Width - LSB) >> (32 - Width)
   860  (BFX [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(d)<<(32-uint32(c&0xff)-uint32(c>>8))>>(32-uint32(c>>8)))])
   861  (BFXU [c] (MOVWconst [d])) -> (MOVWconst [int64(int32(uint32(d)<<(32-uint32(c&0xff)-uint32(c>>8))>>(32-uint32(c>>8))))])
   862  
   863  // absorb shifts into ops
   864  (ADD x (SLLconst [c] y)) -> (ADDshiftLL x y [c])
   865  (ADD x (SRLconst [c] y)) -> (ADDshiftRL x y [c])
   866  (ADD x (SRAconst [c] y)) -> (ADDshiftRA x y [c])
   867  (ADD x (SLL y z)) -> (ADDshiftLLreg x y z)
   868  (ADD x (SRL y z)) -> (ADDshiftRLreg x y z)
   869  (ADD x (SRA y z)) -> (ADDshiftRAreg x y z)
   870  (ADC x (SLLconst [c] y) flags) -> (ADCshiftLL x y [c] flags)
   871  (ADC (SLLconst [c] y) x flags) -> (ADCshiftLL x y [c] flags)
   872  (ADC x (SRLconst [c] y) flags) -> (ADCshiftRL x y [c] flags)
   873  (ADC (SRLconst [c] y) x flags) -> (ADCshiftRL x y [c] flags)
   874  (ADC x (SRAconst [c] y) flags) -> (ADCshiftRA x y [c] flags)
   875  (ADC (SRAconst [c] y) x flags) -> (ADCshiftRA x y [c] flags)
   876  (ADC x (SLL y z) flags) -> (ADCshiftLLreg x y z flags)
   877  (ADC (SLL y z) x flags) -> (ADCshiftLLreg x y z flags)
   878  (ADC x (SRL y z) flags) -> (ADCshiftRLreg x y z flags)
   879  (ADC (SRL y z) x flags) -> (ADCshiftRLreg x y z flags)
   880  (ADC x (SRA y z) flags) -> (ADCshiftRAreg x y z flags)
   881  (ADC (SRA y z) x flags) -> (ADCshiftRAreg x y z flags)
   882  (ADDS x (SLLconst [c] y)) -> (ADDSshiftLL x y [c])
   883  (ADDS x (SRLconst [c] y)) -> (ADDSshiftRL x y [c])
   884  (ADDS x (SRAconst [c] y)) -> (ADDSshiftRA x y [c])
   885  (ADDS x (SLL y z)) -> (ADDSshiftLLreg x y z)
   886  (ADDS x (SRL y z)) -> (ADDSshiftRLreg x y z)
   887  (ADDS x (SRA y z)) -> (ADDSshiftRAreg x y z)
   888  (SUB x (SLLconst [c] y)) -> (SUBshiftLL x y [c])
   889  (SUB (SLLconst [c] y) x) -> (RSBshiftLL x y [c])
   890  (SUB x (SRLconst [c] y)) -> (SUBshiftRL x y [c])
   891  (SUB (SRLconst [c] y) x) -> (RSBshiftRL x y [c])
   892  (SUB x (SRAconst [c] y)) -> (SUBshiftRA x y [c])
   893  (SUB (SRAconst [c] y) x) -> (RSBshiftRA x y [c])
   894  (SUB x (SLL y z)) -> (SUBshiftLLreg x y z)
   895  (SUB (SLL y z) x) -> (RSBshiftLLreg x y z)
   896  (SUB x (SRL y z)) -> (SUBshiftRLreg x y z)
   897  (SUB (SRL y z) x) -> (RSBshiftRLreg x y z)
   898  (SUB x (SRA y z)) -> (SUBshiftRAreg x y z)
   899  (SUB (SRA y z) x) -> (RSBshiftRAreg x y z)
   900  (SBC x (SLLconst [c] y) flags) -> (SBCshiftLL x y [c] flags)
   901  (SBC (SLLconst [c] y) x flags) -> (RSCshiftLL x y [c] flags)
   902  (SBC x (SRLconst [c] y) flags) -> (SBCshiftRL x y [c] flags)
   903  (SBC (SRLconst [c] y) x flags) -> (RSCshiftRL x y [c] flags)
   904  (SBC x (SRAconst [c] y) flags) -> (SBCshiftRA x y [c] flags)
   905  (SBC (SRAconst [c] y) x flags) -> (RSCshiftRA x y [c] flags)
   906  (SBC x (SLL y z) flags) -> (SBCshiftLLreg x y z flags)
   907  (SBC (SLL y z) x flags) -> (RSCshiftLLreg x y z flags)
   908  (SBC x (SRL y z) flags) -> (SBCshiftRLreg x y z flags)
   909  (SBC (SRL y z) x flags) -> (RSCshiftRLreg x y z flags)
   910  (SBC x (SRA y z) flags) -> (SBCshiftRAreg x y z flags)
   911  (SBC (SRA y z) x flags) -> (RSCshiftRAreg x y z flags)
   912  (SUBS x (SLLconst [c] y)) -> (SUBSshiftLL x y [c])
   913  (SUBS (SLLconst [c] y) x) -> (RSBSshiftLL x y [c])
   914  (SUBS x (SRLconst [c] y)) -> (SUBSshiftRL x y [c])
   915  (SUBS (SRLconst [c] y) x) -> (RSBSshiftRL x y [c])
   916  (SUBS x (SRAconst [c] y)) -> (SUBSshiftRA x y [c])
   917  (SUBS (SRAconst [c] y) x) -> (RSBSshiftRA x y [c])
   918  (SUBS x (SLL y z)) -> (SUBSshiftLLreg x y z)
   919  (SUBS (SLL y z) x) -> (RSBSshiftLLreg x y z)
   920  (SUBS x (SRL y z)) -> (SUBSshiftRLreg x y z)
   921  (SUBS (SRL y z) x) -> (RSBSshiftRLreg x y z)
   922  (SUBS x (SRA y z)) -> (SUBSshiftRAreg x y z)
   923  (SUBS (SRA y z) x) -> (RSBSshiftRAreg x y z)
   924  (RSB x (SLLconst [c] y)) -> (RSBshiftLL x y [c])
   925  (RSB (SLLconst [c] y) x) -> (SUBshiftLL x y [c])
   926  (RSB x (SRLconst [c] y)) -> (RSBshiftRL x y [c])
   927  (RSB (SRLconst [c] y) x) -> (SUBshiftRL x y [c])
   928  (RSB x (SRAconst [c] y)) -> (RSBshiftRA x y [c])
   929  (RSB (SRAconst [c] y) x) -> (SUBshiftRA x y [c])
   930  (RSB x (SLL y z)) -> (RSBshiftLLreg x y z)
   931  (RSB (SLL y z) x) -> (SUBshiftLLreg x y z)
   932  (RSB x (SRL y z)) -> (RSBshiftRLreg x y z)
   933  (RSB (SRL y z) x) -> (SUBshiftRLreg x y z)
   934  (RSB x (SRA y z)) -> (RSBshiftRAreg x y z)
   935  (RSB (SRA y z) x) -> (SUBshiftRAreg x y z)
   936  (AND x (SLLconst [c] y)) -> (ANDshiftLL x y [c])
   937  (AND x (SRLconst [c] y)) -> (ANDshiftRL x y [c])
   938  (AND x (SRAconst [c] y)) -> (ANDshiftRA x y [c])
   939  (AND x (SLL y z)) -> (ANDshiftLLreg x y z)
   940  (AND x (SRL y z)) -> (ANDshiftRLreg x y z)
   941  (AND x (SRA y z)) -> (ANDshiftRAreg x y z)
   942  (OR x (SLLconst [c] y)) -> (ORshiftLL x y [c])
   943  (OR x (SRLconst [c] y)) -> (ORshiftRL x y [c])
   944  (OR x (SRAconst [c] y)) -> (ORshiftRA x y [c])
   945  (OR x (SLL y z)) -> (ORshiftLLreg x y z)
   946  (OR x (SRL y z)) -> (ORshiftRLreg x y z)
   947  (OR x (SRA y z)) -> (ORshiftRAreg x y z)
   948  (XOR x (SLLconst [c] y)) -> (XORshiftLL x y [c])
   949  (XOR x (SRLconst [c] y)) -> (XORshiftRL x y [c])
   950  (XOR x (SRAconst [c] y)) -> (XORshiftRA x y [c])
   951  (XOR x (SRRconst [c] y)) -> (XORshiftRR x y [c])
   952  (XOR x (SLL y z)) -> (XORshiftLLreg x y z)
   953  (XOR x (SRL y z)) -> (XORshiftRLreg x y z)
   954  (XOR x (SRA y z)) -> (XORshiftRAreg x y z)
   955  (BIC x (SLLconst [c] y)) -> (BICshiftLL x y [c])
   956  (BIC x (SRLconst [c] y)) -> (BICshiftRL x y [c])
   957  (BIC x (SRAconst [c] y)) -> (BICshiftRA x y [c])
   958  (BIC x (SLL y z)) -> (BICshiftLLreg x y z)
   959  (BIC x (SRL y z)) -> (BICshiftRLreg x y z)
   960  (BIC x (SRA y z)) -> (BICshiftRAreg x y z)
   961  (MVN (SLLconst [c] x)) -> (MVNshiftLL x [c])
   962  (MVN (SRLconst [c] x)) -> (MVNshiftRL x [c])
   963  (MVN (SRAconst [c] x)) -> (MVNshiftRA x [c])
   964  (MVN (SLL x y)) -> (MVNshiftLLreg x y)
   965  (MVN (SRL x y)) -> (MVNshiftRLreg x y)
   966  (MVN (SRA x y)) -> (MVNshiftRAreg x y)
   967  
   968  (CMP x (SLLconst [c] y)) -> (CMPshiftLL x y [c])
   969  (CMP (SLLconst [c] y) x) -> (InvertFlags (CMPshiftLL x y [c]))
   970  (CMP x (SRLconst [c] y)) -> (CMPshiftRL x y [c])
   971  (CMP (SRLconst [c] y) x) -> (InvertFlags (CMPshiftRL x y [c]))
   972  (CMP x (SRAconst [c] y)) -> (CMPshiftRA x y [c])
   973  (CMP (SRAconst [c] y) x) -> (InvertFlags (CMPshiftRA x y [c]))
   974  (CMP x (SLL y z)) -> (CMPshiftLLreg x y z)
   975  (CMP (SLL y z) x) -> (InvertFlags (CMPshiftLLreg x y z))
   976  (CMP x (SRL y z)) -> (CMPshiftRLreg x y z)
   977  (CMP (SRL y z) x) -> (InvertFlags (CMPshiftRLreg x y z))
   978  (CMP x (SRA y z)) -> (CMPshiftRAreg x y z)
   979  (CMP (SRA y z) x) -> (InvertFlags (CMPshiftRAreg x y z))
   980  (TST x (SLLconst [c] y)) -> (TSTshiftLL x y [c])
   981  (TST x (SRLconst [c] y)) -> (TSTshiftRL x y [c])
   982  (TST x (SRAconst [c] y)) -> (TSTshiftRA x y [c])
   983  (TST x (SLL y z)) -> (TSTshiftLLreg x y z)
   984  (TST x (SRL y z)) -> (TSTshiftRLreg x y z)
   985  (TST x (SRA y z)) -> (TSTshiftRAreg x y z)
   986  (TEQ x (SLLconst [c] y)) -> (TEQshiftLL x y [c])
   987  (TEQ x (SRLconst [c] y)) -> (TEQshiftRL x y [c])
   988  (TEQ x (SRAconst [c] y)) -> (TEQshiftRA x y [c])
   989  (TEQ x (SLL y z)) -> (TEQshiftLLreg x y z)
   990  (TEQ x (SRL y z)) -> (TEQshiftRLreg x y z)
   991  (TEQ x (SRA y z)) -> (TEQshiftRAreg x y z)
   992  (CMN x (SLLconst [c] y)) -> (CMNshiftLL x y [c])
   993  (CMN x (SRLconst [c] y)) -> (CMNshiftRL x y [c])
   994  (CMN x (SRAconst [c] y)) -> (CMNshiftRA x y [c])
   995  (CMN x (SLL y z)) -> (CMNshiftLLreg x y z)
   996  (CMN x (SRL y z)) -> (CMNshiftRLreg x y z)
   997  (CMN x (SRA y z)) -> (CMNshiftRAreg x y z)
   998  
   999  // prefer *const ops to *shift ops
  1000  (ADDshiftLL (MOVWconst [c]) x [d]) -> (ADDconst [c] (SLLconst <x.Type> x [d]))
  1001  (ADDshiftRL (MOVWconst [c]) x [d]) -> (ADDconst [c] (SRLconst <x.Type> x [d]))
  1002  (ADDshiftRA (MOVWconst [c]) x [d]) -> (ADDconst [c] (SRAconst <x.Type> x [d]))
  1003  (ADCshiftLL (MOVWconst [c]) x [d] flags) -> (ADCconst [c] (SLLconst <x.Type> x [d]) flags)
  1004  (ADCshiftRL (MOVWconst [c]) x [d] flags) -> (ADCconst [c] (SRLconst <x.Type> x [d]) flags)
  1005  (ADCshiftRA (MOVWconst [c]) x [d] flags) -> (ADCconst [c] (SRAconst <x.Type> x [d]) flags)
  1006  (ADDSshiftLL (MOVWconst [c]) x [d]) -> (ADDSconst [c] (SLLconst <x.Type> x [d]))
  1007  (ADDSshiftRL (MOVWconst [c]) x [d]) -> (ADDSconst [c] (SRLconst <x.Type> x [d]))
  1008  (ADDSshiftRA (MOVWconst [c]) x [d]) -> (ADDSconst [c] (SRAconst <x.Type> x [d]))
  1009  (SUBshiftLL (MOVWconst [c]) x [d]) -> (RSBconst [c] (SLLconst <x.Type> x [d]))
  1010  (SUBshiftRL (MOVWconst [c]) x [d]) -> (RSBconst [c] (SRLconst <x.Type> x [d]))
  1011  (SUBshiftRA (MOVWconst [c]) x [d]) -> (RSBconst [c] (SRAconst <x.Type> x [d]))
  1012  (SBCshiftLL (MOVWconst [c]) x [d] flags) -> (RSCconst [c] (SLLconst <x.Type> x [d]) flags)
  1013  (SBCshiftRL (MOVWconst [c]) x [d] flags) -> (RSCconst [c] (SRLconst <x.Type> x [d]) flags)
  1014  (SBCshiftRA (MOVWconst [c]) x [d] flags) -> (RSCconst [c] (SRAconst <x.Type> x [d]) flags)
  1015  (SUBSshiftLL (MOVWconst [c]) x [d]) -> (RSBSconst [c] (SLLconst <x.Type> x [d]))
  1016  (SUBSshiftRL (MOVWconst [c]) x [d]) -> (RSBSconst [c] (SRLconst <x.Type> x [d]))
  1017  (SUBSshiftRA (MOVWconst [c]) x [d]) -> (RSBSconst [c] (SRAconst <x.Type> x [d]))
  1018  (RSBshiftLL (MOVWconst [c]) x [d]) -> (SUBconst [c] (SLLconst <x.Type> x [d]))
  1019  (RSBshiftRL (MOVWconst [c]) x [d]) -> (SUBconst [c] (SRLconst <x.Type> x [d]))
  1020  (RSBshiftRA (MOVWconst [c]) x [d]) -> (SUBconst [c] (SRAconst <x.Type> x [d]))
  1021  (RSCshiftLL (MOVWconst [c]) x [d] flags) -> (SBCconst [c] (SLLconst <x.Type> x [d]) flags)
  1022  (RSCshiftRL (MOVWconst [c]) x [d] flags) -> (SBCconst [c] (SRLconst <x.Type> x [d]) flags)
  1023  (RSCshiftRA (MOVWconst [c]) x [d] flags) -> (SBCconst [c] (SRAconst <x.Type> x [d]) flags)
  1024  (RSBSshiftLL (MOVWconst [c]) x [d]) -> (SUBSconst [c] (SLLconst <x.Type> x [d]))
  1025  (RSBSshiftRL (MOVWconst [c]) x [d]) -> (SUBSconst [c] (SRLconst <x.Type> x [d]))
  1026  (RSBSshiftRA (MOVWconst [c]) x [d]) -> (SUBSconst [c] (SRAconst <x.Type> x [d]))
  1027  (ANDshiftLL (MOVWconst [c]) x [d]) -> (ANDconst [c] (SLLconst <x.Type> x [d]))
  1028  (ANDshiftRL (MOVWconst [c]) x [d]) -> (ANDconst [c] (SRLconst <x.Type> x [d]))
  1029  (ANDshiftRA (MOVWconst [c]) x [d]) -> (ANDconst [c] (SRAconst <x.Type> x [d]))
  1030  (ORshiftLL (MOVWconst [c]) x [d]) -> (ORconst [c] (SLLconst <x.Type> x [d]))
  1031  (ORshiftRL (MOVWconst [c]) x [d]) -> (ORconst [c] (SRLconst <x.Type> x [d]))
  1032  (ORshiftRA (MOVWconst [c]) x [d]) -> (ORconst [c] (SRAconst <x.Type> x [d]))
  1033  (XORshiftLL (MOVWconst [c]) x [d]) -> (XORconst [c] (SLLconst <x.Type> x [d]))
  1034  (XORshiftRL (MOVWconst [c]) x [d]) -> (XORconst [c] (SRLconst <x.Type> x [d]))
  1035  (XORshiftRA (MOVWconst [c]) x [d]) -> (XORconst [c] (SRAconst <x.Type> x [d]))
  1036  (XORshiftRR (MOVWconst [c]) x [d]) -> (XORconst [c] (SRRconst <x.Type> x [d]))
  1037  (CMPshiftLL (MOVWconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SLLconst <x.Type> x [d])))
  1038  (CMPshiftRL (MOVWconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SRLconst <x.Type> x [d])))
  1039  (CMPshiftRA (MOVWconst [c]) x [d]) -> (InvertFlags (CMPconst [c] (SRAconst <x.Type> x [d])))
  1040  (TSTshiftLL (MOVWconst [c]) x [d]) -> (TSTconst [c] (SLLconst <x.Type> x [d]))
  1041  (TSTshiftRL (MOVWconst [c]) x [d]) -> (TSTconst [c] (SRLconst <x.Type> x [d]))
  1042  (TSTshiftRA (MOVWconst [c]) x [d]) -> (TSTconst [c] (SRAconst <x.Type> x [d]))
  1043  (TEQshiftLL (MOVWconst [c]) x [d]) -> (TEQconst [c] (SLLconst <x.Type> x [d]))
  1044  (TEQshiftRL (MOVWconst [c]) x [d]) -> (TEQconst [c] (SRLconst <x.Type> x [d]))
  1045  (TEQshiftRA (MOVWconst [c]) x [d]) -> (TEQconst [c] (SRAconst <x.Type> x [d]))
  1046  (CMNshiftLL (MOVWconst [c]) x [d]) -> (CMNconst [c] (SLLconst <x.Type> x [d]))
  1047  (CMNshiftRL (MOVWconst [c]) x [d]) -> (CMNconst [c] (SRLconst <x.Type> x [d]))
  1048  (CMNshiftRA (MOVWconst [c]) x [d]) -> (CMNconst [c] (SRAconst <x.Type> x [d]))
  1049  
  1050  (ADDshiftLLreg (MOVWconst [c]) x y) -> (ADDconst [c] (SLL <x.Type> x y))
  1051  (ADDshiftRLreg (MOVWconst [c]) x y) -> (ADDconst [c] (SRL <x.Type> x y))
  1052  (ADDshiftRAreg (MOVWconst [c]) x y) -> (ADDconst [c] (SRA <x.Type> x y))
  1053  (ADCshiftLLreg (MOVWconst [c]) x y flags) -> (ADCconst [c] (SLL <x.Type> x y) flags)
  1054  (ADCshiftRLreg (MOVWconst [c]) x y flags) -> (ADCconst [c] (SRL <x.Type> x y) flags)
  1055  (ADCshiftRAreg (MOVWconst [c]) x y flags) -> (ADCconst [c] (SRA <x.Type> x y) flags)
  1056  (ADDSshiftLLreg (MOVWconst [c]) x y) -> (ADDSconst [c] (SLL <x.Type> x y))
  1057  (ADDSshiftRLreg (MOVWconst [c]) x y) -> (ADDSconst [c] (SRL <x.Type> x y))
  1058  (ADDSshiftRAreg (MOVWconst [c]) x y) -> (ADDSconst [c] (SRA <x.Type> x y))
  1059  (SUBshiftLLreg (MOVWconst [c]) x y) -> (RSBconst [c] (SLL <x.Type> x y))
  1060  (SUBshiftRLreg (MOVWconst [c]) x y) -> (RSBconst [c] (SRL <x.Type> x y))
  1061  (SUBshiftRAreg (MOVWconst [c]) x y) -> (RSBconst [c] (SRA <x.Type> x y))
  1062  (SBCshiftLLreg (MOVWconst [c]) x y flags) -> (RSCconst [c] (SLL <x.Type> x y) flags)
  1063  (SBCshiftRLreg (MOVWconst [c]) x y flags) -> (RSCconst [c] (SRL <x.Type> x y) flags)
  1064  (SBCshiftRAreg (MOVWconst [c]) x y flags) -> (RSCconst [c] (SRA <x.Type> x y) flags)
  1065  (SUBSshiftLLreg (MOVWconst [c]) x y) -> (RSBSconst [c] (SLL <x.Type> x y))
  1066  (SUBSshiftRLreg (MOVWconst [c]) x y) -> (RSBSconst [c] (SRL <x.Type> x y))
  1067  (SUBSshiftRAreg (MOVWconst [c]) x y) -> (RSBSconst [c] (SRA <x.Type> x y))
  1068  (RSBshiftLLreg (MOVWconst [c]) x y) -> (SUBconst [c] (SLL <x.Type> x y))
  1069  (RSBshiftRLreg (MOVWconst [c]) x y) -> (SUBconst [c] (SRL <x.Type> x y))
  1070  (RSBshiftRAreg (MOVWconst [c]) x y) -> (SUBconst [c] (SRA <x.Type> x y))
  1071  (RSCshiftLLreg (MOVWconst [c]) x y flags) -> (SBCconst [c] (SLL <x.Type> x y) flags)
  1072  (RSCshiftRLreg (MOVWconst [c]) x y flags) -> (SBCconst [c] (SRL <x.Type> x y) flags)
  1073  (RSCshiftRAreg (MOVWconst [c]) x y flags) -> (SBCconst [c] (SRA <x.Type> x y) flags)
  1074  (RSBSshiftLLreg (MOVWconst [c]) x y) -> (SUBSconst [c] (SLL <x.Type> x y))
  1075  (RSBSshiftRLreg (MOVWconst [c]) x y) -> (SUBSconst [c] (SRL <x.Type> x y))
  1076  (RSBSshiftRAreg (MOVWconst [c]) x y) -> (SUBSconst [c] (SRA <x.Type> x y))
  1077  (ANDshiftLLreg (MOVWconst [c]) x y) -> (ANDconst [c] (SLL <x.Type> x y))
  1078  (ANDshiftRLreg (MOVWconst [c]) x y) -> (ANDconst [c] (SRL <x.Type> x y))
  1079  (ANDshiftRAreg (MOVWconst [c]) x y) -> (ANDconst [c] (SRA <x.Type> x y))
  1080  (ORshiftLLreg (MOVWconst [c]) x y) -> (ORconst [c] (SLL <x.Type> x y))
  1081  (ORshiftRLreg (MOVWconst [c]) x y) -> (ORconst [c] (SRL <x.Type> x y))
  1082  (ORshiftRAreg (MOVWconst [c]) x y) -> (ORconst [c] (SRA <x.Type> x y))
  1083  (XORshiftLLreg (MOVWconst [c]) x y) -> (XORconst [c] (SLL <x.Type> x y))
  1084  (XORshiftRLreg (MOVWconst [c]) x y) -> (XORconst [c] (SRL <x.Type> x y))
  1085  (XORshiftRAreg (MOVWconst [c]) x y) -> (XORconst [c] (SRA <x.Type> x y))
  1086  (CMPshiftLLreg (MOVWconst [c]) x y) -> (InvertFlags (CMPconst [c] (SLL <x.Type> x y)))
  1087  (CMPshiftRLreg (MOVWconst [c]) x y) -> (InvertFlags (CMPconst [c] (SRL <x.Type> x y)))
  1088  (CMPshiftRAreg (MOVWconst [c]) x y) -> (InvertFlags (CMPconst [c] (SRA <x.Type> x y)))
  1089  (TSTshiftLLreg (MOVWconst [c]) x y) -> (TSTconst [c] (SLL <x.Type> x y))
  1090  (TSTshiftRLreg (MOVWconst [c]) x y) -> (TSTconst [c] (SRL <x.Type> x y))
  1091  (TSTshiftRAreg (MOVWconst [c]) x y) -> (TSTconst [c] (SRA <x.Type> x y))
  1092  (TEQshiftLLreg (MOVWconst [c]) x y) -> (TEQconst [c] (SLL <x.Type> x y))
  1093  (TEQshiftRLreg (MOVWconst [c]) x y) -> (TEQconst [c] (SRL <x.Type> x y))
  1094  (TEQshiftRAreg (MOVWconst [c]) x y) -> (TEQconst [c] (SRA <x.Type> x y))
  1095  (CMNshiftLLreg (MOVWconst [c]) x y) -> (CMNconst [c] (SLL <x.Type> x y))
  1096  (CMNshiftRLreg (MOVWconst [c]) x y) -> (CMNconst [c] (SRL <x.Type> x y))
  1097  (CMNshiftRAreg (MOVWconst [c]) x y) -> (CMNconst [c] (SRA <x.Type> x y))
  1098  
  1099  // constant folding in *shift ops
  1100  (ADDshiftLL x (MOVWconst [c]) [d]) -> (ADDconst x [int64(int32(uint32(c)<<uint64(d)))])
  1101  (ADDshiftRL x (MOVWconst [c]) [d]) -> (ADDconst x [int64(int32(uint32(c)>>uint64(d)))])
  1102  (ADDshiftRA x (MOVWconst [c]) [d]) -> (ADDconst x [int64(int32(c)>>uint64(d))])
  1103  (ADCshiftLL x (MOVWconst [c]) [d] flags) -> (ADCconst x [int64(int32(uint32(c)<<uint64(d)))] flags)
  1104  (ADCshiftRL x (MOVWconst [c]) [d] flags) -> (ADCconst x [int64(int32(uint32(c)>>uint64(d)))] flags)
  1105  (ADCshiftRA x (MOVWconst [c]) [d] flags) -> (ADCconst x [int64(int32(c)>>uint64(d))] flags)
  1106  (ADDSshiftLL x (MOVWconst [c]) [d]) -> (ADDSconst x [int64(int32(uint32(c)<<uint64(d)))])
  1107  (ADDSshiftRL x (MOVWconst [c]) [d]) -> (ADDSconst x [int64(int32(uint32(c)>>uint64(d)))])
  1108  (ADDSshiftRA x (MOVWconst [c]) [d]) -> (ADDSconst x [int64(int32(c)>>uint64(d))])
  1109  (SUBshiftLL x (MOVWconst [c]) [d]) -> (SUBconst x [int64(int32(uint32(c)<<uint64(d)))])
  1110  (SUBshiftRL x (MOVWconst [c]) [d]) -> (SUBconst x [int64(int32(uint32(c)>>uint64(d)))])
  1111  (SUBshiftRA x (MOVWconst [c]) [d]) -> (SUBconst x [int64(int32(c)>>uint64(d))])
  1112  (SBCshiftLL x (MOVWconst [c]) [d] flags) -> (SBCconst x [int64(int32(uint32(c)<<uint64(d)))] flags)
  1113  (SBCshiftRL x (MOVWconst [c]) [d] flags) -> (SBCconst x [int64(int32(uint32(c)>>uint64(d)))] flags)
  1114  (SBCshiftRA x (MOVWconst [c]) [d] flags) -> (SBCconst x [int64(int32(c)>>uint64(d))] flags)
  1115  (SUBSshiftLL x (MOVWconst [c]) [d]) -> (SUBSconst x [int64(int32(uint32(c)<<uint64(d)))])
  1116  (SUBSshiftRL x (MOVWconst [c]) [d]) -> (SUBSconst x [int64(int32(uint32(c)>>uint64(d)))])
  1117  (SUBSshiftRA x (MOVWconst [c]) [d]) -> (SUBSconst x [int64(int32(c)>>uint64(d))])
  1118  (RSBshiftLL x (MOVWconst [c]) [d]) -> (RSBconst x [int64(int32(uint32(c)<<uint64(d)))])
  1119  (RSBshiftRL x (MOVWconst [c]) [d]) -> (RSBconst x [int64(int32(uint32(c)>>uint64(d)))])
  1120  (RSBshiftRA x (MOVWconst [c]) [d]) -> (RSBconst x [int64(int32(c)>>uint64(d))])
  1121  (RSCshiftLL x (MOVWconst [c]) [d] flags) -> (RSCconst x [int64(int32(uint32(c)<<uint64(d)))] flags)
  1122  (RSCshiftRL x (MOVWconst [c]) [d] flags) -> (RSCconst x [int64(int32(uint32(c)>>uint64(d)))] flags)
  1123  (RSCshiftRA x (MOVWconst [c]) [d] flags) -> (RSCconst x [int64(int32(c)>>uint64(d))] flags)
  1124  (RSBSshiftLL x (MOVWconst [c]) [d]) -> (RSBSconst x [int64(int32(uint32(c)<<uint64(d)))])
  1125  (RSBSshiftRL x (MOVWconst [c]) [d]) -> (RSBSconst x [int64(int32(uint32(c)>>uint64(d)))])
  1126  (RSBSshiftRA x (MOVWconst [c]) [d]) -> (RSBSconst x [int64(int32(c)>>uint64(d))])
  1127  (ANDshiftLL x (MOVWconst [c]) [d]) -> (ANDconst x [int64(int32(uint32(c)<<uint64(d)))])
  1128  (ANDshiftRL x (MOVWconst [c]) [d]) -> (ANDconst x [int64(int32(uint32(c)>>uint64(d)))])
  1129  (ANDshiftRA x (MOVWconst [c]) [d]) -> (ANDconst x [int64(int32(c)>>uint64(d))])
  1130  (ORshiftLL x (MOVWconst [c]) [d]) -> (ORconst x [int64(int32(uint32(c)<<uint64(d)))])
  1131  (ORshiftRL x (MOVWconst [c]) [d]) -> (ORconst x [int64(int32(uint32(c)>>uint64(d)))])
  1132  (ORshiftRA x (MOVWconst [c]) [d]) -> (ORconst x [int64(int32(c)>>uint64(d))])
  1133  (XORshiftLL x (MOVWconst [c]) [d]) -> (XORconst x [int64(int32(uint32(c)<<uint64(d)))])
  1134  (XORshiftRL x (MOVWconst [c]) [d]) -> (XORconst x [int64(int32(uint32(c)>>uint64(d)))])
  1135  (XORshiftRA x (MOVWconst [c]) [d]) -> (XORconst x [int64(int32(c)>>uint64(d))])
  1136  (XORshiftRR x (MOVWconst [c]) [d]) -> (XORconst x [int64(int32(uint32(c)>>uint64(d)|uint32(c)<<uint64(32-d)))])
  1137  (BICshiftLL x (MOVWconst [c]) [d]) -> (BICconst x [int64(int32(uint32(c)<<uint64(d)))])
  1138  (BICshiftRL x (MOVWconst [c]) [d]) -> (BICconst x [int64(int32(uint32(c)>>uint64(d)))])
  1139  (BICshiftRA x (MOVWconst [c]) [d]) -> (BICconst x [int64(int32(c)>>uint64(d))])
  1140  (MVNshiftLL (MOVWconst [c]) [d]) -> (MOVWconst [^int64(uint32(c)<<uint64(d))])
  1141  (MVNshiftRL (MOVWconst [c]) [d]) -> (MOVWconst [^int64(uint32(c)>>uint64(d))])
  1142  (MVNshiftRA (MOVWconst [c]) [d]) -> (MOVWconst [^int64(int32(c)>>uint64(d))])
  1143  (CMPshiftLL x (MOVWconst [c]) [d]) -> (CMPconst x [int64(int32(uint32(c)<<uint64(d)))])
  1144  (CMPshiftRL x (MOVWconst [c]) [d]) -> (CMPconst x [int64(int32(uint32(c)>>uint64(d)))])
  1145  (CMPshiftRA x (MOVWconst [c]) [d]) -> (CMPconst x [int64(int32(c)>>uint64(d))])
  1146  (TSTshiftLL x (MOVWconst [c]) [d]) -> (TSTconst x [int64(int32(uint32(c)<<uint64(d)))])
  1147  (TSTshiftRL x (MOVWconst [c]) [d]) -> (TSTconst x [int64(int32(uint32(c)>>uint64(d)))])
  1148  (TSTshiftRA x (MOVWconst [c]) [d]) -> (TSTconst x [int64(int32(c)>>uint64(d))])
  1149  (TEQshiftLL x (MOVWconst [c]) [d]) -> (TEQconst x [int64(int32(uint32(c)<<uint64(d)))])
  1150  (TEQshiftRL x (MOVWconst [c]) [d]) -> (TEQconst x [int64(int32(uint32(c)>>uint64(d)))])
  1151  (TEQshiftRA x (MOVWconst [c]) [d]) -> (TEQconst x [int64(int32(c)>>uint64(d))])
  1152  (CMNshiftLL x (MOVWconst [c]) [d]) -> (CMNconst x [int64(int32(uint32(c)<<uint64(d)))])
  1153  (CMNshiftRL x (MOVWconst [c]) [d]) -> (CMNconst x [int64(int32(uint32(c)>>uint64(d)))])
  1154  (CMNshiftRA x (MOVWconst [c]) [d]) -> (CMNconst x [int64(int32(c)>>uint64(d))])
  1155  
  1156  (ADDshiftLLreg x y (MOVWconst [c])) -> (ADDshiftLL x y [c])
  1157  (ADDshiftRLreg x y (MOVWconst [c])) -> (ADDshiftRL x y [c])
  1158  (ADDshiftRAreg x y (MOVWconst [c])) -> (ADDshiftRA x y [c])
  1159  (ADCshiftLLreg x y (MOVWconst [c]) flags) -> (ADCshiftLL x y [c] flags)
  1160  (ADCshiftRLreg x y (MOVWconst [c]) flags) -> (ADCshiftRL x y [c] flags)
  1161  (ADCshiftRAreg x y (MOVWconst [c]) flags) -> (ADCshiftRA x y [c] flags)
  1162  (ADDSshiftLLreg x y (MOVWconst [c])) -> (ADDSshiftLL x y [c])
  1163  (ADDSshiftRLreg x y (MOVWconst [c])) -> (ADDSshiftRL x y [c])
  1164  (ADDSshiftRAreg x y (MOVWconst [c])) -> (ADDSshiftRA x y [c])
  1165  (SUBshiftLLreg x y (MOVWconst [c])) -> (SUBshiftLL x y [c])
  1166  (SUBshiftRLreg x y (MOVWconst [c])) -> (SUBshiftRL x y [c])
  1167  (SUBshiftRAreg x y (MOVWconst [c])) -> (SUBshiftRA x y [c])
  1168  (SBCshiftLLreg x y (MOVWconst [c]) flags) -> (SBCshiftLL x y [c] flags)
  1169  (SBCshiftRLreg x y (MOVWconst [c]) flags) -> (SBCshiftRL x y [c] flags)
  1170  (SBCshiftRAreg x y (MOVWconst [c]) flags) -> (SBCshiftRA x y [c] flags)
  1171  (SUBSshiftLLreg x y (MOVWconst [c])) -> (SUBSshiftLL x y [c])
  1172  (SUBSshiftRLreg x y (MOVWconst [c])) -> (SUBSshiftRL x y [c])
  1173  (SUBSshiftRAreg x y (MOVWconst [c])) -> (SUBSshiftRA x y [c])
  1174  (RSBshiftLLreg x y (MOVWconst [c])) -> (RSBshiftLL x y [c])
  1175  (RSBshiftRLreg x y (MOVWconst [c])) -> (RSBshiftRL x y [c])
  1176  (RSBshiftRAreg x y (MOVWconst [c])) -> (RSBshiftRA x y [c])
  1177  (RSCshiftLLreg x y (MOVWconst [c]) flags) -> (RSCshiftLL x y [c] flags)
  1178  (RSCshiftRLreg x y (MOVWconst [c]) flags) -> (RSCshiftRL x y [c] flags)
  1179  (RSCshiftRAreg x y (MOVWconst [c]) flags) -> (RSCshiftRA x y [c] flags)
  1180  (RSBSshiftLLreg x y (MOVWconst [c])) -> (RSBSshiftLL x y [c])
  1181  (RSBSshiftRLreg x y (MOVWconst [c])) -> (RSBSshiftRL x y [c])
  1182  (RSBSshiftRAreg x y (MOVWconst [c])) -> (RSBSshiftRA x y [c])
  1183  (ANDshiftLLreg x y (MOVWconst [c])) -> (ANDshiftLL x y [c])
  1184  (ANDshiftRLreg x y (MOVWconst [c])) -> (ANDshiftRL x y [c])
  1185  (ANDshiftRAreg x y (MOVWconst [c])) -> (ANDshiftRA x y [c])
  1186  (ORshiftLLreg x y (MOVWconst [c])) -> (ORshiftLL x y [c])
  1187  (ORshiftRLreg x y (MOVWconst [c])) -> (ORshiftRL x y [c])
  1188  (ORshiftRAreg x y (MOVWconst [c])) -> (ORshiftRA x y [c])
  1189  (XORshiftLLreg x y (MOVWconst [c])) -> (XORshiftLL x y [c])
  1190  (XORshiftRLreg x y (MOVWconst [c])) -> (XORshiftRL x y [c])
  1191  (XORshiftRAreg x y (MOVWconst [c])) -> (XORshiftRA x y [c])
  1192  (BICshiftLLreg x y (MOVWconst [c])) -> (BICshiftLL x y [c])
  1193  (BICshiftRLreg x y (MOVWconst [c])) -> (BICshiftRL x y [c])
  1194  (BICshiftRAreg x y (MOVWconst [c])) -> (BICshiftRA x y [c])
  1195  (MVNshiftLLreg x (MOVWconst [c])) -> (MVNshiftLL x [c])
  1196  (MVNshiftRLreg x (MOVWconst [c])) -> (MVNshiftRL x [c])
  1197  (MVNshiftRAreg x (MOVWconst [c])) -> (MVNshiftRA x [c])
  1198  (CMPshiftLLreg x y (MOVWconst [c])) -> (CMPshiftLL x y [c])
  1199  (CMPshiftRLreg x y (MOVWconst [c])) -> (CMPshiftRL x y [c])
  1200  (CMPshiftRAreg x y (MOVWconst [c])) -> (CMPshiftRA x y [c])
  1201  (TSTshiftLLreg x y (MOVWconst [c])) -> (TSTshiftLL x y [c])
  1202  (TSTshiftRLreg x y (MOVWconst [c])) -> (TSTshiftRL x y [c])
  1203  (TSTshiftRAreg x y (MOVWconst [c])) -> (TSTshiftRA x y [c])
  1204  (TEQshiftLLreg x y (MOVWconst [c])) -> (TEQshiftLL x y [c])
  1205  (TEQshiftRLreg x y (MOVWconst [c])) -> (TEQshiftRL x y [c])
  1206  (TEQshiftRAreg x y (MOVWconst [c])) -> (TEQshiftRA x y [c])
  1207  (CMNshiftLLreg x y (MOVWconst [c])) -> (CMNshiftLL x y [c])
  1208  (CMNshiftRLreg x y (MOVWconst [c])) -> (CMNshiftRL x y [c])
  1209  (CMNshiftRAreg x y (MOVWconst [c])) -> (CMNshiftRA x y [c])
  1210  
  1211  // Generate rotates
  1212  (ADDshiftLL [c] (SRLconst x [32-c]) x) -> (SRRconst [32-c] x)
  1213  ( ORshiftLL [c] (SRLconst x [32-c]) x) -> (SRRconst [32-c] x)
  1214  (XORshiftLL [c] (SRLconst x [32-c]) x) -> (SRRconst [32-c] x)
  1215  (ADDshiftRL [c] (SLLconst x [32-c]) x) -> (SRRconst [   c] x)
  1216  ( ORshiftRL [c] (SLLconst x [32-c]) x) -> (SRRconst [   c] x)
  1217  (XORshiftRL [c] (SLLconst x [32-c]) x) -> (SRRconst [   c] x)
  1218  
  1219  // use indexed loads and stores
  1220  (MOVWload [0] {sym} (ADD ptr idx) mem) && sym == nil && !config.nacl -> (MOVWloadidx ptr idx mem)
  1221  (MOVWstore [0] {sym} (ADD ptr idx) val mem) && sym == nil && !config.nacl -> (MOVWstoreidx ptr idx val mem)
  1222  (MOVWload [0] {sym} (ADDshiftLL ptr idx [c]) mem) && sym == nil && !config.nacl -> (MOVWloadshiftLL ptr idx [c] mem)
  1223  (MOVWload [0] {sym} (ADDshiftRL ptr idx [c]) mem) && sym == nil && !config.nacl -> (MOVWloadshiftRL ptr idx [c] mem)
  1224  (MOVWload [0] {sym} (ADDshiftRA ptr idx [c]) mem) && sym == nil && !config.nacl -> (MOVWloadshiftRA ptr idx [c] mem)
  1225  (MOVWstore [0] {sym} (ADDshiftLL ptr idx [c]) val mem) && sym == nil && !config.nacl -> (MOVWstoreshiftLL ptr idx [c] val mem)
  1226  (MOVWstore [0] {sym} (ADDshiftRL ptr idx [c]) val mem) && sym == nil && !config.nacl -> (MOVWstoreshiftRL ptr idx [c] val mem)
  1227  (MOVWstore [0] {sym} (ADDshiftRA ptr idx [c]) val mem) && sym == nil && !config.nacl -> (MOVWstoreshiftRA ptr idx [c] val mem)
  1228  (MOVBUload [0] {sym} (ADD ptr idx) mem) && sym == nil && !config.nacl -> (MOVBUloadidx ptr idx mem)
  1229  (MOVBload [0] {sym} (ADD ptr idx) mem) && sym == nil && !config.nacl -> (MOVBloadidx ptr idx mem)
  1230  (MOVBstore [0] {sym} (ADD ptr idx) val mem) && sym == nil && !config.nacl -> (MOVBstoreidx ptr idx val mem)
  1231  (MOVHUload [0] {sym} (ADD ptr idx) mem) && sym == nil && !config.nacl -> (MOVHUloadidx ptr idx mem)
  1232  (MOVHload [0] {sym} (ADD ptr idx) mem) && sym == nil && !config.nacl -> (MOVHloadidx ptr idx mem)
  1233  (MOVHstore [0] {sym} (ADD ptr idx) val mem) && sym == nil && !config.nacl -> (MOVHstoreidx ptr idx val mem)
  1234  
  1235  // constant folding in indexed loads and stores
  1236  (MOVWloadidx ptr (MOVWconst [c]) mem) -> (MOVWload [c] ptr mem)
  1237  (MOVWloadidx (MOVWconst [c]) ptr mem) -> (MOVWload [c] ptr mem)
  1238  (MOVBloadidx ptr (MOVWconst [c]) mem) -> (MOVBload [c] ptr mem)
  1239  (MOVBloadidx (MOVWconst [c]) ptr mem) -> (MOVBload [c] ptr mem)
  1240  (MOVBUloadidx ptr (MOVWconst [c]) mem) -> (MOVBUload [c] ptr mem)
  1241  (MOVBUloadidx (MOVWconst [c]) ptr mem) -> (MOVBUload [c] ptr mem)
  1242  (MOVHUloadidx ptr (MOVWconst [c]) mem) -> (MOVHUload [c] ptr mem)
  1243  (MOVHUloadidx (MOVWconst [c]) ptr mem) -> (MOVHUload [c] ptr mem)
  1244  (MOVHloadidx ptr (MOVWconst [c]) mem) -> (MOVHload [c] ptr mem)
  1245  (MOVHloadidx (MOVWconst [c]) ptr mem) -> (MOVHload [c] ptr mem)
  1246  
  1247  (MOVWstoreidx ptr (MOVWconst [c]) val mem) -> (MOVWstore [c] ptr val mem)
  1248  (MOVWstoreidx (MOVWconst [c]) ptr val mem) -> (MOVWstore [c] ptr val mem)
  1249  (MOVBstoreidx ptr (MOVWconst [c]) val mem) -> (MOVBstore [c] ptr val mem)
  1250  (MOVBstoreidx (MOVWconst [c]) ptr val mem) -> (MOVBstore [c] ptr val mem)
  1251  (MOVHstoreidx ptr (MOVWconst [c]) val mem) -> (MOVHstore [c] ptr val mem)
  1252  (MOVHstoreidx (MOVWconst [c]) ptr val mem) -> (MOVHstore [c] ptr val mem)
  1253  
  1254  (MOVWloadidx ptr (SLLconst idx [c]) mem) -> (MOVWloadshiftLL ptr idx [c] mem)
  1255  (MOVWloadidx (SLLconst idx [c]) ptr mem) -> (MOVWloadshiftLL ptr idx [c] mem)
  1256  (MOVWloadidx ptr (SRLconst idx [c]) mem) -> (MOVWloadshiftRL ptr idx [c] mem)
  1257  (MOVWloadidx (SRLconst idx [c]) ptr mem) -> (MOVWloadshiftRL ptr idx [c] mem)
  1258  (MOVWloadidx ptr (SRAconst idx [c]) mem) -> (MOVWloadshiftRA ptr idx [c] mem)
  1259  (MOVWloadidx (SRAconst idx [c]) ptr mem) -> (MOVWloadshiftRA ptr idx [c] mem)
  1260  
  1261  (MOVWstoreidx ptr (SLLconst idx [c]) val mem) -> (MOVWstoreshiftLL ptr idx [c] val mem)
  1262  (MOVWstoreidx (SLLconst idx [c]) ptr val mem) -> (MOVWstoreshiftLL ptr idx [c] val mem)
  1263  (MOVWstoreidx ptr (SRLconst idx [c]) val mem) -> (MOVWstoreshiftRL ptr idx [c] val mem)
  1264  (MOVWstoreidx (SRLconst idx [c]) ptr val mem) -> (MOVWstoreshiftRL ptr idx [c] val mem)
  1265  (MOVWstoreidx ptr (SRAconst idx [c]) val mem) -> (MOVWstoreshiftRA ptr idx [c] val mem)
  1266  (MOVWstoreidx (SRAconst idx [c]) ptr val mem) -> (MOVWstoreshiftRA ptr idx [c] val mem)
  1267  
  1268  (MOVWloadshiftLL ptr (MOVWconst [c]) [d] mem) -> (MOVWload [int64(uint32(c)<<uint64(d))] ptr mem)
  1269  (MOVWloadshiftRL ptr (MOVWconst [c]) [d] mem) -> (MOVWload [int64(uint32(c)>>uint64(d))] ptr mem)
  1270  (MOVWloadshiftRA ptr (MOVWconst [c]) [d] mem) -> (MOVWload [int64(int32(c)>>uint64(d))] ptr mem)
  1271  
  1272  (MOVWstoreshiftLL ptr (MOVWconst [c]) [d] val mem) -> (MOVWstore [int64(uint32(c)<<uint64(d))] ptr val mem)
  1273  (MOVWstoreshiftRL ptr (MOVWconst [c]) [d] val mem) -> (MOVWstore [int64(uint32(c)>>uint64(d))] ptr val mem)
  1274  (MOVWstoreshiftRA ptr (MOVWconst [c]) [d] val mem) -> (MOVWstore [int64(int32(c)>>uint64(d))] ptr val mem)
  1275  
  1276  // generic simplifications
  1277  (ADD x (RSBconst [0] y)) -> (SUB x y)
  1278  (ADD <t> (RSBconst [c] x) (RSBconst [d] y)) -> (RSBconst [c+d] (ADD <t> x y))
  1279  (SUB x x) -> (MOVWconst [0])
  1280  (RSB x x) -> (MOVWconst [0])
  1281  (AND x x) -> x
  1282  (OR x x) -> x
  1283  (XOR x x) -> (MOVWconst [0])
  1284  (BIC x x) -> (MOVWconst [0])
  1285  
  1286  (ADD (MUL x y) a) -> (MULA x y a)
  1287  (SUB a (MUL x y)) && objabi.GOARM == 7 -> (MULS x y a)
  1288  (RSB (MUL x y) a) && objabi.GOARM == 7 -> (MULS x y a)
  1289  
  1290  (NEGF (MULF x y)) && objabi.GOARM >= 6 -> (NMULF x y)
  1291  (NEGD (MULD x y)) && objabi.GOARM >= 6 -> (NMULD x y)
  1292  (MULF (NEGF x) y) && objabi.GOARM >= 6 -> (NMULF x y)
  1293  (MULD (NEGD x) y) && objabi.GOARM >= 6 -> (NMULD x y)
  1294  (NMULF (NEGF x) y) -> (MULF x y)
  1295  (NMULD (NEGD x) y) -> (MULD x y)
  1296  
  1297  // the result will overwrite the addend, since they are in the same register
  1298  (ADDF a (MULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULAF a x y)
  1299  (ADDF a (NMULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULSF a x y)
  1300  (ADDD a (MULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULAD a x y)
  1301  (ADDD a (NMULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULSD a x y)
  1302  (SUBF a (MULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULSF a x y)
  1303  (SUBF a (NMULF x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULAF a x y)
  1304  (SUBD a (MULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULSD a x y)
  1305  (SUBD a (NMULD x y)) && a.Uses == 1 && objabi.GOARM >= 6 -> (MULAD a x y)
  1306  
  1307  (AND x (MVN y)) -> (BIC x y)
  1308  
  1309  // simplification with *shift ops
  1310  (SUBshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1311  (SUBshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1312  (SUBshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1313  (RSBshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1314  (RSBshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1315  (RSBshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1316  (ANDshiftLL x y:(SLLconst x [c]) [d]) && c==d -> y
  1317  (ANDshiftRL x y:(SRLconst x [c]) [d]) && c==d -> y
  1318  (ANDshiftRA x y:(SRAconst x [c]) [d]) && c==d -> y
  1319  (ORshiftLL x y:(SLLconst x [c]) [d]) && c==d -> y
  1320  (ORshiftRL x y:(SRLconst x [c]) [d]) && c==d -> y
  1321  (ORshiftRA x y:(SRAconst x [c]) [d]) && c==d -> y
  1322  (XORshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1323  (XORshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1324  (XORshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1325  (BICshiftLL x (SLLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1326  (BICshiftRL x (SRLconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1327  (BICshiftRA x (SRAconst x [c]) [d]) && c==d -> (MOVWconst [0])
  1328  (AND x (MVNshiftLL y [c])) -> (BICshiftLL x y [c])
  1329  (AND x (MVNshiftRL y [c])) -> (BICshiftRL x y [c])
  1330  (AND x (MVNshiftRA y [c])) -> (BICshiftRA x y [c])
  1331  
  1332  // floating point optimizations
  1333  (CMPF x (MOVFconst [0])) -> (CMPF0 x)
  1334  (CMPD x (MOVDconst [0])) -> (CMPD0 x)
  1335  
  1336  // bit extraction
  1337  (SRAconst (SLLconst x [c]) [d]) && objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 -> (BFX [(d-c)|(32-d)<<8] x)
  1338  (SRLconst (SLLconst x [c]) [d]) && objabi.GOARM==7 && uint64(d)>=uint64(c) && uint64(d)<=31 -> (BFXU [(d-c)|(32-d)<<8] x)
  1339  
  1340  // comparison simplification
  1341  (CMP x (RSBconst [0] y)) -> (CMN x y)
  1342  (CMN x (RSBconst [0] y)) -> (CMP x y)
  1343  (EQ (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (EQ (CMP x y) yes no)
  1344  (EQ (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (EQ (CMP a (MUL <x.Type> x y)) yes no)
  1345  (EQ (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (EQ (CMPconst [c] x) yes no)
  1346  (EQ (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) && l.Uses==1 -> (EQ (CMPshiftLL x y [c]) yes no)
  1347  (EQ (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) && l.Uses==1 -> (EQ (CMPshiftRL x y [c]) yes no)
  1348  (EQ (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) && l.Uses==1 -> (EQ (CMPshiftRA x y [c]) yes no)
  1349  (EQ (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) && l.Uses==1 -> (EQ (CMPshiftLLreg x y z) yes no)
  1350  (EQ (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) && l.Uses==1 -> (EQ (CMPshiftRLreg x y z) yes no)
  1351  (EQ (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) && l.Uses==1 -> (EQ (CMPshiftRAreg x y z) yes no)
  1352  (NE (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (NE (CMP x y) yes no)
  1353  (NE (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (NE (CMP a (MUL <x.Type> x y)) yes no)
  1354  (NE (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (NE (CMPconst [c] x) yes no)
  1355  (NE (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) && l.Uses==1 -> (NE (CMPshiftLL x y [c]) yes no)
  1356  (NE (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) && l.Uses==1 -> (NE (CMPshiftRL x y [c]) yes no)
  1357  (NE (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) && l.Uses==1 -> (NE (CMPshiftRA x y [c]) yes no)
  1358  (NE (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) && l.Uses==1 -> (NE (CMPshiftLLreg x y z) yes no)
  1359  (NE (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) && l.Uses==1 -> (NE (CMPshiftRLreg x y z) yes no)
  1360  (NE (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) && l.Uses==1 -> (NE (CMPshiftRAreg x y z) yes no)
  1361  (EQ (CMPconst [0] l:(ADD x y)) yes no) && l.Uses==1 -> (EQ (CMN x y) yes no)
  1362  (EQ (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (EQ (CMN a (MUL <x.Type> x y)) yes no)
  1363  (EQ (CMPconst [0] l:(ADDconst [c] x)) yes no) && l.Uses==1 -> (EQ (CMNconst [c] x) yes no)
  1364  (EQ (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) && l.Uses==1 -> (EQ (CMNshiftLL x y [c]) yes no)
  1365  (EQ (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) && l.Uses==1 -> (EQ (CMNshiftRL x y [c]) yes no)
  1366  (EQ (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) && l.Uses==1 -> (EQ (CMNshiftRA x y [c]) yes no)
  1367  (EQ (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (EQ (CMNshiftLLreg x y z) yes no)
  1368  (EQ (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (EQ (CMNshiftRLreg x y z) yes no)
  1369  (EQ (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (EQ (CMNshiftRAreg x y z) yes no)
  1370  (NE (CMPconst [0] l:(ADD x y)) yes no) && l.Uses==1 -> (NE (CMN x y) yes no)
  1371  (NE (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (NE (CMN a (MUL <x.Type> x y)) yes no)
  1372  (NE (CMPconst [0] l:(ADDconst [c] x)) yes no) && l.Uses==1 -> (NE (CMNconst [c] x) yes no)
  1373  (NE (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) && l.Uses==1 -> (NE (CMNshiftLL x y [c]) yes no)
  1374  (NE (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) && l.Uses==1 -> (NE (CMNshiftRL x y [c]) yes no)
  1375  (NE (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) && l.Uses==1 -> (NE (CMNshiftRA x y [c]) yes no)
  1376  (NE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (NE (CMNshiftLLreg x y z) yes no)
  1377  (NE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (NE (CMNshiftRLreg x y z) yes no)
  1378  (NE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (NE (CMNshiftRAreg x y z) yes no)
  1379  (EQ (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (EQ (TST x y) yes no)
  1380  (EQ (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (EQ (TSTconst [c] x) yes no)
  1381  (EQ (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (EQ (TSTshiftLL x y [c]) yes no)
  1382  (EQ (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (EQ (TSTshiftRL x y [c]) yes no)
  1383  (EQ (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (EQ (TSTshiftRA x y [c]) yes no)
  1384  (EQ (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (EQ (TSTshiftLLreg x y z) yes no)
  1385  (EQ (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (EQ (TSTshiftRLreg x y z) yes no)
  1386  (EQ (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (EQ (TSTshiftRAreg x y z) yes no)
  1387  (NE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (NE (TST x y) yes no)
  1388  (NE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (NE (TSTconst [c] x) yes no)
  1389  (NE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (NE (TSTshiftLL x y [c]) yes no)
  1390  (NE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (NE (TSTshiftRL x y [c]) yes no)
  1391  (NE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (NE (TSTshiftRA x y [c]) yes no)
  1392  (NE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (NE (TSTshiftLLreg x y z) yes no)
  1393  (NE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (NE (TSTshiftRLreg x y z) yes no)
  1394  (NE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (NE (TSTshiftRAreg x y z) yes no)
  1395  (EQ (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (EQ (TEQ x y) yes no)
  1396  (EQ (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (EQ (TEQconst [c] x) yes no)
  1397  (EQ (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (EQ (TEQshiftLL x y [c]) yes no)
  1398  (EQ (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (EQ (TEQshiftRL x y [c]) yes no)
  1399  (EQ (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (EQ (TEQshiftRA x y [c]) yes no)
  1400  (EQ (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (EQ (TEQshiftLLreg x y z) yes no)
  1401  (EQ (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (EQ (TEQshiftRLreg x y z) yes no)
  1402  (EQ (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (EQ (TEQshiftRAreg x y z) yes no)
  1403  (NE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (NE (TEQ x y) yes no)
  1404  (NE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (NE (TEQconst [c] x) yes no)
  1405  (NE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (NE (TEQshiftLL x y [c]) yes no)
  1406  (NE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (NE (TEQshiftRL x y [c]) yes no)
  1407  (NE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (NE (TEQshiftRA x y [c]) yes no)
  1408  (NE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (NE (TEQshiftLLreg x y z) yes no)
  1409  (NE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (NE (TEQshiftRLreg x y z) yes no)
  1410  (NE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (NE (TEQshiftRAreg x y z) yes no)
  1411  (LT (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (LT (CMP x y) yes no)
  1412  (LT (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (LT (CMP a (MUL <x.Type> x y)) yes no)
  1413  (LT (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (LT (CMPconst [c] x) yes no)
  1414  (LT (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (CMPshiftLL x y [c]) yes no)
  1415  (LT (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (CMPshiftRL x y [c]) yes no)
  1416  (LT (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (CMPshiftRA x y [c]) yes no)
  1417  (LT (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (CMPshiftLLreg x y z) yes no)
  1418  (LT (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (CMPshiftRLreg x y z) yes no)
  1419  (LT (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (CMPshiftRAreg x y z) yes no)
  1420  (LE (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (LE (CMP x y) yes no)
  1421  (LE (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (LE (CMP a (MUL <x.Type> x y)) yes no)
  1422  (LE (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (LE (CMPconst [c] x) yes no)
  1423  (LE (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (CMPshiftLL x y [c]) yes no)
  1424  (LE (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (CMPshiftRL x y [c]) yes no)
  1425  (LE (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (CMPshiftRA x y [c]) yes no)
  1426  (LE (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (CMPshiftLLreg x y z) yes no)
  1427  (LE (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (CMPshiftRLreg x y z) yes no)
  1428  (LE (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (CMPshiftRAreg x y z) yes no)
  1429  (LT (CMPconst [0] l:(ADD x y)) yes no) && l.Uses==1 -> (LT (CMN x y) yes no)
  1430  (LT (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (LT (CMN a (MUL <x.Type> x y)) yes no)
  1431  (LT (CMPconst [0] l:(ADDconst [c] x)) yes no) && l.Uses==1 -> (LT (CMNconst [c] x) yes no)
  1432  (LT (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (CMNshiftLL x y [c]) yes no)
  1433  (LT (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (CMNshiftRL x y [c]) yes no)
  1434  (LT (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (CMNshiftRA x y [c]) yes no)
  1435  (LT (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (CMNshiftLLreg x y z) yes no)
  1436  (LT (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (CMNshiftRLreg x y z) yes no)
  1437  (LT (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (CMNshiftRAreg x y z) yes no)
  1438  (LE (CMPconst [0] l:(ADD x y)) yes no) && l.Uses==1 -> (LE (CMN x y) yes no)
  1439  (LE (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (LE (CMN a (MUL <x.Type> x y)) yes no)
  1440  (LE (CMPconst [0] l:(ADDconst [c] x)) yes no) && l.Uses==1  -> (LE (CMNconst [c] x) yes no)
  1441  (LE (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (CMNshiftLL x y [c]) yes no)
  1442  (LE (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (CMNshiftRL x y [c]) yes no)
  1443  (LE (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (CMNshiftRA x y [c]) yes no)
  1444  (LE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (CMNshiftLLreg x y z) yes no)
  1445  (LE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (CMNshiftRLreg x y z) yes no)
  1446  (LE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (CMNshiftRAreg x y z) yes no)
  1447  (LT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LT (TST x y) yes no)
  1448  (LT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LT (TSTconst [c] x) yes no)
  1449  (LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftLL x y [c]) yes no)
  1450  (LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRL x y [c]) yes no)
  1451  (LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRA x y [c]) yes no)
  1452  (LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftLLreg x y z) yes no)
  1453  (LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRLreg x y z) yes no)
  1454  (LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRAreg x y z) yes no)
  1455  (LE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LE (TST x y) yes no)
  1456  (LE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LE (TSTconst [c] x) yes no)
  1457  (LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftLL x y [c]) yes no)
  1458  (LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRL x y [c]) yes no)
  1459  (LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRA x y [c]) yes no)
  1460  (LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftLLreg x y z) yes no)
  1461  (LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRLreg x y z) yes no)
  1462  (LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRAreg x y z) yes no)
  1463  (LT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LT (TEQ x y) yes no)
  1464  (LT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LT (TEQconst [c] x) yes no)
  1465  (LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftLL x y [c]) yes no)
  1466  (LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRL x y [c]) yes no)
  1467  (LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRA x y [c]) yes no)
  1468  (LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftLLreg x y z) yes no)
  1469  (LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRLreg x y z) yes no)
  1470  (LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRAreg x y z) yes no)
  1471  (LE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LE (TEQ x y) yes no)
  1472  (LE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1  -> (LE (TEQconst [c] x) yes no)
  1473  (LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftLL x y [c]) yes no)
  1474  (LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRL x y [c]) yes no)
  1475  (LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRA x y [c]) yes no)
  1476  (LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftLLreg x y z) yes no)
  1477  (LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRLreg x y z) yes no)
  1478  (LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRAreg x y z) yes no)
  1479  (GT (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (GT (CMP x y) yes no)
  1480  (GT (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (GT (CMP a (MUL <x.Type> x y)) yes no)
  1481  (GT (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (GT (CMPconst [c] x) yes no)
  1482  (GT (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (CMPshiftLL x y [c]) yes no)
  1483  (GT (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (CMPshiftRL x y [c]) yes no)
  1484  (GT (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (CMPshiftRA x y [c]) yes no)
  1485  (GT (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (CMPshiftLLreg x y z) yes no)
  1486  (GT (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (CMPshiftRLreg x y z) yes no)
  1487  (GT (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (CMPshiftRAreg x y z) yes no)
  1488  (GE (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (GE (CMP x y) yes no)
  1489  (GE (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (GE (CMP a (MUL <x.Type> x y)) yes no)
  1490  (GE (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (GE (CMPconst [c] x) yes no)
  1491  (GE (CMPconst [0] l:(SUBshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (CMPshiftLL x y [c]) yes no)
  1492  (GE (CMPconst [0] l:(SUBshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (CMPshiftRL x y [c]) yes no)
  1493  (GE (CMPconst [0] l:(SUBshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (CMPshiftRA x y [c]) yes no)
  1494  (GE (CMPconst [0] l:(SUBshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (CMPshiftLLreg x y z) yes no)
  1495  (GE (CMPconst [0] l:(SUBshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (CMPshiftRLreg x y z) yes no)
  1496  (GE (CMPconst [0] l:(SUBshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (CMPshiftRAreg x y z) yes no)
  1497  (GT (CMPconst [0] l:(ADD x y)) yes no) && l.Uses==1 -> (GT (CMN x y) yes no)
  1498  (GT (CMPconst [0] l:(ADDconst [c] x)) yes no) && l.Uses==1 -> (GT (CMNconst [c] x) yes no)
  1499  (GT (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (CMNshiftLL x y [c]) yes no)
  1500  (GT (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (CMNshiftRL x y [c]) yes no)
  1501  (GT (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (CMNshiftRA x y [c]) yes no)
  1502  (GT (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (CMNshiftLLreg x y z) yes no)
  1503  (GT (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (CMNshiftRLreg x y z) yes no)
  1504  (GT (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (CMNshiftRAreg x y z) yes no)
  1505  (GE (CMPconst [0] l:(ADD x y)) yes no) && l.Uses==1 -> (GE (CMN x y) yes no)
  1506  (GE (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (GE (CMN a (MUL <x.Type> x y)) yes no)
  1507  (GE (CMPconst [0] l:(ADDconst [c] x)) yes no) && l.Uses==1 -> (GE (CMNconst [c] x) yes no)
  1508  (GE (CMPconst [0] l:(ADDshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (CMNshiftLL x y [c]) yes no)
  1509  (GE (CMPconst [0] l:(ADDshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (CMNshiftRL x y [c]) yes no)
  1510  (GE (CMPconst [0] l:(ADDshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (CMNshiftRA x y [c]) yes no)
  1511  (GE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (CMNshiftLLreg x y z) yes no)
  1512  (GE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (CMNshiftRLreg x y z) yes no)
  1513  (GE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (CMNshiftRAreg x y z) yes no)
  1514  (GT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GT (TST x y) yes no)
  1515  (GT (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (GT (CMN a (MUL <x.Type> x y)) yes no)
  1516  (GT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GT (TSTconst [c] x) yes no)
  1517  (GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftLL x y [c]) yes no)
  1518  (GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRL x y [c]) yes no)
  1519  (GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRA x y [c]) yes no)
  1520  (GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftLLreg x y z) yes no)
  1521  (GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRLreg x y z) yes no)
  1522  (GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRAreg x y z) yes no)
  1523  (GE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GE (TST x y) yes no)
  1524  (GE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GE (TSTconst [c] x) yes no)
  1525  (GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftLL x y [c]) yes no)
  1526  (GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRL x y [c]) yes no)
  1527  (GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRA x y [c]) yes no)
  1528  (GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftLLreg x y z) yes no)
  1529  (GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRLreg x y z) yes no)
  1530  (GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRAreg x y z) yes no)
  1531  (GT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GT (TEQ x y) yes no)
  1532  (GT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GT (TEQconst [c] x) yes no)
  1533  (GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftLL x y [c]) yes no)
  1534  (GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRL x y [c]) yes no)
  1535  (GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRA x y [c]) yes no)
  1536  (GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftLLreg x y z) yes no)
  1537  (GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRLreg x y z) yes no)
  1538  (GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRAreg x y z) yes no)
  1539  (GE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GE (TEQ x y) yes no)
  1540  (GE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GE (TEQconst [c] x) yes no)
  1541  (GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftLL x y [c]) yes no)
  1542  (GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRL x y [c]) yes no)
  1543  (GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRA x y [c]) yes no)
  1544  (GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftLLreg x y z) yes no)
  1545  (GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRLreg x y z) yes no)
  1546  (GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRAreg x y z) yes no)
  1547  
  1548  (MOVBUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read8(sym, off))])
  1549  (MOVHUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read16(sym, off, config.BigEndian))])
  1550  (MOVWload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(int32(read32(sym, off, config.BigEndian)))])