]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fold IsInBounds of modulo.
authorAlexandru Moșoi <mosoi@google.com>
Mon, 4 Apr 2016 14:38:26 +0000 (16:38 +0200)
committerAlexandru Moșoi <alexandru@mosoi.ro>
Mon, 4 Apr 2016 16:06:34 +0000 (16:06 +0000)
commit68325b56e7657cf9c0f2c223182b988a4f097cd1
treefc26dadf5aed17664997ff47b1fab01d81e2b23f
parent61f56e925ea97b82090d30f05cde3cd7a2668ed0
cmd/compile: fold IsInBounds of modulo.

In b we only need the division by 0 check.

func b(i uint, v []byte) byte {
    return v[i%uint(len(v))]
}

Updates #15079.

Change-Id: Ic7491e677dd57cd6ba577efbce576dbb6e023cbd
Reviewed-on: https://go-review.googlesource.com/21502
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ahmed Waheed <oneofone@gmail.com>
src/cmd/compile/internal/gc/testdata/divbyzero_ssa.go [new file with mode: 0644]
src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/rewritegeneric.go