Skip to content

Commit ff35c38

Browse files
Jorropogopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Keith Randall <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent b159c99 commit ff35c38

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/cmd/compile/internal/ssa/prove.go

+2-19
Original file line numberDiff line numberDiff line change
@@ -878,34 +878,17 @@ func prove(f *Func) {
878878
continue
879879
}
880880

881-
header := ind.Block
882-
check := header.Controls[0]
883-
if check == nil {
884-
// we don't know how to rewrite a loop that not simple comparison
885-
continue
886-
}
887-
switch check.Op {
888-
case OpLeq64, OpLeq32, OpLeq16, OpLeq8,
889-
OpLess64, OpLess32, OpLess16, OpLess8:
890-
default:
891-
// we don't know how to rewrite a loop that not simple comparison
892-
continue
893-
}
894-
if !((check.Args[0] == ind && check.Args[1] == end) ||
895-
(check.Args[1] == ind && check.Args[0] == end)) {
896-
// we don't know how to rewrite a loop that not simple comparison
897-
continue
898-
}
899881
if end.Block == ind.Block {
900882
// we can't rewrite loops where the condition depends on the loop body
901883
// this simple check is forced to work because if this is true a Phi in ind.Block must exists
902884
continue
903885
}
904886

887+
check := ind.Block.Controls[0]
905888
// invert the check
906889
check.Args[0], check.Args[1] = check.Args[1], check.Args[0]
907890

908-
// invert start and end in the loop
891+
// swap start and end in the loop
909892
for i, v := range check.Args {
910893
if v != end {
911894
continue

0 commit comments

Comments
 (0)