]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: omit unnecessary boolean zero extension on arm64
authorphilhofer <phofer@umich.edu>
Tue, 15 Aug 2017 04:50:43 +0000 (21:50 -0700)
committerCherry Zhang <cherryyz@google.com>
Mon, 21 Aug 2017 14:38:04 +0000 (14:38 +0000)
On arm64, all boolean-generating instructions (CSET, etc.) set the upper
63 bits of the destination register to zero, so there is no need
to zero-extend the lower 8 bits again.

Fixes #21445

Change-Id: I3b176baab706eb684105400bacbaa24175f721f3
Reviewed-on: https://go-review.googlesource.com/55671
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/ARM64.rules
src/cmd/compile/internal/ssa/rewriteARM64.go

index 2c51b5e01bba2e614d5773c38cca3e75ae970e64..f13541068ee8b56f89f8ad7fa59d85a5f630d85f 100644 (file)
 (GreaterEqual (InvertFlags x)) -> (LessEqual x)
 (GreaterEqualU (InvertFlags x)) -> (LessEqualU x)
 
+// Boolean-generating instructions always
+// zero upper bit of the register; no need to zero-extend
+(MOVBUreg x) && x.Type.IsBoolean() -> (MOVDreg x)
+
 // absorb flag constants into conditional instructions
 (CSELULT _ y (FlagEQ)) -> y
 (CSELULT x _ (FlagLT_ULT)) -> x
index 15f1d70a6d5ba99f4767dd2dc754439e0975c64f..f87c5521bb3b9541100b77fc5d939efde4c711ff 100644 (file)
@@ -3790,6 +3790,18 @@ func rewriteValueARM64_OpARM64MOVBUreg_0(v *Value) bool {
                v.AuxInt = int64(uint8(c))
                return true
        }
+       // match: (MOVBUreg x)
+       // cond: x.Type.IsBoolean()
+       // result: (MOVDreg x)
+       for {
+               x := v.Args[0]
+               if !(x.Type.IsBoolean()) {
+                       break
+               }
+               v.reset(OpARM64MOVDreg)
+               v.AddArg(x)
+               return true
+       }
        return false
 }
 func rewriteValueARM64_OpARM64MOVBload_0(v *Value) bool {