From: Jorropo Date: Sat, 3 Feb 2024 08:06:30 +0000 (+0100) Subject: cmd/compile: remove bug workarounds in prove's loop inversion X-Git-Tag: go1.23rc1~1017 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ff35c382eb118565778fbf247e04e76730cdfc6c;p=gostls13.git 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 Reviewed-by: Keith Randall Auto-Submit: Keith Randall Reviewed-by: Michael Knyszek LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index 842719fb4c..761b77a05d 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -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