Commit 07ec4385 authored by philhofer's avatar philhofer Committed by Cherry Zhang

cmd/compile: omit unnecessary boolean zero extension on arm64

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: default avatarCherry Zhang <cherryyz@google.com>
parent eccd3ef5
......@@ -1033,6 +1033,10 @@
(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
......
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment