]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: teach prove about min/max phi operations
authorKeith Randall <khr@golang.org>
Sat, 26 Oct 2024 21:19:32 +0000 (14:19 -0700)
committerKeith Randall <khr@golang.org>
Tue, 29 Oct 2024 16:46:48 +0000 (16:46 +0000)
commit4dcbb00be200bc1f88b534c311ed4289eb2fbdd5
treece9db27b0c526acdba9240b50c85c931659366fb
parentf5526b56dbf45ce1f2e856f4aa78674dd0b5afe3
cmd/compile: teach prove about min/max phi operations

If there is a phi that is computing the minimum of its two inputs,
then we know the result of the phi is smaller than or equal to both
of its inputs. Similarly for maxiumum (although max seems less useful).

This pattern happens for the case

  n := copy(a, b)

n is the minimum of len(a) and len(b), so with this optimization we
know both n <= len(a) and n <= len(b). That extra information is
helpful for subsequent slicing of a or b.

Fixes #16833

Change-Id: Ib4238fd1edae0f2940f62a5516a6b363bbe7928c
Reviewed-on: https://go-review.googlesource.com/c/go/+/622240
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/block.go
src/cmd/compile/internal/ssa/prove.go
test/prove.go