From bb5ff5342d31723ecf245e8e53b79bce23b88839 Mon Sep 17 00:00:00 2001 From: Jakub Ciolek Date: Mon, 3 Oct 2022 18:08:29 +0200 Subject: cmd/compile: make loopbce handle 8, 16 and 32 bit induction variables Compute limits and increment values for all integer widths. Resolves 2 TODO's in loopbce.go compilecmp linux/amd64: compress/flate compress/flate.(*huffmanEncoder).bitCounts 1235 -> 1207 (-2.27%) cmd/internal/obj/wasm cmd/internal/obj/wasm.assemble 7443 -> 7303 (-1.88%) cmd/internal/obj/wasm.assemble.func1 165 -> 138 (-16.36%) cmd/link/internal/ld cmd/link/internal/ld.(*Link).findfunctab.func1 1646 -> 1627 (-1.15%) Change-Id: I2d79b7376eb67d6bcc8fdaf0c197c11e631562d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/435258 Reviewed-by: Benny Siegert Run-TryBot: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Keith Randall Reviewed-by: Keith Randall --- test/loopbce.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/loopbce.go') diff --git a/test/loopbce.go b/test/loopbce.go index db830daf5c..fcf0d8d90d 100644 --- a/test/loopbce.go +++ b/test/loopbce.go @@ -63,6 +63,30 @@ func f5(a [10]int) int { return x } +func f5_int32(a [10]int) int { + x := 0 + for i := int32(-10); i < int32(len(a)); i += 2 { // ERROR "Induction variable: limits \[-10,8\], increment 2$" + x += a[i] + } + return x +} + +func f5_int16(a [10]int) int { + x := 0 + for i := int16(-10); i < int16(len(a)); i += 2 { // ERROR "Induction variable: limits \[-10,8\], increment 2$" + x += a[i] + } + return x +} + +func f5_int8(a [10]int) int { + x := 0 + for i := int8(-10); i < int8(len(a)); i += 2 { // ERROR "Induction variable: limits \[-10,8\], increment 2$" + x += a[i] + } + return x +} + func f6(a []int) { for i := range a { // ERROR "Induction variable: limits \[0,\?\), increment 1$" b := a[0:i] // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$" -- cgit v1.2.1