aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/prove.go
diff options
context:
space:
mode:
authorGiovanni Bajo <rasky@develer.com>2018-04-15 16:03:30 +0200
committerGiovanni Bajo <rasky@develer.com>2018-04-29 09:38:18 +0000
commit6d379add0fefcc17ed7b763078526800a3c1d705 (patch)
treefaeb34f011cf8637601357d9f4a6fc5d6b4e4635 /src/cmd/compile/internal/ssa/prove.go
parent980fdb8dd5fe0151a9b7e84ec6b8c20a11727521 (diff)
downloadgo-6d379add0fefcc17ed7b763078526800a3c1d705.tar.gz
go-6d379add0fefcc17ed7b763078526800a3c1d705.zip
cmd/compile: in prove, detect loops with negative increments
To be effective, this also requires being able to relax constraints on min/max bound inclusiveness; they are now exposed through a flags, and prove has been updated to handle it correctly. Change-Id: I3490e54461b7b9de8bc4ae40d3b5e2fa2d9f0556 Reviewed-on: https://go-review.googlesource.com/104041 Run-TryBot: Giovanni Bajo <rasky@develer.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/prove.go')
-rw-r--r--src/cmd/compile/internal/ssa/prove.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go
index 536cfcebf0..0767be7d57 100644
--- a/src/cmd/compile/internal/ssa/prove.go
+++ b/src/cmd/compile/internal/ssa/prove.go
@@ -799,8 +799,17 @@ func addIndVarRestrictions(ft *factsTable, b *Block, iv indVar) {
d |= unsigned
}
- addRestrictions(b, ft, d, iv.min, iv.ind, lt|eq)
- addRestrictions(b, ft, d, iv.ind, iv.max, lt)
+ if iv.flags&indVarMinExc == 0 {
+ addRestrictions(b, ft, d, iv.min, iv.ind, lt|eq)
+ } else {
+ addRestrictions(b, ft, d, iv.min, iv.ind, lt)
+ }
+
+ if iv.flags&indVarMaxInc == 0 {
+ addRestrictions(b, ft, d, iv.ind, iv.max, lt)
+ } else {
+ addRestrictions(b, ft, d, iv.ind, iv.max, lt|eq)
+ }
}
// addBranchRestrictions updates the factsTables ft with the facts learned when