]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: adding rule to eliminate ANDCCconst
authorJayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Wed, 1 Nov 2023 19:43:42 +0000 (14:43 -0500)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Mon, 6 Nov 2023 19:53:58 +0000 (19:53 +0000)
For example, the Slicemask rule in PPC64 generates a sequence wherein there is andi operation, after an  sradi, which can be replaced by srdi. This new rule eliminates ANDCCconst.

Change-Id: I27aaadf76b9c749a60bcdc5e87b1ebb8167d2fd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/539055
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/ssa/_gen/PPC64.rules
src/cmd/compile/internal/ssa/rewritePPC64.go

index 5780260c24936f2c908fdee6afee2733edbe902c..c9cd34b9a67ce8e88f629251203ae59901c6c2cf 100644 (file)
 (AtomicOr(8|32)   ...) => (LoweredAtomicOr(8|32)   ...)
 
 (Slicemask <t> x) => (SRADconst (NEG <t> x) [63])
+(Select0 (ANDCCconst [1] z:(SRADconst [63] x))) && z.Uses == 1  => (SRDconst [63] x)
 
 // Note that MOV??reg returns a 64-bit int, x is not necessarily that wide
 // This may interact with other patterns in the future. (Compare with arm64)
index 7ec6bb4e4629d987f20a5bef8fbaeee72ffa540f..473a8ff9d95527c949db2272e03040539177e26c 100644 (file)
@@ -14552,6 +14552,26 @@ func rewriteValuePPC64_OpSelect0(v *Value) bool {
                v.AddArg(v0)
                return true
        }
+       // match: (Select0 (ANDCCconst [1] z:(SRADconst [63] x)))
+       // cond: z.Uses == 1
+       // result: (SRDconst [63] x)
+       for {
+               if v_0.Op != OpPPC64ANDCCconst || auxIntToInt64(v_0.AuxInt) != 1 {
+                       break
+               }
+               z := v_0.Args[0]
+               if z.Op != OpPPC64SRADconst || auxIntToInt64(z.AuxInt) != 63 {
+                       break
+               }
+               x := z.Args[0]
+               if !(z.Uses == 1) {
+                       break
+               }
+               v.reset(OpPPC64SRDconst)
+               v.AuxInt = int64ToAuxInt(63)
+               v.AddArg(x)
+               return true
+       }
        return false
 }
 func rewriteValuePPC64_OpSelect1(v *Value) bool {