compiler: recognize and optimize array range clear

Programming / Compilers / GCC - ian [138bc75d-0d04-0410-961f-82ee72b054a4] - 3 May 2019 21:45 EDT

Recognize

for i := range a { a[i] = zero }

for array or slice a, and rewrite it to call memclr, as the gc compiler does.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/169398

d2199dbca72 compiler: recognize and optimize array range clear
gcc/go/gofrontend/MERGE | 2 +-
gcc/go/gofrontend/expressions.cc | 116 ++++++++++++++++++++++++++++++++++++++
gcc/go/gofrontend/expressions.h | 32 ++++++++++-
gcc/go/gofrontend/runtime.def | 8 +++
gcc/go/gofrontend/statements.cc | 118 +++++++++++++++++++++++++++++++++++++++
gcc/go/gofrontend/statements.h | 5 ++
libgo/go/runtime/mbarrier.go | 1 +
7 files changed, 280 insertions(+), 2 deletions(-)

Upstream: gcc.gnu.org


  • Share