Now that we're bootstrapping from a toolchain that has min/max builtins.
Update #64751
Change-Id: I63eedf3cca00f56f62ca092949cb2dc61db03361
Reviewed-on: https://go-review.googlesource.com/c/go/+/610355
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
return left
}
-func max(a, b int8) int8 {
- if a > b {
- return a
- }
- return b
-}
-
func (t *node32) copy() *node32 {
u := *t
return &u
(CMP(W|WU) (MOVDconst [c]) x) => (InvertFlags (CMP(W|WU)const x [int32(c)]))
// Match (x >> c) << d to 'rotate then insert selected bits [into zero]'.
-(SLDconst (SRDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(uint8(max8(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))})
+(SLDconst (SRDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(uint8(max(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))})
// Match (x << c) >> d to 'rotate then insert selected bits [into zero]'.
-(SRDconst (SLDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(d, uint8(min8(63, int8(63-c+d))), uint8(int8(c-d)&63))})
+(SRDconst (SLDconst x [c]) [d]) => (RISBGZ x {s390x.NewRotateParams(d, uint8(min(63, int8(63-c+d))), uint8(int8(c-d)&63))})
// Absorb input zero extension into 'rotate then insert selected bits [into zero]'.
(RISBGZ (MOVWZreg x) {r}) && r.InMerge(0xffffffff) != nil => (RISBGZ x {*r.InMerge(0xffffffff)})
initializedChildren, initializedDepth, initializedExits bool
}
-func min8(a, b int8) int8 {
- if a < b {
- return a
- }
- return b
-}
-
-func max8(a, b int8) int8 {
- if a > b {
- return a
- }
- return b
-}
-
const (
blDEFAULT = 0
blMin = blDEFAULT
// and less influential than inferences from loop structure.
case BlockDefer:
local[b.ID] = blCALL
- certain[b.ID] = max8(blCALL, certain[b.Succs[0].b.ID])
+ certain[b.ID] = max(blCALL, certain[b.Succs[0].b.ID])
default:
if len(b.Succs) == 1 {
// tagged with call cost. Net effect is that loop entry is favored.
b0 := b.Succs[0].b.ID
b1 := b.Succs[1].b.ID
- certain[b.ID] = min8(certain[b0], certain[b1])
+ certain[b.ID] = min(certain[b0], certain[b1])
l := b2l[b.ID]
l0 := b2l[b0]
for _, v := range b.Values {
if opcodeTable[v.Op].call {
local[b.ID] = blCALL
- certain[b.ID] = max8(blCALL, certain[b.Succs[0].b.ID])
+ certain[b.ID] = max(blCALL, certain[b.Succs[0].b.ID])
break
}
}
// AND can only make the value smaller.
a := ft.limits[v.Args[0].ID]
b := ft.limits[v.Args[1].ID]
- return ft.unsignedMax(v, minU(a.umax, b.umax))
+ return ft.unsignedMax(v, min(a.umax, b.umax))
case OpOr64, OpOr32, OpOr16, OpOr8:
// OR can only make the value bigger and can't flip bits proved to be zero in both inputs.
a := ft.limits[v.Args[0].ID]
b := ft.limits[v.Args[1].ID]
return ft.unsignedMinMax(v,
- maxU(a.umin, b.umin),
+ max(a.umin, b.umin),
1<<bits.Len64(a.umax|b.umax)-1)
case OpXor64, OpXor32, OpXor16, OpXor8:
// XOR can't flip bits that are proved to be zero in both inputs.
a := ft.limits[v.Args[0].ID]
b := ft.limits[v.Args[1].ID]
// Underflow in the arithmetic below is ok, it gives to MaxUint64 which does nothing to the limit.
- return ft.unsignedMax(v, minU(a.umax, b.umax-1))
+ return ft.unsignedMax(v, min(a.umax, b.umax-1))
case OpDiv64, OpDiv32, OpDiv16, OpDiv8:
a := ft.limits[v.Args[0].ID]
b := ft.limits[v.Args[1].ID]
l2 := ft.limits[a.ID]
l.min = min(l.min, l2.min)
l.max = max(l.max, l2.max)
- l.umin = minU(l.umin, l2.umin)
- l.umax = maxU(l.umax, l2.umax)
+ l.umin = min(l.umin, l2.umin)
+ l.umax = max(l.umax, l2.umax)
}
return ft.newLimit(v, l)
}
vi := &s.values[v.ID]
if vi.spill != nil {
// Final block not known - keep track of subtree where restores reside.
- vi.restoreMin = min32(vi.restoreMin, s.sdom[b.ID].entry)
- vi.restoreMax = max32(vi.restoreMax, s.sdom[b.ID].exit)
+ vi.restoreMin = min(vi.restoreMin, s.sdom[b.ID].entry)
+ vi.restoreMax = max(vi.restoreMax, s.sdom[b.ID].exit)
return vi.spill
}
// Make a spill for v. We don't know where we want
d.addList(e.ID, e.regs)
}
}
-
-func min32(x, y int32) int32 {
- if x < y {
- return x
- }
- return y
-}
-func max32(x, y int32) int32 {
- if x > y {
- return x
- }
- return y
-}
var ruleFile io.Writer
-// TODO: replace these with the built-in min/max once they are available
-// during bootstrap (when bootstrapping with 1.21 or later).
-func min(x, y int64) int64 {
- if x < y {
- return x
- }
- return y
-}
-func max(x, y int64) int64 {
- if x > y {
- return x
- }
- return y
-}
-func minU(x, y uint64) uint64 {
- if x < y {
- return x
- }
- return y
-}
-func maxU(x, y uint64) uint64 {
- if x > y {
- return x
- }
- return y
-}
-
func isConstZero(v *Value) bool {
switch v.Op {
case OpConstNil:
func rewriteValueS390X_OpS390XSLDconst(v *Value) bool {
v_0 := v.Args[0]
// match: (SLDconst (SRDconst x [c]) [d])
- // result: (RISBGZ x {s390x.NewRotateParams(uint8(max8(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))})
+ // result: (RISBGZ x {s390x.NewRotateParams(uint8(max(0, int8(c-d))), 63-d, uint8(int8(d-c)&63))})
for {
d := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XSRDconst {
c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
v.reset(OpS390XRISBGZ)
- v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(uint8(max8(0, int8(c-d))), 63-d, uint8(int8(d-c)&63)))
+ v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(uint8(max(0, int8(c-d))), 63-d, uint8(int8(d-c)&63)))
v.AddArg(x)
return true
}
func rewriteValueS390X_OpS390XSRDconst(v *Value) bool {
v_0 := v.Args[0]
// match: (SRDconst (SLDconst x [c]) [d])
- // result: (RISBGZ x {s390x.NewRotateParams(d, uint8(min8(63, int8(63-c+d))), uint8(int8(c-d)&63))})
+ // result: (RISBGZ x {s390x.NewRotateParams(d, uint8(min(63, int8(63-c+d))), uint8(int8(c-d)&63))})
for {
d := auxIntToUint8(v.AuxInt)
if v_0.Op != OpS390XSLDconst {
c := auxIntToUint8(v_0.AuxInt)
x := v_0.Args[0]
v.reset(OpS390XRISBGZ)
- v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(d, uint8(min8(63, int8(63-c+d))), uint8(int8(c-d)&63)))
+ v.Aux = s390xRotateParamsToAux(s390x.NewRotateParams(d, uint8(min(63, int8(63-c+d))), uint8(int8(c-d)&63)))
v.AddArg(x)
return true
}
cond := cond.(*ir.LogicalExpr)
mid := s.f.NewBlock(ssa.BlockPlain)
s.stmtList(cond.Init())
- s.condBranch(cond.X, mid, no, max8(likely, 0))
+ s.condBranch(cond.X, mid, no, max(likely, 0))
s.startBlock(mid)
s.condBranch(cond.Y, yes, no, likely)
return
cond := cond.(*ir.LogicalExpr)
mid := s.f.NewBlock(ssa.BlockPlain)
s.stmtList(cond.Init())
- s.condBranch(cond.X, yes, mid, min8(likely, 0))
+ s.condBranch(cond.X, yes, mid, min(likely, 0))
s.startBlock(mid)
s.condBranch(cond.Y, yes, no, likely)
return
return callee.LinksymABI(callee.Func.ABI)
}
-func min8(a, b int8) int8 {
- if a < b {
- return a
- }
- return b
-}
-
-func max8(a, b int8) int8 {
- if a > b {
- return a
- }
- return b
-}
-
// deferStructFnField is the field index of _defer.fn.
const deferStructFnField = 4
return "7"
}
-func min(a, b int) int {
- if a < b {
- return a
- }
- return b
-}
-
// elfIsLittleEndian detects if the ELF file is little endian.
func elfIsLittleEndian(fn string) bool {
// read the ELF file header to determine the endianness without using the