1
0
mirror of https://github.com/golang/go synced 2024-09-30 11:18:33 -06:00

cmd/compile: add patterns to improve PPC64 FP comparisons

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>
This commit is contained in:
David Chase 2016-10-20 11:05:45 -04:00
parent f9bbfe4a09
commit 33b71dfa1c
2 changed files with 100 additions and 4 deletions

View File

@ -361,10 +361,10 @@
(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)

View 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)