mirror of
https://github.com/golang/go.git
synced 2025-05-18 13:54:40 +00:00
cmd/compile: remove bug workarounds in prove's loop inversion
I wrote theses checks because I got bad panics on some innocent functions, turns out I was working around #63955 but I was not aware of that at the time. The proper fix was included in CL 539977 this is now doing nothing. Change-Id: I89329329933527b6f3cb817dc1e039a38f58da9a Reviewed-on: https://go-review.googlesource.com/c/go/+/560975 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
b159c99eb7
commit
ff35c382eb
@ -878,34 +878,17 @@ func prove(f *Func) {
|
||||
continue
|
||||
}
|
||||
|
||||
header := ind.Block
|
||||
check := header.Controls[0]
|
||||
if check == nil {
|
||||
// we don't know how to rewrite a loop that not simple comparison
|
||||
continue
|
||||
}
|
||||
switch check.Op {
|
||||
case OpLeq64, OpLeq32, OpLeq16, OpLeq8,
|
||||
OpLess64, OpLess32, OpLess16, OpLess8:
|
||||
default:
|
||||
// we don't know how to rewrite a loop that not simple comparison
|
||||
continue
|
||||
}
|
||||
if !((check.Args[0] == ind && check.Args[1] == end) ||
|
||||
(check.Args[1] == ind && check.Args[0] == end)) {
|
||||
// we don't know how to rewrite a loop that not simple comparison
|
||||
continue
|
||||
}
|
||||
if end.Block == ind.Block {
|
||||
// we can't rewrite loops where the condition depends on the loop body
|
||||
// this simple check is forced to work because if this is true a Phi in ind.Block must exists
|
||||
continue
|
||||
}
|
||||
|
||||
check := ind.Block.Controls[0]
|
||||
// invert the check
|
||||
check.Args[0], check.Args[1] = check.Args[1], check.Args[0]
|
||||
|
||||
// invert start and end in the loop
|
||||
// swap start and end in the loop
|
||||
for i, v := range check.Args {
|
||||
if v != end {
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user