| // Copyright 2016 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| (Add(Ptr|64|32|16|8) ...) => (ADD ...) |
| (Add(32F|64F) ...) => (FADD(S|D) ...) |
| |
| (Sub(Ptr|64|32|16|8) ...) => (SUB ...) |
| (Sub(32F|64F) ...) => (FSUB(S|D) ...) |
| |
| (Mul64 ...) => (MUL ...) |
| (Mul(32|16|8) ...) => (MULW ...) |
| (Mul(32F|64F) ...) => (FMUL(S|D) ...) |
| |
| (Hmul64 ...) => (MULH ...) |
| (Hmul64u ...) => (UMULH ...) |
| (Hmul32 x y) => (SRAconst (MULL <typ.Int64> x y) [32]) |
| (Hmul32u x y) => (SRAconst (UMULL <typ.UInt64> x y) [32]) |
| (Mul64uhilo ...) => (LoweredMuluhilo ...) |
| |
| (Div64 [false] x y) => (DIV x y) |
| (Div64u ...) => (UDIV ...) |
| (Div32 [false] x y) => (DIVW x y) |
| (Div32u ...) => (UDIVW ...) |
| (Div16 [false] x y) => (DIVW (SignExt16to32 x) (SignExt16to32 y)) |
| (Div16u x y) => (UDIVW (ZeroExt16to32 x) (ZeroExt16to32 y)) |
| (Div8 x y) => (DIVW (SignExt8to32 x) (SignExt8to32 y)) |
| (Div8u x y) => (UDIVW (ZeroExt8to32 x) (ZeroExt8to32 y)) |
| (Div32F ...) => (FDIVS ...) |
| (Div64F ...) => (FDIVD ...) |
| |
| (Mod64 x y) => (MOD x y) |
| (Mod64u ...) => (UMOD ...) |
| (Mod32 x y) => (MODW x y) |
| (Mod32u ...) => (UMODW ...) |
| (Mod16 x y) => (MODW (SignExt16to32 x) (SignExt16to32 y)) |
| (Mod16u x y) => (UMODW (ZeroExt16to32 x) (ZeroExt16to32 y)) |
| (Mod8 x y) => (MODW (SignExt8to32 x) (SignExt8to32 y)) |
| (Mod8u x y) => (UMODW (ZeroExt8to32 x) (ZeroExt8to32 y)) |
| |
| // (x + y) / 2 with x>=y => (x - y) / 2 + y |
| (Avg64u <t> x y) => (ADD (SRLconst <t> (SUB <t> x y) [1]) y) |
| |
| (And(64|32|16|8) ...) => (AND ...) |
| (Or(64|32|16|8) ...) => (OR ...) |
| (Xor(64|32|16|8) ...) => (XOR ...) |
| |
| // unary ops |
| (Neg(64|32|16|8) ...) => (NEG ...) |
| (Neg(32F|64F) ...) => (FNEG(S|D) ...) |
| (Com(64|32|16|8) ...) => (MVN ...) |
| |
| // math package intrinsics |
| (Abs ...) => (FABSD ...) |
| (Sqrt ...) => (FSQRTD ...) |
| (Ceil ...) => (FRINTPD ...) |
| (Floor ...) => (FRINTMD ...) |
| (Round ...) => (FRINTAD ...) |
| (RoundToEven ...) => (FRINTND ...) |
| (Trunc ...) => (FRINTZD ...) |
| (FMA x y z) => (FMADDD z x y) |
| |
| (Sqrt32 ...) => (FSQRTS ...) |
| |
| // lowering rotates |
| (RotateLeft8 <t> x (MOVDconst [c])) => (Or8 (Lsh8x64 <t> x (MOVDconst [c&7])) (Rsh8Ux64 <t> x (MOVDconst [-c&7]))) |
| (RotateLeft16 <t> x (MOVDconst [c])) => (Or16 (Lsh16x64 <t> x (MOVDconst [c&15])) (Rsh16Ux64 <t> x (MOVDconst [-c&15]))) |
| (RotateLeft32 x y) => (RORW x (NEG <y.Type> y)) |
| (RotateLeft64 x y) => (ROR x (NEG <y.Type> y)) |
| |
| (Ctz(64|32|16|8)NonZero ...) => (Ctz(64|32|32|32) ...) |
| |
| (Ctz64 <t> x) => (CLZ (RBIT <t> x)) |
| (Ctz32 <t> x) => (CLZW (RBITW <t> x)) |
| (Ctz16 <t> x) => (CLZW <t> (RBITW <typ.UInt32> (ORconst <typ.UInt32> [0x10000] x))) |
| (Ctz8 <t> x) => (CLZW <t> (RBITW <typ.UInt32> (ORconst <typ.UInt32> [0x100] x))) |
| |
| (PopCount64 <t> x) => (FMOVDfpgp <t> (VUADDLV <typ.Float64> (VCNT <typ.Float64> (FMOVDgpfp <typ.Float64> x)))) |
| (PopCount32 <t> x) => (FMOVDfpgp <t> (VUADDLV <typ.Float64> (VCNT <typ.Float64> (FMOVDgpfp <typ.Float64> (ZeroExt32to64 x))))) |
| (PopCount16 <t> x) => (FMOVDfpgp <t> (VUADDLV <typ.Float64> (VCNT <typ.Float64> (FMOVDgpfp <typ.Float64> (ZeroExt16to64 x))))) |
| |
| // Load args directly into the register class where it will be used. |
| (FMOVDgpfp <t> (Arg [off] {sym})) => @b.Func.Entry (Arg <t> [off] {sym}) |
| (FMOVDfpgp <t> (Arg [off] {sym})) => @b.Func.Entry (Arg <t> [off] {sym}) |
| |
| // Similarly for stores, if we see a store after FPR <=> GPR move, then redirect store to use the other register set. |
| (MOVDstore [off] {sym} ptr (FMOVDfpgp val) mem) => (FMOVDstore [off] {sym} ptr val mem) |
| (FMOVDstore [off] {sym} ptr (FMOVDgpfp val) mem) => (MOVDstore [off] {sym} ptr val mem) |
| (MOVWstore [off] {sym} ptr (FMOVSfpgp val) mem) => (FMOVSstore [off] {sym} ptr val mem) |
| (FMOVSstore [off] {sym} ptr (FMOVSgpfp val) mem) => (MOVWstore [off] {sym} ptr val mem) |
| |
| // float <=> int register moves, with no conversion. |
| // These come up when compiling math.{Float64bits, Float64frombits, Float32bits, Float32frombits}. |
| (MOVDload [off] {sym} ptr (FMOVDstore [off] {sym} ptr val _)) => (FMOVDfpgp val) |
| (FMOVDload [off] {sym} ptr (MOVDstore [off] {sym} ptr val _)) => (FMOVDgpfp val) |
| (MOVWUload [off] {sym} ptr (FMOVSstore [off] {sym} ptr val _)) => (FMOVSfpgp val) |
| (FMOVSload [off] {sym} ptr (MOVWstore [off] {sym} ptr val _)) => (FMOVSgpfp val) |
| |
| (BitLen64 x) => (SUB (MOVDconst [64]) (CLZ <typ.Int> x)) |
| (BitLen32 x) => (SUB (MOVDconst [32]) (CLZW <typ.Int> x)) |
| |
| (Bswap64 ...) => (REV ...) |
| (Bswap32 ...) => (REVW ...) |
| |
| (BitRev64 ...) => (RBIT ...) |
| (BitRev32 ...) => (RBITW ...) |
| (BitRev16 x) => (SRLconst [48] (RBIT <typ.UInt64> x)) |
| (BitRev8 x) => (SRLconst [56] (RBIT <typ.UInt64> x)) |
| |
| // In fact, UMOD will be translated into UREM instruction, and UREM is originally translated into |
| // UDIV and MSUB instructions. But if there is already an identical UDIV instruction just before or |
| // after UREM (case like quo, rem := z/y, z%y), then the second UDIV instruction becomes redundant. |
| // The purpose of this rule is to have this extra UDIV instruction removed in CSE pass. |
| (UMOD <typ.UInt64> x y) => (MSUB <typ.UInt64> x y (UDIV <typ.UInt64> x y)) |
| (UMODW <typ.UInt32> x y) => (MSUBW <typ.UInt32> x y (UDIVW <typ.UInt32> x y)) |
| |
| // 64-bit addition with carry. |
| (Select0 (Add64carry x y c)) => (Select0 <typ.UInt64> (ADCSflags x y (Select1 <types.TypeFlags> (ADDSconstflags [-1] c)))) |
| (Select1 (Add64carry x y c)) => (ADCzerocarry <typ.UInt64> (Select1 <types.TypeFlags> (ADCSflags x y (Select1 <types.TypeFlags> (ADDSconstflags [-1] c))))) |
| |
| // 64-bit subtraction with borrowing. |
| (Select0 (Sub64borrow x y bo)) => (Select0 <typ.UInt64> (SBCSflags x y (Select1 <types.TypeFlags> (NEGSflags bo)))) |
| (Select1 (Sub64borrow x y bo)) => (NEG <typ.UInt64> (NGCzerocarry <typ.UInt64> (Select1 <types.TypeFlags> (SBCSflags x y (Select1 <types.TypeFlags> (NEGSflags bo)))))) |
| |
| // boolean ops -- booleans are represented with 0=false, 1=true |
| (AndB ...) => (AND ...) |
| (OrB ...) => (OR ...) |
| (EqB x y) => (XOR (MOVDconst [1]) (XOR <typ.Bool> x y)) |
| (NeqB ...) => (XOR ...) |
| (Not x) => (XOR (MOVDconst [1]) x) |
| |
| // shifts |
| // hardware instruction uses only the low 6 bits of the shift |
| // we compare to 64 to ensure Go semantics for large shifts |
| // Rules about rotates with non-const shift are based on the following rules, |
| // if the following rules change, please also modify the rules based on them. |
| (Lsh64x64 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Lsh64x32 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Lsh64x16 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Lsh64x8 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Lsh32x64 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Lsh32x32 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Lsh32x16 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Lsh32x8 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Lsh16x64 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Lsh16x32 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Lsh16x16 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Lsh16x8 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Lsh8x64 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Lsh8x32 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Lsh8x16 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Lsh8x8 <t> x y) => (CSEL [OpARM64LessThanU] (SLL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Rsh64Ux64 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> x y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Rsh64Ux32 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> x (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Rsh64Ux16 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> x (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Rsh64Ux8 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> x (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Rsh32Ux64 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt32to64 x) y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Rsh32Ux32 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt32to64 x) (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Rsh32Ux16 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt32to64 x) (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Rsh32Ux8 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt32to64 x) (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Rsh16Ux64 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt16to64 x) y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Rsh16Ux32 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt16to64 x) (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Rsh16Ux16 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt16to64 x) (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Rsh16Ux8 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt16to64 x) (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Rsh8Ux64 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt8to64 x) y) (Const64 <t> [0]) (CMPconst [64] y)) |
| (Rsh8Ux32 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt8to64 x) (ZeroExt32to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt32to64 y))) |
| (Rsh8Ux16 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt8to64 x) (ZeroExt16to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt16to64 y))) |
| (Rsh8Ux8 <t> x y) => (CSEL [OpARM64LessThanU] (SRL <t> (ZeroExt8to64 x) (ZeroExt8to64 y)) (Const64 <t> [0]) (CMPconst [64] (ZeroExt8to64 y))) |
| |
| (Rsh64x64 x y) => (SRA x (CSEL [OpARM64LessThanU] <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) |
| (Rsh64x32 x y) => (SRA x (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) |
| (Rsh64x16 x y) => (SRA x (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) |
| (Rsh64x8 x y) => (SRA x (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) |
| |
| (Rsh32x64 x y) => (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) |
| (Rsh32x32 x y) => (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) |
| (Rsh32x16 x y) => (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) |
| (Rsh32x8 x y) => (SRA (SignExt32to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) |
| |
| (Rsh16x64 x y) => (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) |
| (Rsh16x32 x y) => (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) |
| (Rsh16x16 x y) => (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) |
| (Rsh16x8 x y) => (SRA (SignExt16to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) |
| |
| (Rsh8x64 x y) => (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] <y.Type> y (Const64 <y.Type> [63]) (CMPconst [64] y))) |
| (Rsh8x32 x y) => (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt32to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt32to64 y)))) |
| (Rsh8x16 x y) => (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt16to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt16to64 y)))) |
| (Rsh8x8 x y) => (SRA (SignExt8to64 x) (CSEL [OpARM64LessThanU] <y.Type> (ZeroExt8to64 y) (Const64 <y.Type> [63]) (CMPconst [64] (ZeroExt8to64 y)))) |
| |
| // constants |
| (Const(64|32|16|8) [val]) => (MOVDconst [int64(val)]) |
| (Const(32F|64F) [val]) => (FMOV(S|D)const [float64(val)]) |
| (ConstNil) => (MOVDconst [0]) |
| (ConstBool [t]) => (MOVDconst [b2i(t)]) |
| |
| (Slicemask <t> x) => (SRAconst (NEG <t> x) [63]) |
| |
| // truncations |
| // Because we ignore high parts of registers, truncates are just copies. |
| (Trunc16to8 ...) => (Copy ...) |
| (Trunc32to8 ...) => (Copy ...) |
| (Trunc32to16 ...) => (Copy ...) |
| (Trunc64to8 ...) => (Copy ...) |
| (Trunc64to16 ...) => (Copy ...) |
| (Trunc64to32 ...) => (Copy ...) |
| |
| // Zero-/Sign-extensions |
| (ZeroExt8to16 ...) => (MOVBUreg ...) |
| (ZeroExt8to32 ...) => (MOVBUreg ...) |
| (ZeroExt16to32 ...) => (MOVHUreg ...) |
| (ZeroExt8to64 ...) => (MOVBUreg ...) |
| (ZeroExt16to64 ...) => (MOVHUreg ...) |
| (ZeroExt32to64 ...) => (MOVWUreg ...) |
| |
| (SignExt8to16 ...) => (MOVBreg ...) |
| (SignExt8to32 ...) => (MOVBreg ...) |
| (SignExt16to32 ...) => (MOVHreg ...) |
| (SignExt8to64 ...) => (MOVBreg ...) |
| (SignExt16to64 ...) => (MOVHreg ...) |
| (SignExt32to64 ...) => (MOVWreg ...) |
| |
| // float <=> int conversion |
| (Cvt32to32F ...) => (SCVTFWS ...) |
| (Cvt32to64F ...) => (SCVTFWD ...) |
| (Cvt64to32F ...) => (SCVTFS ...) |
| (Cvt64to64F ...) => (SCVTFD ...) |
| (Cvt32Uto32F ...) => (UCVTFWS ...) |
| (Cvt32Uto64F ...) => (UCVTFWD ...) |
| (Cvt64Uto32F ...) => (UCVTFS ...) |
| (Cvt64Uto64F ...) => (UCVTFD ...) |
| (Cvt32Fto32 ...) => (FCVTZSSW ...) |
| (Cvt64Fto32 ...) => (FCVTZSDW ...) |
| (Cvt32Fto64 ...) => (FCVTZSS ...) |
| (Cvt64Fto64 ...) => (FCVTZSD ...) |
| (Cvt32Fto32U ...) => (FCVTZUSW ...) |
| (Cvt64Fto32U ...) => (FCVTZUDW ...) |
| (Cvt32Fto64U ...) => (FCVTZUS ...) |
| (Cvt64Fto64U ...) => (FCVTZUD ...) |
| (Cvt32Fto64F ...) => (FCVTSD ...) |
| (Cvt64Fto32F ...) => (FCVTDS ...) |
| |
| (CvtBoolToUint8 ...) => (Copy ...) |
| |
| (Round32F ...) => (LoweredRound32F ...) |
| (Round64F ...) => (LoweredRound64F ...) |
| |
| // comparisons |
| (Eq8 x y) => (Equal (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) |
| (Eq16 x y) => (Equal (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) |
| (Eq32 x y) => (Equal (CMPW x y)) |
| (Eq64 x y) => (Equal (CMP x y)) |
| (EqPtr x y) => (Equal (CMP x y)) |
| (Eq32F x y) => (Equal (FCMPS x y)) |
| (Eq64F x y) => (Equal (FCMPD x y)) |
| |
| (Neq8 x y) => (NotEqual (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) |
| (Neq16 x y) => (NotEqual (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) |
| (Neq32 x y) => (NotEqual (CMPW x y)) |
| (Neq64 x y) => (NotEqual (CMP x y)) |
| (NeqPtr x y) => (NotEqual (CMP x y)) |
| (Neq32F x y) => (NotEqual (FCMPS x y)) |
| (Neq64F x y) => (NotEqual (FCMPD x y)) |
| |
| (Less8 x y) => (LessThan (CMPW (SignExt8to32 x) (SignExt8to32 y))) |
| (Less16 x y) => (LessThan (CMPW (SignExt16to32 x) (SignExt16to32 y))) |
| (Less32 x y) => (LessThan (CMPW x y)) |
| (Less64 x y) => (LessThan (CMP x y)) |
| |
| // Set condition flags for floating-point comparisons "x < y" |
| // and "x <= y". Because if either or both of the operands are |
| // NaNs, all three of (x < y), (x == y) and (x > y) are false, |
| // and ARM Manual says FCMP instruction sets PSTATE.<N,Z,C,V> |
| // of this case to (0, 0, 1, 1). |
| (Less32F x y) => (LessThanF (FCMPS x y)) |
| (Less64F x y) => (LessThanF (FCMPD x y)) |
| |
| // For an unsigned integer x, the following rules are useful when combining branch |
| // 0 < x => x != 0 |
| // x <= 0 => x == 0 |
| // x < 1 => x == 0 |
| // 1 <= x => x != 0 |
| (Less(8U|16U|32U|64U) zero:(MOVDconst [0]) x) => (Neq(8|16|32|64) zero x) |
| (Leq(8U|16U|32U|64U) x zero:(MOVDconst [0])) => (Eq(8|16|32|64) x zero) |
| (Less(8U|16U|32U|64U) x (MOVDconst [1])) => (Eq(8|16|32|64) x (MOVDconst [0])) |
| (Leq(8U|16U|32U|64U) (MOVDconst [1]) x) => (Neq(8|16|32|64) (MOVDconst [0]) x) |
| |
| (Less8U x y) => (LessThanU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) |
| (Less16U x y) => (LessThanU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) |
| (Less32U x y) => (LessThanU (CMPW x y)) |
| (Less64U x y) => (LessThanU (CMP x y)) |
| |
| (Leq8 x y) => (LessEqual (CMPW (SignExt8to32 x) (SignExt8to32 y))) |
| (Leq16 x y) => (LessEqual (CMPW (SignExt16to32 x) (SignExt16to32 y))) |
| (Leq32 x y) => (LessEqual (CMPW x y)) |
| (Leq64 x y) => (LessEqual (CMP x y)) |
| |
| // Refer to the comments for op Less64F above. |
| (Leq32F x y) => (LessEqualF (FCMPS x y)) |
| (Leq64F x y) => (LessEqualF (FCMPD x y)) |
| |
| (Leq8U x y) => (LessEqualU (CMPW (ZeroExt8to32 x) (ZeroExt8to32 y))) |
| (Leq16U x y) => (LessEqualU (CMPW (ZeroExt16to32 x) (ZeroExt16to32 y))) |
| (Leq32U x y) => (LessEqualU (CMPW x y)) |
| (Leq64U x y) => (LessEqualU (CMP x y)) |
| |
| // Optimize comparison between a floating-point value and 0.0 with "FCMP $(0.0), Fn" |
| (FCMPS x (FMOVSconst [0])) => (FCMPS0 x) |
| (FCMPS (FMOVSconst [0]) x) => (InvertFlags (FCMPS0 x)) |
| (FCMPD x (FMOVDconst [0])) => (FCMPD0 x) |
| (FCMPD (FMOVDconst [0]) x) => (InvertFlags (FCMPD0 x)) |
| |
| // CSEL needs a flag-generating argument. Synthesize a CMPW if necessary. |
| (CondSelect x y boolval) && flagArg(boolval) != nil => (CSEL [boolval.Op] x y flagArg(boolval)) |
| (CondSelect x y boolval) && flagArg(boolval) == nil => (CSEL [OpARM64NotEqual] x y (CMPWconst [0] boolval)) |
| |
| (OffPtr [off] ptr:(SP)) && is32Bit(off) => (MOVDaddr [int32(off)] ptr) |
| (OffPtr [off] ptr) => (ADDconst [off] ptr) |
| |
| (Addr {sym} base) => (MOVDaddr {sym} base) |
| (LocalAddr {sym} base _) => (MOVDaddr {sym} base) |
| |
| // loads |
| (Load <t> ptr mem) && t.IsBoolean() => (MOVBUload ptr mem) |
| (Load <t> ptr mem) && (is8BitInt(t) && isSigned(t)) => (MOVBload ptr mem) |
| (Load <t> ptr mem) && (is8BitInt(t) && !isSigned(t)) => (MOVBUload ptr mem) |
| (Load <t> ptr mem) && (is16BitInt(t) && isSigned(t)) => (MOVHload ptr mem) |
| (Load <t> ptr mem) && (is16BitInt(t) && !isSigned(t)) => (MOVHUload ptr mem) |
| (Load <t> ptr mem) && (is32BitInt(t) && isSigned(t)) => (MOVWload ptr mem) |
| (Load <t> ptr mem) && (is32BitInt(t) && !isSigned(t)) => (MOVWUload ptr mem) |
| (Load <t> ptr mem) && (is64BitInt(t) || isPtr(t)) => (MOVDload ptr mem) |
| (Load <t> ptr mem) && is32BitFloat(t) => (FMOVSload ptr mem) |
| (Load <t> ptr mem) && is64BitFloat(t) => (FMOVDload ptr mem) |
| |
| // stores |
| (Store {t} ptr val mem) && t.Size() == 1 => (MOVBstore ptr val mem) |
| (Store {t} ptr val mem) && t.Size() == 2 => (MOVHstore ptr val mem) |
| (Store {t} ptr val mem) && t.Size() == 4 && !is32BitFloat(val.Type) => (MOVWstore ptr val mem) |
| (Store {t} ptr val mem) && t.Size() == 8 && !is64BitFloat(val.Type) => (MOVDstore ptr val mem) |
| (Store {t} ptr val mem) && t.Size() == 4 && is32BitFloat(val.Type) => (FMOVSstore ptr val mem) |
| (Store {t} ptr val mem) && t.Size() == 8 && is64BitFloat(val.Type) => (FMOVDstore ptr val mem) |
| |
| // zeroing |
| (Zero [0] _ mem) => mem |
| (Zero [1] ptr mem) => (MOVBstore ptr (MOVDconst [0]) mem) |
| (Zero [2] ptr mem) => (MOVHstore ptr (MOVDconst [0]) mem) |
| (Zero [4] ptr mem) => (MOVWstore ptr (MOVDconst [0]) mem) |
| (Zero [8] ptr mem) => (MOVDstore ptr (MOVDconst [0]) mem) |
| |
| (Zero [3] ptr mem) => |
| (MOVBstore [2] ptr (MOVDconst [0]) |
| (MOVHstore ptr (MOVDconst [0]) mem)) |
| (Zero [5] ptr mem) => |
| (MOVBstore [4] ptr (MOVDconst [0]) |
| (MOVWstore ptr (MOVDconst [0]) mem)) |
| (Zero [6] ptr mem) => |
| (MOVHstore [4] ptr (MOVDconst [0]) |
| (MOVWstore ptr (MOVDconst [0]) mem)) |
| (Zero [7] ptr mem) => |
| (MOVBstore [6] ptr (MOVDconst [0]) |
| (MOVHstore [4] ptr (MOVDconst [0]) |
| (MOVWstore ptr (MOVDconst [0]) mem))) |
| (Zero [9] ptr mem) => |
| (MOVBstore [8] ptr (MOVDconst [0]) |
| (MOVDstore ptr (MOVDconst [0]) mem)) |
| (Zero [10] ptr mem) => |
| (MOVHstore [8] ptr (MOVDconst [0]) |
| (MOVDstore ptr (MOVDconst [0]) mem)) |
| (Zero [11] ptr mem) => |
| (MOVBstore [10] ptr (MOVDconst [0]) |
| (MOVHstore [8] ptr (MOVDconst [0]) |
| (MOVDstore ptr (MOVDconst [0]) mem))) |
| (Zero [12] ptr mem) => |
| (MOVWstore [8] ptr (MOVDconst [0]) |
| (MOVDstore ptr (MOVDconst [0]) mem)) |
| (Zero [13] ptr mem) => |
| (MOVBstore [12] ptr (MOVDconst [0]) |
| (MOVWstore [8] ptr (MOVDconst [0]) |
| (MOVDstore ptr (MOVDconst [0]) mem))) |
| (Zero [14] ptr mem) => |
| (MOVHstore [12] ptr (MOVDconst [0]) |
| (MOVWstore [8] ptr (MOVDconst [0]) |
| (MOVDstore ptr (MOVDconst [0]) mem))) |
| (Zero [15] ptr mem) => |
| (MOVBstore [14] ptr (MOVDconst [0]) |
| (MOVHstore [12] ptr (MOVDconst [0]) |
| (MOVWstore [8] ptr (MOVDconst [0]) |
| (MOVDstore ptr (MOVDconst [0]) mem)))) |
| (Zero [16] ptr mem) => |
| (STP [0] ptr (MOVDconst [0]) (MOVDconst [0]) mem) |
| |
| (Zero [32] ptr mem) => |
| (STP [16] ptr (MOVDconst [0]) (MOVDconst [0]) |
| (STP [0] ptr (MOVDconst [0]) (MOVDconst [0]) mem)) |
| |
| (Zero [48] ptr mem) => |
| (STP [32] ptr (MOVDconst [0]) (MOVDconst [0]) |
| (STP [16] ptr (MOVDconst [0]) (MOVDconst [0]) |
| (STP [0] ptr (MOVDconst [0]) (MOVDconst [0]) mem))) |
| |
| (Zero [64] ptr mem) => |
| (STP [48] ptr (MOVDconst [0]) (MOVDconst [0]) |
| (STP [32] ptr (MOVDconst [0]) (MOVDconst [0]) |
| (STP [16] ptr (MOVDconst [0]) (MOVDconst [0]) |
| (STP [0] ptr (MOVDconst [0]) (MOVDconst [0]) mem)))) |
| |
| // strip off fractional word zeroing |
| (Zero [s] ptr mem) && s%16 != 0 && s%16 <= 8 && s > 16 => |
| (Zero [8] |
| (OffPtr <ptr.Type> ptr [s-8]) |
| (Zero [s-s%16] ptr mem)) |
| (Zero [s] ptr mem) && s%16 != 0 && s%16 > 8 && s > 16 => |
| (Zero [16] |
| (OffPtr <ptr.Type> ptr [s-16]) |
| (Zero [s-s%16] ptr mem)) |
| |
| // medium zeroing uses a duff device |
| // 4, 16, and 64 are magic constants, see runtime/mkduff.go |
| (Zero [s] ptr mem) |
| && s%16 == 0 && s > 64 && s <= 16*64 |
| && !config.noDuffDevice => |
| (DUFFZERO [4 * (64 - s/16)] ptr mem) |
| |
| // large zeroing uses a loop |
| (Zero [s] ptr mem) |
| && s%16 == 0 && (s > 16*64 || config.noDuffDevice) => |
| (LoweredZero |
| ptr |
| (ADDconst <ptr.Type> [s-16] ptr) |
| mem) |
| |
| // moves |
| (Move [0] _ _ mem) => mem |
| (Move [1] dst src mem) => (MOVBstore dst (MOVBUload src mem) mem) |
| (Move [2] dst src mem) => (MOVHstore dst (MOVHUload src mem) mem) |
| (Move [4] dst src mem) => (MOVWstore dst (MOVWUload src mem) mem) |
| (Move [8] dst src mem) => (MOVDstore dst (MOVDload src mem) mem) |
| |
| (Move [3] dst src mem) => |
| (MOVBstore [2] dst (MOVBUload [2] src mem) |
| (MOVHstore dst (MOVHUload src mem) mem)) |
| (Move [5] dst src mem) => |
| (MOVBstore [4] dst (MOVBUload [4] src mem) |
| (MOVWstore dst (MOVWUload src mem) mem)) |
| (Move [6] dst src mem) => |
| (MOVHstore [4] dst (MOVHUload [4] src mem) |
| (MOVWstore dst (MOVWUload src mem) mem)) |
| (Move [7] dst src mem) => |
| (MOVBstore [6] dst (MOVBUload [6] src mem) |
| (MOVHstore [4] dst (MOVHUload [4] src mem) |
| (MOVWstore dst (MOVWUload src mem) mem))) |
| (Move [12] dst src mem) => |
| (MOVWstore [8] dst (MOVWUload [8] src mem) |
| (MOVDstore dst (MOVDload src mem) mem)) |
| (Move [16] dst src mem) => |
| (MOVDstore [8] dst (MOVDload [8] src mem) |
| (MOVDstore dst (MOVDload src mem) mem)) |
| (Move [24] dst src mem) => |
| (MOVDstore [16] dst (MOVDload [16] src mem) |
| (MOVDstore [8] dst (MOVDload [8] src mem) |
| (MOVDstore dst (MOVDload src mem) mem))) |
| |
| // strip off fractional word move |
| (Move [s] dst src mem) && s%8 != 0 && s > 8 => |
| (Move [s%8] |
| (OffPtr <dst.Type> dst [s-s%8]) |
| (OffPtr <src.Type> src [s-s%8]) |
| (Move [s-s%8] dst src mem)) |
| |
| // medium move uses a duff device |
| (Move [s] dst src mem) |
| && s > 32 && s <= 16*64 && s%16 == 8 |
| && !config.noDuffDevice && logLargeCopy(v, s) => |
| (MOVDstore [int32(s-8)] dst (MOVDload [int32(s-8)] src mem) |
| (DUFFCOPY <types.TypeMem> [8*(64-(s-8)/16)] dst src mem)) |
| (Move [s] dst src mem) |
| && s > 32 && s <= 16*64 && s%16 == 0 |
| && !config.noDuffDevice && logLargeCopy(v, s) => |
| (DUFFCOPY [8 * (64 - s/16)] dst src mem) |
| // 8 is the number of bytes to encode: |
| // |
| // LDP.P 16(R16), (R26, R27) |
| // STP.P (R26, R27), 16(R17) |
| // |
| // 64 is number of these blocks. See runtime/duff_arm64.s:duffcopy |
| |
| // large move uses a loop |
| (Move [s] dst src mem) |
| && s > 24 && s%8 == 0 && logLargeCopy(v, s) => |
| (LoweredMove |
| dst |
| src |
| (ADDconst <src.Type> src [s-8]) |
| mem) |
| |
| // calls |
| (StaticCall ...) => (CALLstatic ...) |
| (ClosureCall ...) => (CALLclosure ...) |
| (InterCall ...) => (CALLinter ...) |
| |
| // checks |
| (NilCheck ...) => (LoweredNilCheck ...) |
| (IsNonNil ptr) => (NotEqual (CMPconst [0] ptr)) |
| (IsInBounds idx len) => (LessThanU (CMP idx len)) |
| (IsSliceInBounds idx len) => (LessEqualU (CMP idx len)) |
| |
| // pseudo-ops |
| (GetClosurePtr ...) => (LoweredGetClosurePtr ...) |
| (GetCallerSP ...) => (LoweredGetCallerSP ...) |
| (GetCallerPC ...) => (LoweredGetCallerPC ...) |
| |
| // Absorb pseudo-ops into blocks. |
| (If (Equal cc) yes no) => (EQ cc yes no) |
| (If (NotEqual cc) yes no) => (NE cc yes no) |
| (If (LessThan cc) yes no) => (LT cc yes no) |
| (If (LessThanU cc) yes no) => (ULT cc yes no) |
| (If (LessEqual cc) yes no) => (LE cc yes no) |
| (If (LessEqualU cc) yes no) => (ULE cc yes no) |
| (If (GreaterThan cc) yes no) => (GT cc yes no) |
| (If (GreaterThanU cc) yes no) => (UGT cc yes no) |
| (If (GreaterEqual cc) yes no) => (GE cc yes no) |
| (If (GreaterEqualU cc) yes no) => (UGE cc yes no) |
| (If (LessThanF cc) yes no) => (FLT cc yes no) |
| (If (LessEqualF cc) yes no) => (FLE cc yes no) |
| (If (GreaterThanF cc) yes no) => (FGT cc yes no) |
| (If (GreaterEqualF cc) yes no) => (FGE cc yes no) |
| |
| (If cond yes no) => (NZ cond yes no) |
| |
| // atomic intrinsics |
| // Note: these ops do not accept offset. |
| (AtomicLoad8 ...) => (LDARB ...) |
| (AtomicLoad32 ...) => (LDARW ...) |
| (AtomicLoad64 ...) => (LDAR ...) |
| (AtomicLoadPtr ...) => (LDAR ...) |
| |
| (AtomicStore8 ...) => (STLRB ...) |
| (AtomicStore32 ...) => (STLRW ...) |
| (AtomicStore64 ...) => (STLR ...) |
| (AtomicStorePtrNoWB ...) => (STLR ...) |
| |
| (AtomicExchange(32|64) ...) => (LoweredAtomicExchange(32|64) ...) |
| (AtomicAdd(32|64) ...) => (LoweredAtomicAdd(32|64) ...) |
| (AtomicCompareAndSwap(32|64) ...) => (LoweredAtomicCas(32|64) ...) |
| |
| (AtomicAdd(32|64)Variant ...) => (LoweredAtomicAdd(32|64)Variant ...) |
| (AtomicExchange(32|64)Variant ...) => (LoweredAtomicExchange(32|64)Variant ...) |
| (AtomicCompareAndSwap(32|64)Variant ...) => (LoweredAtomicCas(32|64)Variant ...) |
| |
| // Currently the updated value is not used, but we need a register to temporarily hold it. |
| (AtomicAnd8 ptr val mem) => (Select1 (LoweredAtomicAnd8 ptr val mem)) |
| (AtomicAnd32 ptr val mem) => (Select1 (LoweredAtomicAnd32 ptr val mem)) |
| (AtomicOr8 ptr val mem) => (Select1 (LoweredAtomicOr8 ptr val mem)) |
| (AtomicOr32 ptr val mem) => (Select1 (LoweredAtomicOr32 ptr val mem)) |
| |
| (AtomicAnd8Variant ptr val mem) => (Select1 (LoweredAtomicAnd8Variant ptr val mem)) |
| (AtomicAnd32Variant ptr val mem) => (Select1 (LoweredAtomicAnd32Variant ptr val mem)) |
| (AtomicOr8Variant ptr val mem) => (Select1 (LoweredAtomicOr8Variant ptr val mem)) |
| (AtomicOr32Variant ptr val mem) => (Select1 (LoweredAtomicOr32Variant ptr val mem)) |
| |
| // Write barrier. |
| (WB ...) => (LoweredWB ...) |
| |
| (PanicBounds [kind] x y mem) && boundsABI(kind) == 0 => (LoweredPanicBoundsA [kind] x y mem) |
| (PanicBounds [kind] x y mem) && boundsABI(kind) == 1 => (LoweredPanicBoundsB [kind] x y mem) |
| (PanicBounds [kind] x y mem) && boundsABI(kind) == 2 => (LoweredPanicBoundsC [kind] x y mem) |
| |
| // Optimizations |
| |
| // Absorb boolean tests into block |
| (NZ (Equal cc) yes no) => (EQ cc yes no) |
| (NZ (NotEqual cc) yes no) => (NE cc yes no) |
| (NZ (LessThan cc) yes no) => (LT cc yes no) |
| (NZ (LessThanU cc) yes no) => (ULT cc yes no) |
| (NZ (LessEqual cc) yes no) => (LE cc yes no) |
| (NZ (LessEqualU cc) yes no) => (ULE cc yes no) |
| (NZ (GreaterThan cc) yes no) => (GT cc yes no) |
| (NZ (GreaterThanU cc) yes no) => (UGT cc yes no) |
| (NZ (GreaterEqual cc) yes no) => (GE cc yes no) |
| (NZ (GreaterEqualU cc) yes no) => (UGE cc yes no) |
| (NZ (LessThanF cc) yes no) => (FLT cc yes no) |
| (NZ (LessEqualF cc) yes no) => (FLE cc yes no) |
| (NZ (GreaterThanF cc) yes no) => (FGT cc yes no) |
| (NZ (GreaterEqualF cc) yes no) => (FGE cc yes no) |
| |
| (EQ (CMPWconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (EQ (TSTWconst [int32(c)] y) yes no) |
| (NE (CMPWconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (NE (TSTWconst [int32(c)] y) yes no) |
| (LT (CMPWconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (LT (TSTWconst [int32(c)] y) yes no) |
| (LE (CMPWconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (LE (TSTWconst [int32(c)] y) yes no) |
| (GT (CMPWconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (GT (TSTWconst [int32(c)] y) yes no) |
| (GE (CMPWconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (GE (TSTWconst [int32(c)] y) yes no) |
| |
| (EQ (CMPconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (EQ (TST x y) yes no) |
| (NE (CMPconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (NE (TST x y) yes no) |
| (LT (CMPconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (LT (TST x y) yes no) |
| (LE (CMPconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (LE (TST x y) yes no) |
| (GT (CMPconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (GT (TST x y) yes no) |
| (GE (CMPconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (GE (TST x y) yes no) |
| |
| (EQ (CMPWconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (EQ (TSTW x y) yes no) |
| (NE (CMPWconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (NE (TSTW x y) yes no) |
| (LT (CMPWconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (LT (TSTW x y) yes no) |
| (LE (CMPWconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (LE (TSTW x y) yes no) |
| (GT (CMPWconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (GT (TSTW x y) yes no) |
| (GE (CMPWconst [0] z:(AND x y)) yes no) && z.Uses == 1 => (GE (TSTW x y) yes no) |
| |
| (EQ (CMPconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (EQ (TSTconst [c] y) yes no) |
| (NE (CMPconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (NE (TSTconst [c] y) yes no) |
| (LT (CMPconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (LT (TSTconst [c] y) yes no) |
| (LE (CMPconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (LE (TSTconst [c] y) yes no) |
| (GT (CMPconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (GT (TSTconst [c] y) yes no) |
| (GE (CMPconst [0] x:(ANDconst [c] y)) yes no) && x.Uses == 1 => (GE (TSTconst [c] y) yes no) |
| |
| (EQ (CMPconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (EQ (CMNconst [c] y) yes no) |
| (NE (CMPconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (NE (CMNconst [c] y) yes no) |
| (LT (CMPconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (LTnoov (CMNconst [c] y) yes no) |
| (LE (CMPconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (LEnoov (CMNconst [c] y) yes no) |
| (GT (CMPconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (GTnoov (CMNconst [c] y) yes no) |
| (GE (CMPconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (GEnoov (CMNconst [c] y) yes no) |
| |
| (EQ (CMPWconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (EQ (CMNWconst [int32(c)] y) yes no) |
| (NE (CMPWconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (NE (CMNWconst [int32(c)] y) yes no) |
| (LT (CMPWconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (LTnoov (CMNWconst [int32(c)] y) yes no) |
| (LE (CMPWconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (LEnoov (CMNWconst [int32(c)] y) yes no) |
| (GT (CMPWconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (GTnoov (CMNWconst [int32(c)] y) yes no) |
| (GE (CMPWconst [0] x:(ADDconst [c] y)) yes no) && x.Uses == 1 => (GEnoov (CMNWconst [int32(c)] y) yes no) |
| |
| (EQ (CMPconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (EQ (CMN x y) yes no) |
| (NE (CMPconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (NE (CMN x y) yes no) |
| (LT (CMPconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (LTnoov (CMN x y) yes no) |
| (LE (CMPconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (LEnoov (CMN x y) yes no) |
| (GT (CMPconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (GTnoov (CMN x y) yes no) |
| (GE (CMPconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (GEnoov (CMN x y) yes no) |
| |
| (EQ (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (EQ (CMNW x y) yes no) |
| (NE (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (NE (CMNW x y) yes no) |
| (LT (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (LTnoov (CMNW x y) yes no) |
| (LE (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (LEnoov (CMNW x y) yes no) |
| (GT (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (GTnoov (CMNW x y) yes no) |
| (GE (CMPWconst [0] z:(ADD x y)) yes no) && z.Uses == 1 => (GEnoov (CMNW x y) yes no) |
| |
| (EQ (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (EQ (CMN x y) yes no) |
| (NE (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (NE (CMN x y) yes no) |
| (LT (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (LT (CMN x y) yes no) |
| (LE (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (LE (CMN x y) yes no) |
| (GT (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (GT (CMN x y) yes no) |
| (GE (CMP x z:(NEG y)) yes no) && z.Uses == 1 => (GE (CMN x y) yes no) |
| |
| (EQ (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (EQ (CMNW x y) yes no) |
| (NE (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (NE (CMNW x y) yes no) |
| (LT (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (LT (CMNW x y) yes no) |
| (LE (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (LE (CMNW x y) yes no) |
| (GT (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (GT (CMNW x y) yes no) |
| (GE (CMPW x z:(NEG y)) yes no) && z.Uses == 1 => (GE (CMNW x y) yes no) |
| |
| (EQ (CMPconst [0] x) yes no) => (Z x yes no) |
| (NE (CMPconst [0] x) yes no) => (NZ x yes no) |
| (EQ (CMPWconst [0] x) yes no) => (ZW x yes no) |
| (NE (CMPWconst [0] x) yes no) => (NZW x yes no) |
| |
| (EQ (CMPconst [0] z:(MADD a x y)) yes no) && z.Uses==1 => (EQ (CMN a (MUL <x.Type> x y)) yes no) |
| (NE (CMPconst [0] z:(MADD a x y)) yes no) && z.Uses==1 => (NE (CMN a (MUL <x.Type> x y)) yes no) |
| (LT (CMPconst [0] z:(MADD a x y)) yes no) && z.Uses==1 => (LTnoov (CMN a (MUL <x.Type> x y)) yes no) |
| (LE (CMPconst [0] z:(MADD a x y)) yes no) && z.Uses==1 => (LEnoov (CMN a (MUL <x.Type> x y)) yes no) |
| (GT (CMPconst [0] z:(MADD a x y)) yes no) && z.Uses==1 => (GTnoov (CMN a (MUL <x.Type> x y)) yes no) |
| (GE (CMPconst [0] z:(MADD a x y)) yes no) && z.Uses==1 => (GEnoov (CMN a (MUL <x.Type> x y)) yes no) |
| |
| (EQ (CMPconst [0] z:(MSUB a x y)) yes no) && z.Uses==1 => (EQ (CMP a (MUL <x.Type> x y)) yes no) |
| (NE (CMPconst [0] z:(MSUB a x y)) yes no) && z.Uses==1 => (NE (CMP a (MUL <x.Type> x y)) yes no) |
| (LE (CMPconst [0] z:(MSUB a x y)) yes no) && z.Uses==1 => (LEnoov (CMP a (MUL <x.Type> x y)) yes no) |
| (LT (CMPconst [0] z:(MSUB a x y)) yes no) && z.Uses==1 => (LTnoov (CMP a (MUL <x.Type> x y)) yes no) |
| (GE (CMPconst [0] z:(MSUB a x y)) yes no) && z.Uses==1 => (GEnoov (CMP a (MUL <x.Type> x y)) yes no) |
| (GT (CMPconst [0] z:(MSUB a x y)) yes no) && z.Uses==1 => (GTnoov (CMP a (MUL <x.Type> x y)) yes no) |
| |
| (EQ (CMPWconst [0] z:(MADDW a x y)) yes no) && z.Uses==1 => (EQ (CMNW a (MULW <x.Type> x y)) yes no) |
| (NE (CMPWconst [0] z:(MADDW a x y)) yes no) && z.Uses==1 => (NE (CMNW a (MULW <x.Type> x y)) yes no) |
| (LE (CMPWconst [0] z:(MADDW a x y)) yes no) && z.Uses==1 => (LEnoov (CMNW a (MULW <x.Type> x y)) yes no) |
| (LT (CMPWconst [0] z:(MADDW a x y)) yes no) && z.Uses==1 => (LTnoov (CMNW a (MULW <x.Type> x y)) yes no) |
| (GE (CMPWconst [0] z:(MADDW a x y)) yes no) && z.Uses==1 => (GEnoov (CMNW a (MULW <x.Type> x y)) yes no) |
| (GT (CMPWconst [0] z:(MADDW a x y)) yes no) && z.Uses==1 => (GTnoov (CMNW a (MULW <x.Type> x y)) yes no) |
| |
| (EQ (CMPWconst [0] z:(MSUBW a x y)) yes no) && z.Uses==1 => (EQ (CMPW a (MULW <x.Type> x y)) yes no) |
| (NE (CMPWconst [0] z:(MSUBW a x y)) yes no) && z.Uses==1 => (NE (CMPW a (MULW <x.Type> x y)) yes no) |
| (LE (CMPWconst [0] z:(MSUBW a x y)) yes no) && z.Uses==1 => (LEnoov (CMPW a (MULW <x.Type> x y)) yes no) |
| (LT (CMPWconst [0] z:(MSUBW a x y)) yes no) && z.Uses==1 => (LTnoov (CMPW a (MULW <x.Type> x y)) yes no) |
| (GE (CMPWconst [0] z:(MSUBW a x y)) yes no) && z.Uses==1 => (GEnoov (CMPW a (MULW <x.Type> x y)) yes no) |
| (GT (CMPWconst [0] z:(MSUBW a x y)) yes no) && z.Uses==1 => (GTnoov (CMPW a (MULW <x.Type> x y)) yes no) |
| |
| // Absorb bit-tests into block |
| (Z (ANDconst [c] x) yes no) && oneBit(c) => (TBZ [int64(ntz64(c))] x yes no) |
| (NZ (ANDconst [c] x) yes no) && oneBit(c) => (TBNZ [int64(ntz64(c))] x yes no) |
| (ZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBZ [int64(ntz64(int64(uint32(c))))] x yes no) |
| (NZW (ANDconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no) |
| (EQ (TSTconst [c] x) yes no) && oneBit(c) => (TBZ [int64(ntz64(c))] x yes no) |
| (NE (TSTconst [c] x) yes no) && oneBit(c) => (TBNZ [int64(ntz64(c))] x yes no) |
| (EQ (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBZ [int64(ntz64(int64(uint32(c))))] x yes no) |
| (NE (TSTWconst [c] x) yes no) && oneBit(int64(uint32(c))) => (TBNZ [int64(ntz64(int64(uint32(c))))] x yes no) |
| |
| // Test sign-bit for signed comparisons against zero |
| (GE (CMPWconst [0] x) yes no) => (TBZ [31] x yes no) |
| (GE (CMPconst [0] x) yes no) => (TBZ [63] x yes no) |
| (LT (CMPWconst [0] x) yes no) => (TBNZ [31] x yes no) |
| (LT (CMPconst [0] x) yes no) => (TBNZ [63] x yes no) |
| |
| // fold offset into address |
| (ADDconst [off1] (MOVDaddr [off2] {sym} ptr)) && is32Bit(off1+int64(off2)) => |
| (MOVDaddr [int32(off1)+off2] {sym} ptr) |
| |
| // fold address into load/store |
| (MOVBload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBload [off1+int32(off2)] {sym} ptr mem) |
| (MOVBUload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBUload [off1+int32(off2)] {sym} ptr mem) |
| (MOVHload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHload [off1+int32(off2)] {sym} ptr mem) |
| (MOVHUload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHUload [off1+int32(off2)] {sym} ptr mem) |
| (MOVWload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWload [off1+int32(off2)] {sym} ptr mem) |
| (MOVWUload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWUload [off1+int32(off2)] {sym} ptr mem) |
| (MOVDload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVDload [off1+int32(off2)] {sym} ptr mem) |
| (FMOVSload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVSload [off1+int32(off2)] {sym} ptr mem) |
| (FMOVDload [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVDload [off1+int32(off2)] {sym} ptr mem) |
| |
| // register indexed load |
| (MOVDload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVDloadidx ptr idx mem) |
| (MOVWUload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVWUloadidx ptr idx mem) |
| (MOVWload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVWloadidx ptr idx mem) |
| (MOVHUload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVHUloadidx ptr idx mem) |
| (MOVHload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVHloadidx ptr idx mem) |
| (MOVBUload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVBUloadidx ptr idx mem) |
| (MOVBload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVBloadidx ptr idx mem) |
| (FMOVSload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (FMOVSloadidx ptr idx mem) |
| (FMOVDload [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (FMOVDloadidx ptr idx mem) |
| (MOVDloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVDload [int32(c)] ptr mem) |
| (MOVDloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (MOVDload [int32(c)] ptr mem) |
| (MOVWUloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVWUload [int32(c)] ptr mem) |
| (MOVWUloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (MOVWUload [int32(c)] ptr mem) |
| (MOVWloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVWload [int32(c)] ptr mem) |
| (MOVWloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (MOVWload [int32(c)] ptr mem) |
| (MOVHUloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVHUload [int32(c)] ptr mem) |
| (MOVHUloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (MOVHUload [int32(c)] ptr mem) |
| (MOVHloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVHload [int32(c)] ptr mem) |
| (MOVHloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (MOVHload [int32(c)] ptr mem) |
| (MOVBUloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVBUload [int32(c)] ptr mem) |
| (MOVBUloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (MOVBUload [int32(c)] ptr mem) |
| (MOVBloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVBload [int32(c)] ptr mem) |
| (MOVBloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (MOVBload [int32(c)] ptr mem) |
| (FMOVSloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (FMOVSload [int32(c)] ptr mem) |
| (FMOVSloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (FMOVSload [int32(c)] ptr mem) |
| (FMOVDloadidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (FMOVDload [int32(c)] ptr mem) |
| (FMOVDloadidx (MOVDconst [c]) ptr mem) && is32Bit(c) => (FMOVDload [int32(c)] ptr mem) |
| |
| // shifted register indexed load |
| (MOVDload [off] {sym} (ADDshiftLL [3] ptr idx) mem) && off == 0 && sym == nil => (MOVDloadidx8 ptr idx mem) |
| (MOVWUload [off] {sym} (ADDshiftLL [2] ptr idx) mem) && off == 0 && sym == nil => (MOVWUloadidx4 ptr idx mem) |
| (MOVWload [off] {sym} (ADDshiftLL [2] ptr idx) mem) && off == 0 && sym == nil => (MOVWloadidx4 ptr idx mem) |
| (MOVHUload [off] {sym} (ADDshiftLL [1] ptr idx) mem) && off == 0 && sym == nil => (MOVHUloadidx2 ptr idx mem) |
| (MOVHload [off] {sym} (ADDshiftLL [1] ptr idx) mem) && off == 0 && sym == nil => (MOVHloadidx2 ptr idx mem) |
| (MOVDloadidx ptr (SLLconst [3] idx) mem) => (MOVDloadidx8 ptr idx mem) |
| (MOVWloadidx ptr (SLLconst [2] idx) mem) => (MOVWloadidx4 ptr idx mem) |
| (MOVWUloadidx ptr (SLLconst [2] idx) mem) => (MOVWUloadidx4 ptr idx mem) |
| (MOVHloadidx ptr (SLLconst [1] idx) mem) => (MOVHloadidx2 ptr idx mem) |
| (MOVHUloadidx ptr (SLLconst [1] idx) mem) => (MOVHUloadidx2 ptr idx mem) |
| (MOVHloadidx ptr (ADD idx idx) mem) => (MOVHloadidx2 ptr idx mem) |
| (MOVHUloadidx ptr (ADD idx idx) mem) => (MOVHUloadidx2 ptr idx mem) |
| (MOVDloadidx (SLLconst [3] idx) ptr mem) => (MOVDloadidx8 ptr idx mem) |
| (MOVWloadidx (SLLconst [2] idx) ptr mem) => (MOVWloadidx4 ptr idx mem) |
| (MOVWUloadidx (SLLconst [2] idx) ptr mem) => (MOVWUloadidx4 ptr idx mem) |
| (MOVHloadidx (ADD idx idx) ptr mem) => (MOVHloadidx2 ptr idx mem) |
| (MOVHUloadidx (ADD idx idx) ptr mem) => (MOVHUloadidx2 ptr idx mem) |
| (MOVDloadidx8 ptr (MOVDconst [c]) mem) && is32Bit(c<<3) => (MOVDload [int32(c)<<3] ptr mem) |
| (MOVWUloadidx4 ptr (MOVDconst [c]) mem) && is32Bit(c<<2) => (MOVWUload [int32(c)<<2] ptr mem) |
| (MOVWloadidx4 ptr (MOVDconst [c]) mem) && is32Bit(c<<2) => (MOVWload [int32(c)<<2] ptr mem) |
| (MOVHUloadidx2 ptr (MOVDconst [c]) mem) && is32Bit(c<<1) => (MOVHUload [int32(c)<<1] ptr mem) |
| (MOVHloadidx2 ptr (MOVDconst [c]) mem) && is32Bit(c<<1) => (MOVHload [int32(c)<<1] ptr mem) |
| |
| (FMOVDload [off] {sym} (ADDshiftLL [3] ptr idx) mem) && off == 0 && sym == nil => (FMOVDloadidx8 ptr idx mem) |
| (FMOVSload [off] {sym} (ADDshiftLL [2] ptr idx) mem) && off == 0 && sym == nil => (FMOVSloadidx4 ptr idx mem) |
| (FMOVDloadidx ptr (SLLconst [3] idx) mem) => (FMOVDloadidx8 ptr idx mem) |
| (FMOVSloadidx ptr (SLLconst [2] idx) mem) => (FMOVSloadidx4 ptr idx mem) |
| (FMOVDloadidx (SLLconst [3] idx) ptr mem) => (FMOVDloadidx8 ptr idx mem) |
| (FMOVSloadidx (SLLconst [2] idx) ptr mem) => (FMOVSloadidx4 ptr idx mem) |
| (FMOVDloadidx8 ptr (MOVDconst [c]) mem) && is32Bit(c<<3) => (FMOVDload ptr [int32(c)<<3] mem) |
| (FMOVSloadidx4 ptr (MOVDconst [c]) mem) && is32Bit(c<<2) => (FMOVSload ptr [int32(c)<<2] mem) |
| |
| (MOVBstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBstore [off1+int32(off2)] {sym} ptr val mem) |
| (MOVHstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHstore [off1+int32(off2)] {sym} ptr val mem) |
| (MOVWstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWstore [off1+int32(off2)] {sym} ptr val mem) |
| (MOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVDstore [off1+int32(off2)] {sym} ptr val mem) |
| (STP [off1] {sym} (ADDconst [off2] ptr) val1 val2 mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (STP [off1+int32(off2)] {sym} ptr val1 val2 mem) |
| (FMOVSstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVSstore [off1+int32(off2)] {sym} ptr val mem) |
| (FMOVDstore [off1] {sym} (ADDconst [off2] ptr) val mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVDstore [off1+int32(off2)] {sym} ptr val mem) |
| (MOVBstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBstorezero [off1+int32(off2)] {sym} ptr mem) |
| (MOVHstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHstorezero [off1+int32(off2)] {sym} ptr mem) |
| (MOVWstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWstorezero [off1+int32(off2)] {sym} ptr mem) |
| (MOVDstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVDstorezero [off1+int32(off2)] {sym} ptr mem) |
| (MOVQstorezero [off1] {sym} (ADDconst [off2] ptr) mem) && is32Bit(int64(off1)+off2) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVQstorezero [off1+int32(off2)] {sym} ptr mem) |
| |
| // register indexed store |
| (MOVDstore [off] {sym} (ADD ptr idx) val mem) && off == 0 && sym == nil => (MOVDstoreidx ptr idx val mem) |
| (MOVWstore [off] {sym} (ADD ptr idx) val mem) && off == 0 && sym == nil => (MOVWstoreidx ptr idx val mem) |
| (MOVHstore [off] {sym} (ADD ptr idx) val mem) && off == 0 && sym == nil => (MOVHstoreidx ptr idx val mem) |
| (MOVBstore [off] {sym} (ADD ptr idx) val mem) && off == 0 && sym == nil => (MOVBstoreidx ptr idx val mem) |
| (FMOVDstore [off] {sym} (ADD ptr idx) val mem) && off == 0 && sym == nil => (FMOVDstoreidx ptr idx val mem) |
| (FMOVSstore [off] {sym} (ADD ptr idx) val mem) && off == 0 && sym == nil => (FMOVSstoreidx ptr idx val mem) |
| (MOVDstoreidx ptr (MOVDconst [c]) val mem) && is32Bit(c) => (MOVDstore [int32(c)] ptr val mem) |
| (MOVDstoreidx (MOVDconst [c]) idx val mem) && is32Bit(c) => (MOVDstore [int32(c)] idx val mem) |
| (MOVWstoreidx ptr (MOVDconst [c]) val mem) && is32Bit(c) => (MOVWstore [int32(c)] ptr val mem) |
| (MOVWstoreidx (MOVDconst [c]) idx val mem) && is32Bit(c) => (MOVWstore [int32(c)] idx val mem) |
| (MOVHstoreidx ptr (MOVDconst [c]) val mem) && is32Bit(c) => (MOVHstore [int32(c)] ptr val mem) |
| (MOVHstoreidx (MOVDconst [c]) idx val mem) && is32Bit(c) => (MOVHstore [int32(c)] idx val mem) |
| (MOVBstoreidx ptr (MOVDconst [c]) val mem) && is32Bit(c) => (MOVBstore [int32(c)] ptr val mem) |
| (MOVBstoreidx (MOVDconst [c]) idx val mem) && is32Bit(c) => (MOVBstore [int32(c)] idx val mem) |
| (FMOVDstoreidx ptr (MOVDconst [c]) val mem) && is32Bit(c) => (FMOVDstore [int32(c)] ptr val mem) |
| (FMOVDstoreidx (MOVDconst [c]) idx val mem) && is32Bit(c) => (FMOVDstore [int32(c)] idx val mem) |
| (FMOVSstoreidx ptr (MOVDconst [c]) val mem) && is32Bit(c) => (FMOVSstore [int32(c)] ptr val mem) |
| (FMOVSstoreidx (MOVDconst [c]) idx val mem) && is32Bit(c) => (FMOVSstore [int32(c)] idx val mem) |
| |
| // shifted register indexed store |
| (MOVDstore [off] {sym} (ADDshiftLL [3] ptr idx) val mem) && off == 0 && sym == nil => (MOVDstoreidx8 ptr idx val mem) |
| (MOVWstore [off] {sym} (ADDshiftLL [2] ptr idx) val mem) && off == 0 && sym == nil => (MOVWstoreidx4 ptr idx val mem) |
| (MOVHstore [off] {sym} (ADDshiftLL [1] ptr idx) val mem) && off == 0 && sym == nil => (MOVHstoreidx2 ptr idx val mem) |
| (MOVDstoreidx ptr (SLLconst [3] idx) val mem) => (MOVDstoreidx8 ptr idx val mem) |
| (MOVWstoreidx ptr (SLLconst [2] idx) val mem) => (MOVWstoreidx4 ptr idx val mem) |
| (MOVHstoreidx ptr (SLLconst [1] idx) val mem) => (MOVHstoreidx2 ptr idx val mem) |
| (MOVHstoreidx ptr (ADD idx idx) val mem) => (MOVHstoreidx2 ptr idx val mem) |
| (MOVDstoreidx (SLLconst [3] idx) ptr val mem) => (MOVDstoreidx8 ptr idx val mem) |
| (MOVWstoreidx (SLLconst [2] idx) ptr val mem) => (MOVWstoreidx4 ptr idx val mem) |
| (MOVHstoreidx (SLLconst [1] idx) ptr val mem) => (MOVHstoreidx2 ptr idx val mem) |
| (MOVHstoreidx (ADD idx idx) ptr val mem) => (MOVHstoreidx2 ptr idx val mem) |
| (MOVDstoreidx8 ptr (MOVDconst [c]) val mem) && is32Bit(c<<3) => (MOVDstore [int32(c)<<3] ptr val mem) |
| (MOVWstoreidx4 ptr (MOVDconst [c]) val mem) && is32Bit(c<<2) => (MOVWstore [int32(c)<<2] ptr val mem) |
| (MOVHstoreidx2 ptr (MOVDconst [c]) val mem) && is32Bit(c<<1) => (MOVHstore [int32(c)<<1] ptr val mem) |
| |
| (FMOVDstore [off] {sym} (ADDshiftLL [3] ptr idx) val mem) && off == 0 && sym == nil => (FMOVDstoreidx8 ptr idx val mem) |
| (FMOVSstore [off] {sym} (ADDshiftLL [2] ptr idx) val mem) && off == 0 && sym == nil => (FMOVSstoreidx4 ptr idx val mem) |
| (FMOVDstoreidx ptr (SLLconst [3] idx) val mem) => (FMOVDstoreidx8 ptr idx val mem) |
| (FMOVSstoreidx ptr (SLLconst [2] idx) val mem) => (FMOVSstoreidx4 ptr idx val mem) |
| (FMOVDstoreidx (SLLconst [3] idx) ptr val mem) => (FMOVDstoreidx8 ptr idx val mem) |
| (FMOVSstoreidx (SLLconst [2] idx) ptr val mem) => (FMOVSstoreidx4 ptr idx val mem) |
| (FMOVDstoreidx8 ptr (MOVDconst [c]) val mem) && is32Bit(c<<3) => (FMOVDstore [int32(c)<<3] ptr val mem) |
| (FMOVSstoreidx4 ptr (MOVDconst [c]) val mem) && is32Bit(c<<2) => (FMOVSstore [int32(c)<<2] ptr val mem) |
| |
| (MOVBload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVBUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVHload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVHUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVWload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVWUload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWUload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (FMOVSload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVSload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (FMOVDload [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVDload [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| |
| (MOVBstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) |
| (MOVHstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) |
| (MOVWstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) |
| (MOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) |
| (STP [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val1 val2 mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (STP [off1+off2] {mergeSym(sym1,sym2)} ptr val1 val2 mem) |
| (FMOVSstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVSstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) |
| (FMOVDstore [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) val mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (FMOVDstore [off1+off2] {mergeSym(sym1,sym2)} ptr val mem) |
| (MOVBstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVBstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVHstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVHstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVWstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVWstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVDstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVDstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| (MOVQstorezero [off1] {sym1} (MOVDaddr [off2] {sym2} ptr) mem) |
| && canMergeSym(sym1,sym2) && is32Bit(int64(off1)+int64(off2)) |
| && (ptr.Op != OpSB || !config.ctxt.Flag_shared) => |
| (MOVQstorezero [off1+off2] {mergeSym(sym1,sym2)} ptr mem) |
| |
| // store zero |
| (MOVBstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVBstorezero [off] {sym} ptr mem) |
| (MOVHstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVHstorezero [off] {sym} ptr mem) |
| (MOVWstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVWstorezero [off] {sym} ptr mem) |
| (MOVDstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVDstorezero [off] {sym} ptr mem) |
| (STP [off] {sym} ptr (MOVDconst [0]) (MOVDconst [0]) mem) => (MOVQstorezero [off] {sym} ptr mem) |
| |
| // register indexed store zero |
| (MOVDstorezero [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVDstorezeroidx ptr idx mem) |
| (MOVWstorezero [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVWstorezeroidx ptr idx mem) |
| (MOVHstorezero [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVHstorezeroidx ptr idx mem) |
| (MOVBstorezero [off] {sym} (ADD ptr idx) mem) && off == 0 && sym == nil => (MOVBstorezeroidx ptr idx mem) |
| (MOVDstoreidx ptr idx (MOVDconst [0]) mem) => (MOVDstorezeroidx ptr idx mem) |
| (MOVWstoreidx ptr idx (MOVDconst [0]) mem) => (MOVWstorezeroidx ptr idx mem) |
| (MOVHstoreidx ptr idx (MOVDconst [0]) mem) => (MOVHstorezeroidx ptr idx mem) |
| (MOVBstoreidx ptr idx (MOVDconst [0]) mem) => (MOVBstorezeroidx ptr idx mem) |
| (MOVDstorezeroidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVDstorezero [int32(c)] ptr mem) |
| (MOVDstorezeroidx (MOVDconst [c]) idx mem) && is32Bit(c) => (MOVDstorezero [int32(c)] idx mem) |
| (MOVWstorezeroidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVWstorezero [int32(c)] ptr mem) |
| (MOVWstorezeroidx (MOVDconst [c]) idx mem) && is32Bit(c) => (MOVWstorezero [int32(c)] idx mem) |
| (MOVHstorezeroidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVHstorezero [int32(c)] ptr mem) |
| (MOVHstorezeroidx (MOVDconst [c]) idx mem) && is32Bit(c) => (MOVHstorezero [int32(c)] idx mem) |
| (MOVBstorezeroidx ptr (MOVDconst [c]) mem) && is32Bit(c) => (MOVBstorezero [int32(c)] ptr mem) |
| (MOVBstorezeroidx (MOVDconst [c]) idx mem) && is32Bit(c) => (MOVBstorezero [int32(c)] idx mem) |
| |
| // shifted register indexed store zero |
| (MOVDstorezero [off] {sym} (ADDshiftLL [3] ptr idx) mem) && off == 0 && sym == nil => (MOVDstorezeroidx8 ptr idx mem) |
| (MOVWstorezero [off] {sym} (ADDshiftLL [2] ptr idx) mem) && off == 0 && sym == nil => (MOVWstorezeroidx4 ptr idx mem) |
| (MOVHstorezero [off] {sym} (ADDshiftLL [1] ptr idx) mem) && off == 0 && sym == nil => (MOVHstorezeroidx2 ptr idx mem) |
| (MOVDstorezeroidx ptr (SLLconst [3] idx) mem) => (MOVDstorezeroidx8 ptr idx mem) |
| (MOVWstorezeroidx ptr (SLLconst [2] idx) mem) => (MOVWstorezeroidx4 ptr idx mem) |
| (MOVHstorezeroidx ptr (SLLconst [1] idx) mem) => (MOVHstorezeroidx2 ptr idx mem) |
| (MOVHstorezeroidx ptr (ADD idx idx) mem) => (MOVHstorezeroidx2 ptr idx mem) |
| (MOVDstorezeroidx (SLLconst [3] idx) ptr mem) => (MOVDstorezeroidx8 ptr idx mem) |
| (MOVWstorezeroidx (SLLconst [2] idx) ptr mem) => (MOVWstorezeroidx4 ptr idx mem) |
| (MOVHstorezeroidx (SLLconst [1] idx) ptr mem) => (MOVHstorezeroidx2 ptr idx mem) |
| (MOVHstorezeroidx (ADD idx idx) ptr mem) => (MOVHstorezeroidx2 ptr idx mem) |
| (MOVDstoreidx8 ptr idx (MOVDconst [0]) mem) => (MOVDstorezeroidx8 ptr idx mem) |
| (MOVWstoreidx4 ptr idx (MOVDconst [0]) mem) => (MOVWstorezeroidx4 ptr idx mem) |
| (MOVHstoreidx2 ptr idx (MOVDconst [0]) mem) => (MOVHstorezeroidx2 ptr idx mem) |
| (MOVDstorezeroidx8 ptr (MOVDconst [c]) mem) && is32Bit(c<<3) => (MOVDstorezero [int32(c<<3)] ptr mem) |
| (MOVWstorezeroidx4 ptr (MOVDconst [c]) mem) && is32Bit(c<<2) => (MOVWstorezero [int32(c<<2)] ptr mem) |
| (MOVHstorezeroidx2 ptr (MOVDconst [c]) mem) && is32Bit(c<<1) => (MOVHstorezero [int32(c<<1)] ptr mem) |
| |
| // replace load from same location as preceding store with zero/sign extension (or copy in case of full width) |
| // these seem to have bad interaction with other rules, resulting in slower code |
| //(MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVBreg x) |
| //(MOVBUload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVBUreg x) |
| //(MOVHload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVHreg x) |
| //(MOVHUload [off] {sym} ptr (MOVHstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVHUreg x) |
| //(MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVWreg x) |
| //(MOVWUload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> (MOVWUreg x) |
| //(MOVDload [off] {sym} ptr (MOVDstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x |
| //(FMOVSload [off] {sym} ptr (FMOVSstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x |
| //(FMOVDload [off] {sym} ptr (FMOVDstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) -> x |
| |
| (MOVBload [off] {sym} ptr (MOVBstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVDconst [0]) |
| (MOVBUload [off] {sym} ptr (MOVBstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVDconst [0]) |
| (MOVHload [off] {sym} ptr (MOVHstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVDconst [0]) |
| (MOVHUload [off] {sym} ptr (MOVHstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVDconst [0]) |
| (MOVWload [off] {sym} ptr (MOVWstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVDconst [0]) |
| (MOVWUload [off] {sym} ptr (MOVWstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVDconst [0]) |
| (MOVDload [off] {sym} ptr (MOVDstorezero [off2] {sym2} ptr2 _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVDconst [0]) |
| |
| (MOVBloadidx ptr idx (MOVBstorezeroidx ptr2 idx2 _)) |
| && (isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) || isSamePtr(ptr, idx2) && isSamePtr(idx, ptr2)) => (MOVDconst [0]) |
| (MOVBUloadidx ptr idx (MOVBstorezeroidx ptr2 idx2 _)) |
| && (isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) || isSamePtr(ptr, idx2) && isSamePtr(idx, ptr2)) => (MOVDconst [0]) |
| (MOVHloadidx ptr idx (MOVHstorezeroidx ptr2 idx2 _)) |
| && (isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) || isSamePtr(ptr, idx2) && isSamePtr(idx, ptr2)) => (MOVDconst [0]) |
| (MOVHUloadidx ptr idx (MOVHstorezeroidx ptr2 idx2 _)) |
| && (isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) || isSamePtr(ptr, idx2) && isSamePtr(idx, ptr2)) => (MOVDconst [0]) |
| (MOVWloadidx ptr idx (MOVWstorezeroidx ptr2 idx2 _)) |
| && (isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) || isSamePtr(ptr, idx2) && isSamePtr(idx, ptr2)) => (MOVDconst [0]) |
| (MOVWUloadidx ptr idx (MOVWstorezeroidx ptr2 idx2 _)) |
| && (isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) || isSamePtr(ptr, idx2) && isSamePtr(idx, ptr2)) => (MOVDconst [0]) |
| (MOVDloadidx ptr idx (MOVDstorezeroidx ptr2 idx2 _)) |
| && (isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) || isSamePtr(ptr, idx2) && isSamePtr(idx, ptr2)) => (MOVDconst [0]) |
| |
| (MOVHloadidx2 ptr idx (MOVHstorezeroidx2 ptr2 idx2 _)) && isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) => (MOVDconst [0]) |
| (MOVHUloadidx2 ptr idx (MOVHstorezeroidx2 ptr2 idx2 _)) && isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) => (MOVDconst [0]) |
| (MOVWloadidx4 ptr idx (MOVWstorezeroidx4 ptr2 idx2 _)) && isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) => (MOVDconst [0]) |
| (MOVWUloadidx4 ptr idx (MOVWstorezeroidx4 ptr2 idx2 _)) && isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) => (MOVDconst [0]) |
| (MOVDloadidx8 ptr idx (MOVDstorezeroidx8 ptr2 idx2 _)) && isSamePtr(ptr, ptr2) && isSamePtr(idx, idx2) => (MOVDconst [0]) |
| |
| // don't extend after proper load |
| (MOVBreg x:(MOVBload _ _)) => (MOVDreg x) |
| (MOVBUreg x:(MOVBUload _ _)) => (MOVDreg x) |
| (MOVHreg x:(MOVBload _ _)) => (MOVDreg x) |
| (MOVHreg x:(MOVBUload _ _)) => (MOVDreg x) |
| (MOVHreg x:(MOVHload _ _)) => (MOVDreg x) |
| (MOVHUreg x:(MOVBUload _ _)) => (MOVDreg x) |
| (MOVHUreg x:(MOVHUload _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVBload _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVBUload _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVHload _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVHUload _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVWload _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVBUload _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVHUload _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVWUload _ _)) => (MOVDreg x) |
| (MOVBreg x:(MOVBloadidx _ _ _)) => (MOVDreg x) |
| (MOVBUreg x:(MOVBUloadidx _ _ _)) => (MOVDreg x) |
| (MOVHreg x:(MOVBloadidx _ _ _)) => (MOVDreg x) |
| (MOVHreg x:(MOVBUloadidx _ _ _)) => (MOVDreg x) |
| (MOVHreg x:(MOVHloadidx _ _ _)) => (MOVDreg x) |
| (MOVHUreg x:(MOVBUloadidx _ _ _)) => (MOVDreg x) |
| (MOVHUreg x:(MOVHUloadidx _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVBloadidx _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVBUloadidx _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVHloadidx _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVHUloadidx _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVWloadidx _ _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVBUloadidx _ _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVHUloadidx _ _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVWUloadidx _ _ _)) => (MOVDreg x) |
| (MOVHreg x:(MOVHloadidx2 _ _ _)) => (MOVDreg x) |
| (MOVHUreg x:(MOVHUloadidx2 _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVHloadidx2 _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVHUloadidx2 _ _ _)) => (MOVDreg x) |
| (MOVWreg x:(MOVWloadidx4 _ _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVHUloadidx2 _ _ _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVWUloadidx4 _ _ _)) => (MOVDreg x) |
| |
| // fold double extensions |
| (MOVBreg x:(MOVBreg _)) => (MOVDreg x) |
| (MOVBUreg x:(MOVBUreg _)) => (MOVDreg x) |
| (MOVHreg x:(MOVBreg _)) => (MOVDreg x) |
| (MOVHreg x:(MOVBUreg _)) => (MOVDreg x) |
| (MOVHreg x:(MOVHreg _)) => (MOVDreg x) |
| (MOVHUreg x:(MOVBUreg _)) => (MOVDreg x) |
| (MOVHUreg x:(MOVHUreg _)) => (MOVDreg x) |
| (MOVWreg x:(MOVBreg _)) => (MOVDreg x) |
| (MOVWreg x:(MOVBUreg _)) => (MOVDreg x) |
| (MOVWreg x:(MOVHreg _)) => (MOVDreg x) |
| (MOVWreg x:(MOVWreg _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVBUreg _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVHUreg _)) => (MOVDreg x) |
| (MOVWUreg x:(MOVWUreg _)) => (MOVDreg x) |
| |
| // don't extend before store |
| (MOVBstore [off] {sym} ptr (MOVBreg x) mem) => (MOVBstore [off] {sym} ptr x mem) |
| (MOVBstore [off] {sym} ptr (MOVBUreg x) mem) => (MOVBstore [off] {sym} ptr x mem) |
| (MOVBstore [off] {sym} ptr (MOVHreg x) mem) => (MOVBstore [off] {sym} ptr x mem) |
| (MOVBstore [off] {sym} ptr (MOVHUreg x) mem) => (MOVBstore [off] {sym} ptr x mem) |
| (MOVBstore [off] {sym} ptr (MOVWreg x) mem) => (MOVBstore [off] {sym} ptr x mem) |
| (MOVBstore [off] {sym} ptr (MOVWUreg x) mem) => (MOVBstore [off] {sym} ptr x mem) |
| (MOVHstore [off] {sym} ptr (MOVHreg x) mem) => (MOVHstore [off] {sym} ptr x mem) |
| (MOVHstore [off] {sym} ptr (MOVHUreg x) mem) => (MOVHstore [off] {sym} ptr x mem) |
| (MOVHstore [off] {sym} ptr (MOVWreg x) mem) => (MOVHstore [off] {sym} ptr x mem) |
| (MOVHstore [off] {sym} ptr (MOVWUreg x) mem) => (MOVHstore [off] {sym} ptr x mem) |
| (MOVWstore [off] {sym} ptr (MOVWreg x) mem) => (MOVWstore [off] {sym} ptr x mem) |
| (MOVWstore [off] {sym} ptr (MOVWUreg x) mem) => (MOVWstore [off] {sym} ptr x mem) |
| (MOVBstoreidx ptr idx (MOVBreg x) mem) => (MOVBstoreidx ptr idx x mem) |
| (MOVBstoreidx ptr idx (MOVBUreg x) mem) => (MOVBstoreidx ptr idx x mem) |
| (MOVBstoreidx ptr idx (MOVHreg x) mem) => (MOVBstoreidx ptr idx x mem) |
| (MOVBstoreidx ptr idx (MOVHUreg x) mem) => (MOVBstoreidx ptr idx x mem) |
| (MOVBstoreidx ptr idx (MOVWreg x) mem) => (MOVBstoreidx ptr idx x mem) |
| (MOVBstoreidx ptr idx (MOVWUreg x) mem) => (MOVBstoreidx ptr idx x mem) |
| (MOVHstoreidx ptr idx (MOVHreg x) mem) => (MOVHstoreidx ptr idx x mem) |
| (MOVHstoreidx ptr idx (MOVHUreg x) mem) => (MOVHstoreidx ptr idx x mem) |
| (MOVHstoreidx ptr idx (MOVWreg x) mem) => (MOVHstoreidx ptr idx x mem) |
| (MOVHstoreidx ptr idx (MOVWUreg x) mem) => (MOVHstoreidx ptr idx x mem) |
| (MOVWstoreidx ptr idx (MOVWreg x) mem) => (MOVWstoreidx ptr idx x mem) |
| (MOVWstoreidx ptr idx (MOVWUreg x) mem) => (MOVWstoreidx ptr idx x mem) |
| (MOVHstoreidx2 ptr idx (MOVHreg x) mem) => (MOVHstoreidx2 ptr idx x mem) |
| (MOVHstoreidx2 ptr idx (MOVHUreg x) mem) => (MOVHstoreidx2 ptr idx x mem) |
| (MOVHstoreidx2 ptr idx (MOVWreg x) mem) => (MOVHstoreidx2 ptr idx x mem) |
| (MOVHstoreidx2 ptr idx (MOVWUreg x) mem) => (MOVHstoreidx2 ptr idx x mem) |
| (MOVWstoreidx4 ptr idx (MOVWreg x) mem) => (MOVWstoreidx4 ptr idx x mem) |
| (MOVWstoreidx4 ptr idx (MOVWUreg x) mem) => (MOVWstoreidx4 ptr idx x mem) |
| |
| // if a register move has only 1 use, just use the same register without emitting instruction |
| // MOVDnop doesn't emit instruction, only for ensuring the type. |
| (MOVDreg x) && x.Uses == 1 => (MOVDnop x) |
| |
| // TODO: we should be able to get rid of MOVDnop all together. |
| // But for now, this is enough to get rid of lots of them. |
| (MOVDnop (MOVDconst [c])) => (MOVDconst [c]) |
| |
| // fold constant into arithmatic ops |
| (ADD x (MOVDconst [c])) => (ADDconst [c] x) |
| (SUB x (MOVDconst [c])) => (SUBconst [c] x) |
| (AND x (MOVDconst [c])) => (ANDconst [c] x) |
| (OR x (MOVDconst [c])) => (ORconst [c] x) |
| (XOR x (MOVDconst [c])) => (XORconst [c] x) |
| (TST x (MOVDconst [c])) => (TSTconst [c] x) |
| (TSTW x (MOVDconst [c])) => (TSTWconst [int32(c)] x) |
| (CMN x (MOVDconst [c])) => (CMNconst [c] x) |
| (CMNW x (MOVDconst [c])) => (CMNWconst [int32(c)] x) |
| (BIC x (MOVDconst [c])) => (ANDconst [^c] x) |
| (EON x (MOVDconst [c])) => (XORconst [^c] x) |
| (ORN x (MOVDconst [c])) => (ORconst [^c] x) |
| |
| (SLL x (MOVDconst [c])) => (SLLconst x [c&63]) // Note: I don't think we ever generate bad constant shifts (i.e. c>=64) |
| (SRL x (MOVDconst [c])) => (SRLconst x [c&63]) |
| (SRA x (MOVDconst [c])) => (SRAconst x [c&63]) |
| |
| (CMP x (MOVDconst [c])) => (CMPconst [c] x) |
| (CMP (MOVDconst [c]) x) => (InvertFlags (CMPconst [c] x)) |
| (CMPW x (MOVDconst [c])) => (CMPWconst [int32(c)] x) |
| (CMPW (MOVDconst [c]) x) => (InvertFlags (CMPWconst [int32(c)] x)) |
| |
| // Canonicalize the order of arguments to comparisons - helps with CSE. |
| ((CMP|CMPW) x y) && canonLessThan(x,y) => (InvertFlags ((CMP|CMPW) y x)) |
| |
| // mul-neg => mneg |
| (NEG (MUL x y)) => (MNEG x y) |
| (NEG (MULW x y)) => (MNEGW x y) |
| (MUL (NEG x) y) => (MNEG x y) |
| (MULW (NEG x) y) => (MNEGW x y) |
| |
| // madd/msub |
| (ADD a l:(MUL x y)) && l.Uses==1 && clobber(l) => (MADD a x y) |
| (SUB a l:(MUL x y)) && l.Uses==1 && clobber(l) => (MSUB a x y) |
| (ADD a l:(MNEG x y)) && l.Uses==1 && clobber(l) => (MSUB a x y) |
| (SUB a l:(MNEG x y)) && l.Uses==1 && clobber(l) => (MADD a x y) |
| |
| (ADD a l:(MULW x y)) && a.Type.Size() != 8 && l.Uses==1 && clobber(l) => (MADDW a x y) |
| (SUB a l:(MULW x y)) && a.Type.Size() != 8 && l.Uses==1 && clobber(l) => (MSUBW a x y) |
| (ADD a l:(MNEGW x y)) && a.Type.Size() != 8 && l.Uses==1 && clobber(l) => (MSUBW a x y) |
| (SUB a l:(MNEGW x y)) && a.Type.Size() != 8 && l.Uses==1 && clobber(l) => (MADDW a x y) |
| |
| // optimize ADCSflags, SBCSflags and friends |
| (ADCSflags x y (Select1 <types.TypeFlags> (ADDSconstflags [-1] (ADCzerocarry <typ.UInt64> c)))) => (ADCSflags x y c) |
| (ADCSflags x y (Select1 <types.TypeFlags> (ADDSconstflags [-1] (MOVDconst [0])))) => (ADDSflags x y) |
| (SBCSflags x y (Select1 <types.TypeFlags> (NEGSflags (NEG <typ.UInt64> (NGCzerocarry <typ.UInt64> bo))))) => (SBCSflags x y bo) |
| (SBCSflags x y (Select1 <types.TypeFlags> (NEGSflags (MOVDconst [0])))) => (SUBSflags x y) |
| |
| // mul by constant |
| (MUL x (MOVDconst [-1])) => (NEG x) |
| (MUL _ (MOVDconst [0])) => (MOVDconst [0]) |
| (MUL x (MOVDconst [1])) => x |
| (MUL x (MOVDconst [c])) && isPowerOfTwo64(c) => (SLLconst [log64(c)] x) |
| (MUL x (MOVDconst [c])) && isPowerOfTwo64(c-1) && c >= 3 => (ADDshiftLL x x [log64(c-1)]) |
| (MUL x (MOVDconst [c])) && isPowerOfTwo64(c+1) && c >= 7 => (ADDshiftLL (NEG <x.Type> x) x [log64(c+1)]) |
| (MUL x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) => (SLLconst [log64(c/3)] (ADDshiftLL <x.Type> x x [1])) |
| (MUL x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) => (SLLconst [log64(c/5)] (ADDshiftLL <x.Type> x x [2])) |
| (MUL x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) => (SLLconst [log64(c/7)] (ADDshiftLL <x.Type> (NEG <x.Type> x) x [3])) |
| (MUL x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) => (SLLconst [log64(c/9)] (ADDshiftLL <x.Type> x x [3])) |
| |
| (MULW x (MOVDconst [c])) && int32(c)==-1 => (NEG x) |
| (MULW _ (MOVDconst [c])) && int32(c)==0 => (MOVDconst [0]) |
| (MULW x (MOVDconst [c])) && int32(c)==1 => x |
| (MULW x (MOVDconst [c])) && isPowerOfTwo64(c) => (SLLconst [log64(c)] x) |
| (MULW x (MOVDconst [c])) && isPowerOfTwo64(c-1) && int32(c) >= 3 => (ADDshiftLL x x [log64(c-1)]) |
| (MULW x (MOVDconst [c])) && isPowerOfTwo64(c+1) && int32(c) >= 7 => (ADDshiftLL (NEG <x.Type> x) x [log64(c+1)]) |
| (MULW x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) && is32Bit(c) => (SLLconst [log64(c/3)] (ADDshiftLL <x.Type> x x [1])) |
| (MULW x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) && is32Bit(c) => (SLLconst [log64(c/5)] (ADDshiftLL <x.Type> x x [2])) |
| (MULW x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) && is32Bit(c) => (SLLconst [log64(c/7)] (ADDshiftLL <x.Type> (NEG <x.Type> x) x [3])) |
| (MULW x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) && is32Bit(c) => (SLLconst [log64(c/9)] (ADDshiftLL <x.Type> x x [3])) |
| |
| // mneg by constant |
| (MNEG x (MOVDconst [-1])) => x |
| (MNEG _ (MOVDconst [0])) => (MOVDconst [0]) |
| (MNEG x (MOVDconst [1])) => (NEG x) |
| (MNEG x (MOVDconst [c])) && isPowerOfTwo64(c) => (NEG (SLLconst <x.Type> [log64(c)] x)) |
| (MNEG x (MOVDconst [c])) && isPowerOfTwo64(c-1) && c >= 3 => (NEG (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MNEG x (MOVDconst [c])) && isPowerOfTwo64(c+1) && c >= 7 => (NEG (ADDshiftLL <x.Type> (NEG <x.Type> x) x [log64(c+1)])) |
| (MNEG x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) => (SLLconst <x.Type> [log64(c/3)] (SUBshiftLL <x.Type> x x [2])) |
| (MNEG x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) => (NEG (SLLconst <x.Type> [log64(c/5)] (ADDshiftLL <x.Type> x x [2]))) |
| (MNEG x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) => (SLLconst <x.Type> [log64(c/7)] (SUBshiftLL <x.Type> x x [3])) |
| (MNEG x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) => (NEG (SLLconst <x.Type> [log64(c/9)] (ADDshiftLL <x.Type> x x [3]))) |
| |
| |
| (MNEGW x (MOVDconst [c])) && int32(c)==-1 => x |
| (MNEGW _ (MOVDconst [c])) && int32(c)==0 => (MOVDconst [0]) |
| (MNEGW x (MOVDconst [c])) && int32(c)==1 => (NEG x) |
| (MNEGW x (MOVDconst [c])) && isPowerOfTwo64(c) => (NEG (SLLconst <x.Type> [log64(c)] x)) |
| (MNEGW x (MOVDconst [c])) && isPowerOfTwo64(c-1) && int32(c) >= 3 => (NEG (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MNEGW x (MOVDconst [c])) && isPowerOfTwo64(c+1) && int32(c) >= 7 => (NEG (ADDshiftLL <x.Type> (NEG <x.Type> x) x [log64(c+1)])) |
| (MNEGW x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) && is32Bit(c) => (SLLconst <x.Type> [log64(c/3)] (SUBshiftLL <x.Type> x x [2])) |
| (MNEGW x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) && is32Bit(c) => (NEG (SLLconst <x.Type> [log64(c/5)] (ADDshiftLL <x.Type> x x [2]))) |
| (MNEGW x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) && is32Bit(c) => (SLLconst <x.Type> [log64(c/7)] (SUBshiftLL <x.Type> x x [3])) |
| (MNEGW x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) && is32Bit(c) => (NEG (SLLconst <x.Type> [log64(c/9)] (ADDshiftLL <x.Type> x x [3]))) |
| |
| |
| (MADD a x (MOVDconst [-1])) => (SUB a x) |
| (MADD a _ (MOVDconst [0])) => a |
| (MADD a x (MOVDconst [1])) => (ADD a x) |
| (MADD a x (MOVDconst [c])) && isPowerOfTwo64(c) => (ADDshiftLL a x [log64(c)]) |
| (MADD a x (MOVDconst [c])) && isPowerOfTwo64(c-1) && c>=3 => (ADD a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MADD a x (MOVDconst [c])) && isPowerOfTwo64(c+1) && c>=7 => (SUB a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MADD a x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MADD a x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MADD a x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MADD a x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| (MADD a (MOVDconst [-1]) x) => (SUB a x) |
| (MADD a (MOVDconst [0]) _) => a |
| (MADD a (MOVDconst [1]) x) => (ADD a x) |
| (MADD a (MOVDconst [c]) x) && isPowerOfTwo64(c) => (ADDshiftLL a x [log64(c)]) |
| (MADD a (MOVDconst [c]) x) && isPowerOfTwo64(c-1) && c>=3 => (ADD a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MADD a (MOVDconst [c]) x) && isPowerOfTwo64(c+1) && c>=7 => (SUB a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MADD a (MOVDconst [c]) x) && c%3 == 0 && isPowerOfTwo64(c/3) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MADD a (MOVDconst [c]) x) && c%5 == 0 && isPowerOfTwo64(c/5) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MADD a (MOVDconst [c]) x) && c%7 == 0 && isPowerOfTwo64(c/7) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MADD a (MOVDconst [c]) x) && c%9 == 0 && isPowerOfTwo64(c/9) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| (MADDW a x (MOVDconst [c])) && int32(c)==-1 => (SUB a x) |
| (MADDW a _ (MOVDconst [c])) && int32(c)==0 => a |
| (MADDW a x (MOVDconst [c])) && int32(c)==1 => (ADD a x) |
| (MADDW a x (MOVDconst [c])) && isPowerOfTwo64(c) => (ADDshiftLL a x [log64(c)]) |
| (MADDW a x (MOVDconst [c])) && isPowerOfTwo64(c-1) && int32(c)>=3 => (ADD a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MADDW a x (MOVDconst [c])) && isPowerOfTwo64(c+1) && int32(c)>=7 => (SUB a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MADDW a x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) && is32Bit(c) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MADDW a x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) && is32Bit(c) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MADDW a x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) && is32Bit(c) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MADDW a x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) && is32Bit(c) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| (MADDW a (MOVDconst [c]) x) && int32(c)==-1 => (SUB a x) |
| (MADDW a (MOVDconst [c]) _) && int32(c)==0 => a |
| (MADDW a (MOVDconst [c]) x) && int32(c)==1 => (ADD a x) |
| (MADDW a (MOVDconst [c]) x) && isPowerOfTwo64(c) => (ADDshiftLL a x [log64(c)]) |
| (MADDW a (MOVDconst [c]) x) && isPowerOfTwo64(c-1) && int32(c)>=3 => (ADD a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MADDW a (MOVDconst [c]) x) && isPowerOfTwo64(c+1) && int32(c)>=7 => (SUB a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MADDW a (MOVDconst [c]) x) && c%3 == 0 && isPowerOfTwo64(c/3) && is32Bit(c) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MADDW a (MOVDconst [c]) x) && c%5 == 0 && isPowerOfTwo64(c/5) && is32Bit(c) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MADDW a (MOVDconst [c]) x) && c%7 == 0 && isPowerOfTwo64(c/7) && is32Bit(c) => (SUBshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MADDW a (MOVDconst [c]) x) && c%9 == 0 && isPowerOfTwo64(c/9) && is32Bit(c) => (ADDshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| (MSUB a x (MOVDconst [-1])) => (ADD a x) |
| (MSUB a _ (MOVDconst [0])) => a |
| (MSUB a x (MOVDconst [1])) => (SUB a x) |
| (MSUB a x (MOVDconst [c])) && isPowerOfTwo64(c) => (SUBshiftLL a x [log64(c)]) |
| (MSUB a x (MOVDconst [c])) && isPowerOfTwo64(c-1) && c>=3 => (SUB a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MSUB a x (MOVDconst [c])) && isPowerOfTwo64(c+1) && c>=7 => (ADD a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MSUB a x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MSUB a x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MSUB a x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MSUB a x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| (MSUB a (MOVDconst [-1]) x) => (ADD a x) |
| (MSUB a (MOVDconst [0]) _) => a |
| (MSUB a (MOVDconst [1]) x) => (SUB a x) |
| (MSUB a (MOVDconst [c]) x) && isPowerOfTwo64(c) => (SUBshiftLL a x [log64(c)]) |
| (MSUB a (MOVDconst [c]) x) && isPowerOfTwo64(c-1) && c>=3 => (SUB a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MSUB a (MOVDconst [c]) x) && isPowerOfTwo64(c+1) && c>=7 => (ADD a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MSUB a (MOVDconst [c]) x) && c%3 == 0 && isPowerOfTwo64(c/3) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MSUB a (MOVDconst [c]) x) && c%5 == 0 && isPowerOfTwo64(c/5) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MSUB a (MOVDconst [c]) x) && c%7 == 0 && isPowerOfTwo64(c/7) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MSUB a (MOVDconst [c]) x) && c%9 == 0 && isPowerOfTwo64(c/9) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| (MSUBW a x (MOVDconst [c])) && int32(c)==-1 => (ADD a x) |
| (MSUBW a _ (MOVDconst [c])) && int32(c)==0 => a |
| (MSUBW a x (MOVDconst [c])) && int32(c)==1 => (SUB a x) |
| (MSUBW a x (MOVDconst [c])) && isPowerOfTwo64(c) => (SUBshiftLL a x [log64(c)]) |
| (MSUBW a x (MOVDconst [c])) && isPowerOfTwo64(c-1) && int32(c)>=3 => (SUB a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MSUBW a x (MOVDconst [c])) && isPowerOfTwo64(c+1) && int32(c)>=7 => (ADD a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MSUBW a x (MOVDconst [c])) && c%3 == 0 && isPowerOfTwo64(c/3) && is32Bit(c) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MSUBW a x (MOVDconst [c])) && c%5 == 0 && isPowerOfTwo64(c/5) && is32Bit(c) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MSUBW a x (MOVDconst [c])) && c%7 == 0 && isPowerOfTwo64(c/7) && is32Bit(c) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MSUBW a x (MOVDconst [c])) && c%9 == 0 && isPowerOfTwo64(c/9) && is32Bit(c) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| (MSUBW a (MOVDconst [c]) x) && int32(c)==-1 => (ADD a x) |
| (MSUBW a (MOVDconst [c]) _) && int32(c)==0 => a |
| (MSUBW a (MOVDconst [c]) x) && int32(c)==1 => (SUB a x) |
| (MSUBW a (MOVDconst [c]) x) && isPowerOfTwo64(c) => (SUBshiftLL a x [log64(c)]) |
| (MSUBW a (MOVDconst [c]) x) && isPowerOfTwo64(c-1) && int32(c)>=3 => (SUB a (ADDshiftLL <x.Type> x x [log64(c-1)])) |
| (MSUBW a (MOVDconst [c]) x) && isPowerOfTwo64(c+1) && int32(c)>=7 => (ADD a (SUBshiftLL <x.Type> x x [log64(c+1)])) |
| (MSUBW a (MOVDconst [c]) x) && c%3 == 0 && isPowerOfTwo64(c/3) && is32Bit(c) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [2]) [log64(c/3)]) |
| (MSUBW a (MOVDconst [c]) x) && c%5 == 0 && isPowerOfTwo64(c/5) && is32Bit(c) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [2]) [log64(c/5)]) |
| (MSUBW a (MOVDconst [c]) x) && c%7 == 0 && isPowerOfTwo64(c/7) && is32Bit(c) => (ADDshiftLL a (SUBshiftLL <x.Type> x x [3]) [log64(c/7)]) |
| (MSUBW a (MOVDconst [c]) x) && c%9 == 0 && isPowerOfTwo64(c/9) && is32Bit(c) => (SUBshiftLL a (ADDshiftLL <x.Type> x x [3]) [log64(c/9)]) |
| |
| // div by constant |
| (UDIV x (MOVDconst [1])) => x |
| (UDIV x (MOVDconst [c])) && isPowerOfTwo64(c) => (SRLconst [log64(c)] x) |
| (UDIVW x (MOVDconst [c])) && uint32(c)==1 => x |
| (UDIVW x (MOVDconst [c])) && isPowerOfTwo64(c) && is32Bit(c) => (SRLconst [log64(c)] x) |
| (UMOD _ (MOVDconst [1])) => (MOVDconst [0]) |
| (UMOD x (MOVDconst [c])) && isPowerOfTwo64(c) => (ANDconst [c-1] x) |
| (UMODW _ (MOVDconst [c])) && uint32(c)==1 => (MOVDconst [0]) |
| (UMODW x (MOVDconst [c])) && isPowerOfTwo64(c) && is32Bit(c) => (ANDconst [c-1] x) |
| |
| // generic simplifications |
| (ADD x (NEG y)) => (SUB x y) |
| (SUB x x) => (MOVDconst [0]) |
| (AND x x) => x |
| (OR x x) => x |
| (XOR x x) => (MOVDconst [0]) |
| (BIC x x) => (MOVDconst [0]) |
| (EON x x) => (MOVDconst [-1]) |
| (ORN x x) => (MOVDconst [-1]) |
| (AND x (MVN y)) => (BIC x y) |
| (XOR x (MVN y)) => ( |