]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add patterns to improve PPC64 FP comparisons
authorDavid Chase <drchase@google.com>
Thu, 20 Oct 2016 15:05:45 +0000 (11:05 -0400)
committerDavid Chase <drchase@google.com>
Thu, 20 Oct 2016 15:34:20 +0000 (15:34 +0000)
Uncommented 4 comparison rules of this form:
(NE (CMPWconst [0] (FLessThan cc)) yes no) -> (FLT cc yes no)

Fixes #17507.

Change-Id: I74f34f13526aeee619711c8281a66652d90a962a
Reviewed-on: https://go-review.googlesource.com/31612
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/PPC64.rules
src/cmd/compile/internal/ssa/rewritePPC64.go

index 1df8b3ca0eae03b56d9c058c4f6aef8de999a0dd..ba1ffa5e12ed2758d916a8540259c4d8795e93e4 100644 (file)
 (NE (CMPWconst [0] (LessEqual cc)) yes no) -> (LE cc yes no)
 (NE (CMPWconst [0] (GreaterThan cc)) yes no) -> (GT cc yes no)
 (NE (CMPWconst [0] (GreaterEqual cc)) yes no) -> (GE cc yes no)
-// (NE (CMPWconst [0] (FLessThan cc)) yes no) -> (FLT cc yes no)
-// (NE (CMPWconst [0] (FLessEqual cc)) yes no) -> (FLE cc yes no)
-// (NE (CMPWconst [0] (FGreaterThan cc)) yes no) -> (FGT cc yes no)
-// (NE (CMPWconst [0] (FGreaterEqual cc)) yes no) -> (FGE cc yes no)
+(NE (CMPWconst [0] (FLessThan cc)) yes no) -> (FLT cc yes no)
+(NE (CMPWconst [0] (FLessEqual cc)) yes no) -> (FLE cc yes no)
+(NE (CMPWconst [0] (FGreaterThan cc)) yes no) -> (FGT cc yes no)
+(NE (CMPWconst [0] (FGreaterEqual cc)) yes no) -> (FGE cc yes no)
 
 // Elide compares of bit tests // TODO need to make both CC and result of ANDCC available.
 (EQ (CMPconst [0] (ANDconst [c] x)) yes no) -> (EQ (ANDCCconst [c] x) yes no)
index defda0aa6325c9144b9bcb6f20445fac01af97ec..bea94e44d81be8b4b99fce38027d5e45410241dc 100644 (file)
@@ -10584,6 +10584,102 @@ func rewriteBlockPPC64(b *Block, config *Config) bool {
                        _ = no
                        return true
                }
+               // match: (NE (CMPWconst [0] (FLessThan cc)) yes no)
+               // cond:
+               // result: (FLT cc yes no)
+               for {
+                       v := b.Control
+                       if v.Op != OpPPC64CMPWconst {
+                               break
+                       }
+                       if v.AuxInt != 0 {
+                               break
+                       }
+                       v_0 := v.Args[0]
+                       if v_0.Op != OpPPC64FLessThan {
+                               break
+                       }
+                       cc := v_0.Args[0]
+                       yes := b.Succs[0]
+                       no := b.Succs[1]
+                       b.Kind = BlockPPC64FLT
+                       b.SetControl(cc)
+                       _ = yes
+                       _ = no
+                       return true
+               }
+               // match: (NE (CMPWconst [0] (FLessEqual cc)) yes no)
+               // cond:
+               // result: (FLE cc yes no)
+               for {
+                       v := b.Control
+                       if v.Op != OpPPC64CMPWconst {
+                               break
+                       }
+                       if v.AuxInt != 0 {
+                               break
+                       }
+                       v_0 := v.Args[0]
+                       if v_0.Op != OpPPC64FLessEqual {
+                               break
+                       }
+                       cc := v_0.Args[0]
+                       yes := b.Succs[0]
+                       no := b.Succs[1]
+                       b.Kind = BlockPPC64FLE
+                       b.SetControl(cc)
+                       _ = yes
+                       _ = no
+                       return true
+               }
+               // match: (NE (CMPWconst [0] (FGreaterThan cc)) yes no)
+               // cond:
+               // result: (FGT cc yes no)
+               for {
+                       v := b.Control
+                       if v.Op != OpPPC64CMPWconst {
+                               break
+                       }
+                       if v.AuxInt != 0 {
+                               break
+                       }
+                       v_0 := v.Args[0]
+                       if v_0.Op != OpPPC64FGreaterThan {
+                               break
+                       }
+                       cc := v_0.Args[0]
+                       yes := b.Succs[0]
+                       no := b.Succs[1]
+                       b.Kind = BlockPPC64FGT
+                       b.SetControl(cc)
+                       _ = yes
+                       _ = no
+                       return true
+               }
+               // match: (NE (CMPWconst [0] (FGreaterEqual cc)) yes no)
+               // cond:
+               // result: (FGE cc yes no)
+               for {
+                       v := b.Control
+                       if v.Op != OpPPC64CMPWconst {
+                               break
+                       }
+                       if v.AuxInt != 0 {
+                               break
+                       }
+                       v_0 := v.Args[0]
+                       if v_0.Op != OpPPC64FGreaterEqual {
+                               break
+                       }
+                       cc := v_0.Args[0]
+                       yes := b.Succs[0]
+                       no := b.Succs[1]
+                       b.Kind = BlockPPC64FGE
+                       b.SetControl(cc)
+                       _ = yes
+                       _ = no
+                       return true
+               }
                // match: (NE (CMPconst [0] (ANDconst [c] x)) yes no)
                // cond:
                // result: (NE (ANDCCconst [c] x) yes no)