From: Jorropo Date: Sat, 25 Oct 2025 13:34:02 +0000 (+0200) Subject: cmd/compile: remove 68857 min & max flowLimit workaround in prove X-Git-Tag: go1.26rc1~458 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a50de4bda7;p=gostls13.git cmd/compile: remove 68857 min & max flowLimit workaround in prove We can know this is correct because all the testcases added by CL 656157 are still passing. Partial revert of CL 656157 (everything but the testcases). Change-Id: I24931fa1affba7e9e92233b3de74ebade3d48a09 Reviewed-on: https://go-review.googlesource.com/c/go/+/714921 Auto-Submit: Jorropo Reviewed-by: Keith Randall Reviewed-by: Michael Knyszek Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index cbfbd70af6..d448f6e7fc 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -1996,89 +1996,6 @@ func (ft *factsTable) flowLimit(v *Value) bool { return ft.newLimit(v, lim) case OpPhi: - { - // Work around for go.dev/issue/68857, look for min(x, y) and max(x, y). - b := v.Block - if len(b.Preds) != 2 { - goto notMinNorMax - } - // FIXME: this code searches for the following losange pattern - // because that what ssagen produce for min and max builtins: - // conditionBlock → (firstBlock, secondBlock) → v.Block - // there are three non losange equivalent constructions - // we could match for, but I didn't bother: - // conditionBlock → (v.Block, secondBlock → v.Block) - // conditionBlock → (firstBlock → v.Block, v.Block) - // conditionBlock → (v.Block, v.Block) - firstBlock, secondBlock := b.Preds[0].b, b.Preds[1].b - if firstBlock.Kind != BlockPlain || secondBlock.Kind != BlockPlain { - goto notMinNorMax - } - if len(firstBlock.Preds) != 1 || len(secondBlock.Preds) != 1 { - goto notMinNorMax - } - conditionBlock := firstBlock.Preds[0].b - if conditionBlock != secondBlock.Preds[0].b { - goto notMinNorMax - } - if conditionBlock.Kind != BlockIf { - goto notMinNorMax - } - - less := conditionBlock.Controls[0] - var unsigned bool - switch less.Op { - case OpLess64U, OpLess32U, OpLess16U, OpLess8U, - OpLeq64U, OpLeq32U, OpLeq16U, OpLeq8U: - unsigned = true - case OpLess64, OpLess32, OpLess16, OpLess8, - OpLeq64, OpLeq32, OpLeq16, OpLeq8: - default: - goto notMinNorMax - } - small, big := less.Args[0], less.Args[1] - truev, falsev := v.Args[0], v.Args[1] - if conditionBlock.Succs[0].b == secondBlock { - truev, falsev = falsev, truev - } - - bigl, smalll := ft.limits[big.ID], ft.limits[small.ID] - if truev == big { - if falsev == small { - // v := big if small <¿=? big else small - if unsigned { - maximum := max(bigl.umax, smalll.umax) - minimum := max(bigl.umin, smalll.umin) - return ft.unsignedMinMax(v, minimum, maximum) - } else { - maximum := max(bigl.max, smalll.max) - minimum := max(bigl.min, smalll.min) - return ft.signedMinMax(v, minimum, maximum) - } - } else { - goto notMinNorMax - } - } else if truev == small { - if falsev == big { - // v := small if small <¿=? big else big - if unsigned { - maximum := min(bigl.umax, smalll.umax) - minimum := min(bigl.umin, smalll.umin) - return ft.unsignedMinMax(v, minimum, maximum) - } else { - maximum := min(bigl.max, smalll.max) - minimum := min(bigl.min, smalll.min) - return ft.signedMinMax(v, minimum, maximum) - } - } else { - goto notMinNorMax - } - } else { - goto notMinNorMax - } - } - notMinNorMax: - // Compute the union of all the input phis. // Often this will convey no information, because the block // is not dominated by its predecessors and hence the