mirror of
https://github.com/golang/go
synced 2024-11-17 17:04:47 -07:00
cmd/compile: constant fold SSA bool to int conversions
Shaves off a few instructions here and there. file before after Δ % go/types.s 322118 321851 -267 -0.083% go/internal/gcimporter.s 34937 34909 -28 -0.080% go/internal/gccgoimporter.s 56493 56474 -19 -0.034% cmd/compile/internal/ssa.s 3926994 3927177 +183 +0.005% total 18862670 18862539 -131 -0.001% Change-Id: I724f32317b946b5138224808f85709d9c097a247 Reviewed-on: https://go-review.googlesource.com/c/go/+/221428 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
d889f0cb10
commit
74f898360d
@ -56,6 +56,7 @@
|
|||||||
(Cvt64Fto64 (Const64F [c])) -> (Const64 [int64(auxTo64F(c))])
|
(Cvt64Fto64 (Const64F [c])) -> (Const64 [int64(auxTo64F(c))])
|
||||||
(Round32F x:(Const32F)) -> x
|
(Round32F x:(Const32F)) -> x
|
||||||
(Round64F x:(Const64F)) -> x
|
(Round64F x:(Const64F)) -> x
|
||||||
|
(CvtBoolToUint8 (ConstBool [c])) -> (Const8 [c])
|
||||||
|
|
||||||
(Trunc16to8 (ZeroExt8to16 x)) -> x
|
(Trunc16to8 (ZeroExt8to16 x)) -> x
|
||||||
(Trunc32to8 (ZeroExt8to32 x)) -> x
|
(Trunc32to8 (ZeroExt8to32 x)) -> x
|
||||||
|
@ -68,6 +68,8 @@ func rewriteValuegeneric(v *Value) bool {
|
|||||||
return rewriteValuegeneric_OpCvt64to32F(v)
|
return rewriteValuegeneric_OpCvt64to32F(v)
|
||||||
case OpCvt64to64F:
|
case OpCvt64to64F:
|
||||||
return rewriteValuegeneric_OpCvt64to64F(v)
|
return rewriteValuegeneric_OpCvt64to64F(v)
|
||||||
|
case OpCvtBoolToUint8:
|
||||||
|
return rewriteValuegeneric_OpCvtBoolToUint8(v)
|
||||||
case OpDiv16:
|
case OpDiv16:
|
||||||
return rewriteValuegeneric_OpDiv16(v)
|
return rewriteValuegeneric_OpDiv16(v)
|
||||||
case OpDiv16u:
|
case OpDiv16u:
|
||||||
@ -2981,6 +2983,21 @@ func rewriteValuegeneric_OpCvt64to64F(v *Value) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
func rewriteValuegeneric_OpCvtBoolToUint8(v *Value) bool {
|
||||||
|
v_0 := v.Args[0]
|
||||||
|
// match: (CvtBoolToUint8 (ConstBool [c]))
|
||||||
|
// result: (Const8 [c])
|
||||||
|
for {
|
||||||
|
if v_0.Op != OpConstBool {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
c := v_0.AuxInt
|
||||||
|
v.reset(OpConst8)
|
||||||
|
v.AuxInt = c
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
func rewriteValuegeneric_OpDiv16(v *Value) bool {
|
func rewriteValuegeneric_OpDiv16(v *Value) bool {
|
||||||
v_1 := v.Args[1]
|
v_1 := v.Args[1]
|
||||||
v_0 := v.Args[0]
|
v_0 := v.Args[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user