]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: detect indvars that are bound by other indvars
authorGiovanni Bajo <rasky@develer.com>
Mon, 16 Sep 2019 08:25:48 +0000 (10:25 +0200)
committerGiovanni Bajo <rasky@develer.com>
Thu, 26 Sep 2019 18:47:12 +0000 (18:47 +0000)
commit1658263bbfbf0c31f179df878049e6d4690501c8
treed0acf2fa6bceb0d71c79dccec3048d9c7e0f36dd
parent9740b60e140433c6ab2230ca4f53935818221445
cmd/compile: detect indvars that are bound by other indvars

prove wasn't able to detect induction variables that was bound
by another inducation variable. This happened because an indvar
is a Phi, and thus in case of a dependency, the loop bounding
condition looked as Phi < Phi. This triggered an existing
codepath that checked whether the upper bound was a Phi to
detect loop conditions written in reversed order respect to the
idiomatic way (eg: for i:=0; len(n)>i; i++).

To fix this, we call the indvar pattern matching on both operands
of the loop condition, so that the first operand that matches
will be treated as the indvar.

Updates #24660 (removes a boundcheck from Fannkuch)

Change-Id: Iade83d8deb54f14277ed3f2e37b190e1ed173d11
Reviewed-on: https://go-review.googlesource.com/c/go/+/195220
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/loopbce.go
test/loopbce.go