]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: avoid remainder in loopbce when increment=0
authorDavid Chase <drchase@google.com>
Mon, 25 Jun 2018 19:26:45 +0000 (15:26 -0400)
committerDavid Chase <drchase@google.com>
Mon, 25 Jun 2018 20:36:42 +0000 (20:36 +0000)
commit7e9d55eeeb183ee95d26b3ed4ff171902605decf
tree5739d3711787f80403e6616d11285454508d7b99
parent6d709528972aa572a6dafb06cd3446348d337aa7
cmd/compile: avoid remainder in loopbce when increment=0

For non-unit increment, loopbce checks to see if the
increment evenly divides the difference between (constant)
loop start and end.  This test panics when the increment
is zero.

Fix: check for zero, if found, don't optimize the loop.

Also added missing copyright notice to loopbce.go.

Fixes #26043.

Change-Id: I5f460104879cacc94481949234c9ce8c519d6380
Reviewed-on: https://go-review.googlesource.com/120759
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/ssa/loopbce.go
test/fixedbugs/issue26043.go [new file with mode: 0644]