Commit 7c1e778
committed
cmd/compile: make prove use non-equality in subtraction for a stronger bound
Given:
s := /* slice */
k := /* proved valid index in s (0 <= k < len(s)) */
v := s[k:]
len(v) >= 1, so v[0] needs no bounds check. However, for
len(v) = len(s) - k, we only checked if len(s) >= k and so could only
prove len(v) >= 0, thus the bounds check wasn't removed.
As far as I can tell these checks were commented out for performance,
but after benchmarking prove I see no difference.
Fixes: #764291 parent cead111 commit 7c1e778
1 file changed
+11
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2162 | 2162 | | |
2163 | 2163 | | |
2164 | 2164 | | |
2165 | | - | |
2166 | | - | |
2167 | | - | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
2168 | 2171 | | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | 2172 | | |
2174 | 2173 | | |
2175 | 2174 | | |
2176 | | - | |
2177 | | - | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
2178 | 2180 | | |
2179 | | - | |
2180 | | - | |
2181 | | - | |
2182 | | - | |
2183 | 2181 | | |
2184 | 2182 | | |
2185 | 2183 | | |
| |||
0 commit comments