mirror of
https://github.com/golang/go.git
synced 2025-05-29 11:25:43 +00:00
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: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
eccd3ef526
commit
07ec4385f1
@ -1033,6 +1033,10 @@
|
|||||||
(GreaterEqual (InvertFlags x)) -> (LessEqual x)
|
(GreaterEqual (InvertFlags x)) -> (LessEqual x)
|
||||||
(GreaterEqualU (InvertFlags x)) -> (LessEqualU 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
|
// absorb flag constants into conditional instructions
|
||||||
(CSELULT _ y (FlagEQ)) -> y
|
(CSELULT _ y (FlagEQ)) -> y
|
||||||
(CSELULT x _ (FlagLT_ULT)) -> x
|
(CSELULT x _ (FlagLT_ULT)) -> x
|
||||||
|
@ -3790,6 +3790,18 @@ func rewriteValueARM64_OpARM64MOVBUreg_0(v *Value) bool {
|
|||||||
v.AuxInt = int64(uint8(c))
|
v.AuxInt = int64(uint8(c))
|
||||||
return true
|
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
|
return false
|
||||||
}
|
}
|
||||||
func rewriteValueARM64_OpARM64MOVBload_0(v *Value) bool {
|
func rewriteValueARM64_OpARM64MOVBload_0(v *Value) bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user